2
Browser: Firefox 50 version
Selenium Jar files : 3.0.1 jar
OS: Windows 7 enterprise 64 bit 

通过右键单击 xml 文件“作为 testNG 套件运行”来执行脚本时,浏览器会打开,但错误会立即显示在控制台中。

任何人都可以指导我是否需要降级浏览器,如果是的话,selenium 3 版本的支持版本是什么。

错误日志:

[TestNG] Running:
  C:\Users\raghuveer.amajala\AppData\Local\Temp\testng-eclipse-1646049448\testng-customsuite.xml

org.openqa.selenium.firefox.NotConnectedException: Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms. Firefox console output:
true,"v":"1.0","st":1478328645000}},"winreg-app-user":{"ocplugin@webex.com":{"d":"C:\\Program Files (x86)\\WebEx\\Productivity Tools","e":false,"v":"2.0","st":1485264359732,"mt":1463471846535}},"app-global":{"{972ce4c6-7e08-4474-a285-3208198ce6fd}":{"d":"C:\\Program Files (x86)\\Mozilla Firefox\\browser\\extensions\\{972ce4c6-7e08-4474-a285-3208198ce6fd}.xpi","e":true,"v":"50.0","st":1478328645000}},"winreg-app-global":{"{D19CA586-DD6C-4a0a-96F8-14644F340D60}":{"d":"C:\\Program Files (x86)\\Common Files\\McAfee\\SystemCore","e":false,"v":"15.4.0","st":1477288713580,"mt":1476678768866}}}
1485322859314   addons.xpi  DEBUG   No changes found
1485322859325   addons.xpi  DEBUG   Registering manifest for C:\Program Files (x86)\Mozilla Firefox\browser\features\aushelper@mozilla.org.xpi
1485322859326   addons.xpi  DEBUG   Loading bootstrap scope from C:\Program Files (x86)\Mozilla Firefox\browser\features\aushelper@mozilla.org.xpi
1485322859331   addons.xpi  DEBUG   Calling bootstrap method startup on aushelper@mozilla.org version 1.0
1485322859333   addons.xpi  DEBUG   Registering manifest for C:\Program Files (x86)\Mozilla Firefox\browser\features\e10srollout@mozilla.org.xpi
1485322859334   addons.xpi  DEBUG   Loading bootstrap scope from C:\Program Files (x86)\Mozilla Firefox\browser\features\e10srollout@mozilla.org.xpi
1485322859343   addons.xpi  DEBUG   Calling bootstrap method startup on e10srollout@mozilla.org version 1.5
1485322859344   addons.xpi  DEBUG   Registering manifest for C:\Program Files (x86)\Mozilla Firefox\browser\features\firefox@getpocket.com.xpi
1485322859345   addons.xpi  DEBUG   Loading bootstrap scope from C:\Program Files (x86)\Mozilla Firefox\browser\features\firefox@getpocket.com.xpi
1485322859349   addons.xpi  DEBUG   Calling bootstrap method startup on firefox@getpocket.com version 1.0.5
1485322859360   addons.xpi-utils    DEBUG   Starting async load of XPI database C:\Users\RAGHUV~1.AMA\AppData\Local\Temp\anonymous8881786919455687854webdriver-profile\extensions.json
1485322859362   addons.xpi  DEBUG   Registering manifest for C:\Program Files (x86)\Mozilla Firefox\browser\features\webcompat@mozilla.org.xpi
1485322859362   addons.xpi  DEBUG   Loading bootstrap scope from C:\Program Files (x86)\Mozilla Firefox\browser\features\webcompat@mozilla.org.xpi
1485322859365   addons.xpi  DEBUG   Calling bootstrap method startup on webcompat@mozilla.org version 1.0
1485322859367   addons.manager  DEBUG   Registering shutdown blocker for XPIProvider
1485322859367   addons.manager  DEBUG   Provider finished startup: XPIProvider
1485322859367   addons.manager  DEBUG   Starting provider: LightweightThemeManager
1485322859367   addons.manager  DEBUG   Registering shutdown blocker for LightweightThemeManager
1485322859368   addons.manager  DEBUG   Provider finished startup: LightweightThemeManager
1485322859368   addons.manager  DEBUG   Starting provider: GMPProvider
1485322859386   addons.manager  DEBUG   Registering shutdown blocker for GMPProvider
1485322859386   addons.manager  DEBUG   Provider finished startup: GMPProvider
1485322859386   addons.manager  DEBUG   Starting provider: PluginProvider
1485322859387   addons.manager  DEBUG   Registering shutdown blocker for PluginProvider
1485322859387   addons.manager  DEBUG   Provider finished startup: PluginProvider
1485322859387   addons.manager  DEBUG   Completed startup sequence
1485322859726   addons.xpi-utils    DEBUG   Async JSON file read took 0 MS
1485322859726   addons.xpi-utils    DEBUG   Finished async read of XPI database, parsing...
1485322859728   addons.xpi-utils    DEBUG   Successfully read XPI database
1485322859739   addons.manager  DEBUG   Starting provider: <unnamed-provider>
1485322859739   addons.manager  DEBUG   Registering shutdown blocker for <unnamed-provider>
1485322859740   addons.manager  DEBUG   Provider finished startup: <unnamed-provider>
*** Blocklist::_loadBlocklistFromFile: blocklist is disabled
1485322859848   addons.manager  DEBUG   Starting provider: PreviousExperimentProvider
1485322859849   addons.manager  DEBUG   Registering shutdown blocker for PreviousExperimentProvider
1485322859849   addons.manager  DEBUG   Provider finished startup: PreviousExperimentProvider

    at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:118)
    at org.openqa.selenium.firefox.FirefoxDriver.startClient(FirefoxDriver.java:246)
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:114)
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:193)
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:186)
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:182)
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:95)
    at Registration.Registration_webdriver.SetUp(Registration_webdriver.java:88)
    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:497)
    at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:84)
    at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:564)
    at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:213)
    at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:138)
    at org.testng.internal.TestMethodWorker.invokeBeforeClassMethods(TestMethodWorker.java:175)
    at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:107)
    at org.testng.TestRunner.privateRun(TestRunner.java:767)
    at org.testng.TestRunner.run(TestRunner.java:617)
    at org.testng.SuiteRunner.runTest(SuiteRunner.java:334)
    at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329)
    at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291)
    at org.testng.SuiteRunner.run(SuiteRunner.java:240)
    at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
    at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
    at org.testng.TestNG.runSuitesSequentially(TestNG.java:1224)
    at org.testng.TestNG.runSuitesLocally(TestNG.java:1149)
    at org.testng.TestNG.run(TestNG.java:1057)
    at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:132)
    at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:236)
    at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:81)`

下面是setup()我课前的方法。

@BeforeClass
public void SetUp()throws Exception
{ 
 //System.setProperty("webdriver.ie.driver","D:\\jar-files\\IEDriverServer_Win32_2.39.0\\IEDriverServer.exe");
 //driver = new InternetExplorerDriver();
    //String firefoxlocation=System.getenv("ProgramFiles(X86)")+"\\Mozilla Firefox\\firefox.exe";
    //System.setProperty("webdriver.firefox.bin", firefoxlocation);
    System.setProperty("webdriver.gecko.driver", driverPath+"geckodriver.exe");
    driver = new FirefoxDriver();
    driver.get(partnerportalurl);
    driver.manage().window().maximize();
    String title=driver.getTitle();
    System.out.println(title);

}
4

2 回答 2

0

selenium tries to use the firefox which is currently installed on your machine. This one is probably newer than the one supported in your selenium version. To fix this you could download a compatible firefox version and pass it in the DesiredCapabilities. It is always helpful to read the selenium changelog for the supported firefox versions.

DesiredCapabilities capabilities = new DesiredCapabilities();

// linux
capabilities.setCapability(FirefoxDriver.BINARY, "/path/to/your_firefox/firefox-bin");
// win
capabilities.setCapability(FirefoxDriver.BINARY, "C:\\path\\to\\your_firefox\\firefox.exe");

WebDriver webdriver = new FirefoxDriver(capabilities);
于 2017-01-23T09:11:57.997 回答
0

只需降级到 Firefox 47.0.1 并禁用更新。每当 Firefox 更新到版本 50 时,我都会遇到这个问题。(在 selenium 2.x 和 3.x 上测试的问题)。

请看这里

于 2017-02-07T12:04:14.943 回答