我在mac os上运行selenium测试,我在mac机器上本地运行safari驱动程序没有问题,但是当尝试通过TeamCity代理运行测试时(与本地代码相同),我不断收到错误:
Aug 10, 2014 6:16:27 PM org.openqa.selenium.safari.SafariDriverServer start
[18:16:27][exec] INFO: Server started on port 10862
[18:16:27][exec] Aug 10, 2014 6:16:27 PM org.openqa.selenium.safari.SafariDriverCommandExecutor start
[18:16:27][exec] INFO: Launching Safari
[18:16:27][exec] Aug 10, 2014 6:16:27 PM org.openqa.selenium.safari.SafariDriverCommandExecutor start
[18:16:27][exec] INFO: Waiting for SafariDriver to connect
[18:17:12][exec] INFO: Stopping server
[18:17:12][exec] Aug 10, 2014 6:17:12 PM org.openqa.selenium.safari.SafariDriverServer stop
org.openqa.selenium.safari.SafariDriverCommandExecutor stop
[18:17:12][exec] INFO: Shutdown complete
[18:17:19][exec] Original message: org.openqa.selenium.remote.UnreachableBrowserException: Failed to connect to SafariDriver after 45072 ms
[18:17:19][exec] Build info: version: '2.42.0', revision: '5e82430', time: '2014-05-22 20:18:07'
[18:17:19][exec] System info: host: 'eyals-Mac-mini.local', ip: '192.168.1.102', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.9.4', java.version: '1.8.0_11'
[18:17:19][exec] Driver info: driver.version: SafariDriver
为什么会这样?
这是我运行驱动程序的代码:
dc = DesiredCapabilities.safari();
SafariOptions safariOptions = new SafariOptions();
safariOptions.setUseCleanSession(true);
safariOptions.setDataDir(new File(System.getProperty("user.home") +"/Library/Safari"));
dc.setCapability(SafariOptions.CAPABILITY, safariOptions);
dc.setCapability(CapabilityType.UNEXPECTED_ALERT_BEHAVIOUR, UnexpectedAlertBehaviour.IGNORE);
dc.setPlatform(Platform.MAC);
driver = new SafariDriver(dc);
答案 0 :(得分:0)
我有同样的问题。唯一的解决方案是为你的mac机器分配更多的内存,或者用更多的Ram获得更好的mac。我重新安装了我的mac OS来处理这个问题。