Selenium脚本无法在Chrome&詹金斯的Firefox

时间:2016-06-30 12:33:25

标签: selenium-webdriver jenkins testng selenium-chromedriver

我有Selenium webdriver使用TESTNG& Maven。我可以在IEChrome&来自Firefox的{​​{1}}。

当我使用Eclips安排测试时,如果我使用Jenkins,我的测试运行正常,但他们在IE& chrome。我不确定Firefox

这是日志:

Selenium Grid

功能

FAILED CONFIGURATION: @BeforeClass beforeTest
org.openqa.selenium.WebDriverException: unknown error: unable to
discover open pages   (Driver info: chromedriver=2.21.371459
(36d3d07f660ff2bc1bf28a75d1cdabed0983e7c4),platform=Windows NT 6.1 SP1
x86_64) (WARNING: The server did not provide any stacktrace
information) Command duration or timeout: 60.77 seconds Build info:
version: '2.53.0', revision: '35ae25b', time: '2016-03-15 16:57:40'
System info: host: , os.name: 'Windows 7', os.arch: 'amd64',
os.version: '6.1', java.version: '1.8.0_91' Driver info:
org.openqa.selenium.chrome.ChromeDriver     at
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at
org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:206)
    at
org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:158)
    at
org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:678)
    at
org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:249)
    at
org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:131)
    at
org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:144)
    at
org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:170)
    at
org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:159)
    at
org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:116)
    at Foundation.BrowserFactory.getBrowser(BrowserFactory.java:45)     at
PageObj.LogIn_Page.openApp(LogIn_Page.java:39)  at
Scripts.CreateAppointment.beforeTest(CreateAppointment.java:29)     at
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)     at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)     at
org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:85)
    at
org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:510)
    at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:211)
    at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:138)
    at
org.testng.internal.TestMethodWorker.invokeBeforeClassMethods(TestMethodWorker.java:170)
    at
org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:104)
    at org.testng.TestRunner.privateRun(TestRunner.java:774)    at
org.testng.TestRunner.run(TestRunner.java:624)  at
org.testng.SuiteRunner.runTest(SuiteRunner.java:359)    at
org.testng.SuiteRunner.runSequentially(SuiteRunner.java:354)    at
org.testng.SuiteRunner.privateRun(SuiteRunner.java:312)     at
org.testng.SuiteRunner.run(SuiteRunner.java:261)    at
org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)    at
org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)     at
org.testng.TestNG.runSuitesSequentially(TestNG.java:1215)   at
org.testng.TestNG.runSuitesLocally(TestNG.java:1140)    at
org.testng.TestNG.run(TestNG.java:1048)     at
org.testng.TestNG.privateMain(TestNG.java:1355)     at
org.testng.TestNG.main(TestNG.java:1324)

2 个答案:

答案 0 :(得分:0)

你在VM上运行Jenkins吗?或者您在本地运行测试的相同环境?如果它在IE上运行并且在所有网络浏览器上都可以在本地运行,并且如果你使用的是虚拟机,那么它必须关闭才能在虚拟机上安装Firefox和Chrome?

答案 1 :(得分:0)

如果您使用的是Windows,请在系统管理员中运行Jenkins服务,

  1. 打开以运行cmd
  2. 输入服务,然后单击“确定”按钮
  3. 打开服务对话框,找到Jenkins服务。转到服务属性
  4. 转到登录标签,选择第二个选项。提供您的管理员用户而不是本地服务器
  5. 然后重启服务。
  6. 这解决了我遇到的问题。谢谢!