1、运行时报错,提示
Exception in thread "main" java.lang.NoSuchFieldError: INSTANCE
at org.apache.http.conn.ssl.SSLConnectionSocketFactory.<clinit>(SSLConnectionSocketFactory.java:144)
at org.openqa.selenium.remote.internal.HttpClientFactory.getClientConnectionManager(HttpClientFactory.java:71)
at org.openqa.selenium.remote.internal.HttpClientFactory.<init>(HttpClientFactory.java:57)
at org.openqa.selenium.remote.internal.HttpClientFactory.<init>(HttpClientFactory.java:60)
at org.openqa.selenium.remote.internal.ApacheHttpClient$Factory.getDefaultHttpClientFactory(ApacheHttpClient.java:251)
at org.openqa.selenium.remote.internal.ApacheHttpClient$Factory.<init>(ApacheHttpClient.java:228)
at org.openqa.selenium.remote.HttpCommandExecutor.getDefaultClientFactory(HttpCommandExecutor.java:89)
at org.openqa.selenium.remote.HttpCommandExecutor.<init>(HttpCommandExecutor.java:63)
at org.openqa.selenium.remote.HttpCommandExecutor.<init>(HttpCommandExecutor.java:58)
at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:95)
at org.openqa.selenium.firefox.FirefoxDriver.startClient(FirefoxDriver.java:275)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:116)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:222)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:215)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:211)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:124)
at com.selenium.homepage.HomePage.openBrowse(HomePage.java:44)
at com.selenium.homepage.HomePage.login1(HomePage.java:58)
at com.selenium.homepage.HomePage.main(HomePage.java:29)
原因:一般是由于导入的jar包重复
解决办法:去Build Path中将重复的jar包删除
2、运行时报错,提示
org.openqa.selenium.firefox.NotConnectedException: Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms. Firefox console output:
*** LOG addons.manager: Application has been upgraded
*** LOG addons.xpi: startup
*** LOG addons.xpi: Skipping unavailable install location app-system-local
*** LOG addons.xpi: Skipping unavailable install location app-system-share
*** LOG addons.xpi: Ignoring file entry whose name is not a valid add-on ID:
C:\Users\Salma.n\AppData\Local\Temp\anonymous38301webdriver-profile\extensions\webdriver-staging
*** LOG addons.xpi: checkForChanges
*** LOG addons.xpi-utils: Opening XPI database
C:\Users\Salma.n\AppData\Local\Temp\anonymous38301webdriver-profile\extensions.json
*** LOG addons.xpi: New add-on [email protected] installed in app-profile
*** Blocklist::_loadBlocklistFromFile: blocklist is disabled
*** LOG addons.xpi-utils: Make addon app-profile:[email protected] visible
原因:Selenium和FireFox版本兼容性问题解决办法:升级Selenium或降低FireFox版本
3、启动FireFox弹出导入向导
原因:未知解决办法:将
firefox的profiles.ini所在文件中修改IsRelative=1->IsRelative=0文件位置C:\Users\{用户名}\AppData\Roaming\Mozilla\Firefox\profiles.ini