java - Firefox浏览器49.0版本是否不支持selenium Standalone server 2.50?

标签 java eclipse selenium selenium-webdriver

selenium 不支持最新的 mozilla 版本,有什么解决方案吗?

这是我的代码

package Admin_Package;

import org.openqa.selenium.WebDriver; import
org.openqa.selenium.firefox.FirefoxDriver;

public class test {



public static void main(String[] args) throws InterruptedException {
    // Download "geckodriver.exe" from https://github.com/mozilla/geckodriver/releases
    System.setProperty("webdriver.gecko.driver","D:\\ecl_ee\\jar_files\\gecko_driver\\geckodriver.exe");
    WebDriver driver = new FirefoxDriver();

    driver.get("http://www.facebook.com");

    System.out.println("Application title is ============="+driver.getTitle());

    driver.quit();
} }

If I am using 3.0.1 standalone below mention error is coming java.lang.IllegalStateException: The driver executable does not exist: D:\ecl_ee\jar_files\gecko_driver\geckodriver.exe at com.google.common.base.Preconditions.checkState(Preconditions.java:199) at org.openqa.selenium.remote.service.DriverService.checkExecutable(DriverService.java:121) at org.openqa.selenium.remote.service.DriverService.findExecutable(DriverService.java:116) at org.openqa.selenium.firefox.GeckoDriverService.access$000(GeckoDriverService.java:37) at org.openqa.selenium.firefox.GeckoDriverService$Builder.findDefaultExecutable(GeckoDriverService.java:95) at org.openqa.selenium.remote.service.DriverService$Builder.build(DriverService.java:296) at org.openqa.selenium.firefox.FirefoxDriver.createCommandExecutor(FirefoxDriver.java:277) at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:247) at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:242) at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:135) at Admin_Package.test.before(test.java:20) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:86) at org.testng.internal.Invoker.invokeMethod(Invoker.java:646) at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:823) at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1131) at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:129) at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:112) at org.testng.TestRunner.privateRun(TestRunner.java:778) at org.testng.TestRunner.run(TestRunner.java:632) at org.testng.SuiteRunner.runTest(SuiteRunner.java:366) at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:361) at org.testng.SuiteRunner.privateRun(SuiteRunner.java:319) at org.testng.SuiteRunner.run(SuiteRunner.java:268) at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52) at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86) at org.testng.TestNG.runSuitesSequentially(TestNG.java:1225) at org.testng.TestNG.runSuites(TestNG.java:1075) at org.testng.TestNG.run(TestNG.java:1047) at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:126) at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:137) at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:58)

打开浏览器,然后出现此错误

1478585217132 geckodriver INFO    Listening on 127.0.0.1:42466
Nov 08, 2016 11:36:57 AM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Attempting bi-dialect session, assuming Postel's Law holds true on the remote end
1478585217594 mozprofile::profile INFO    Using profile path C:\Users\Divya\AppData\Local\Temp\rust_mozprofile.Xge4QjcxXLSu
1478585217596 geckodriver::marionette INFO    Starting browser C:\Program Files\Mozilla Firefox\firefox.exe
1478585217605 geckodriver::marionette INFO    Connecting to Marionette on localhost:2185
1478585219168 Marionette  INFO    Listening on port 2185
1478585221536 Marionette  INFO    startBrowser 2a9015b9-cac1-4641-839d-8f9279055519
Nov 08, 2016 11:37:01 AM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: W3C
JavaScript warning: http://reventics.infoversity.in/app/services/sharedProperties.js, line 13: unreachable code after return statement
JavaScript warning: http://reventics.infoversity.in/app/services/sharedProperties.js, line 13: unreachable code after return statement
Application title is =============Reventics
[Child 1708] ###!!! ABORT: Aborting on channel error.: file c:/builds/moz2_slave/m-rel-w32-00000000000000000000/build/src/ipc/glue/MessageChannel.cpp, line 2052
Nov 08, 2016 11:37:09 AM org.openqa.selenium.os.UnixProcess destroy
SEVERE: Unable to kill process with PID 6120

enter image description here

套件类(class)之前、之后

package Admin_Package;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.BeforeSuite;
public class BA_Admin {
public static WebDriver driver;
@BeforeSuite
public void beforeSuite() throws InterruptedException {           
System.setProperty("webdriver.gecko.driver","D:\\ecl_ee\\jar_files\\gecko_driver\\geckodriver.exe");
WebDriver driver = new FirefoxDriver();
driver.get("URL");
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver.manage().window().maximize();
}
@AfterSuite     
public void afterSuite() throws Exception { 
driver.quit();
}
}

扩展类(class)

package Admin_Package;
import java.util.List;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
public class Role_Add extends Admin_Package.BA_Admin{
@BeforeTest
public void login() throws InterruptedException {
driver.findElement(By.xpath(".//*[@id='txtUsername']")).sendKeys("venkatm");
Thread.sleep(5000);
driver.findElement(By.xpath(".//*[@id='txtPassword']")).sendKeys("Password@123");
Thread.sleep(5000);
driver.findElement(By.xpath("html/body/div[2]/div/form/div/div/div[2]/div/button[1]")).click();
Thread.sleep(5000);
System.out.println("Login Test Case Passed"); 
} 
@Test
public void link1() throws InterruptedException { 
driver.findElement(By.xpath("html/body/div[1]/aside/section/ul[1]/li[1]")).click();
Thread.sleep(5000);
}  
}
}

运行此类后出现以下错误

1478588994124 geckodriver INFO    Listening on 127.0.0.1:36811
Nov 08, 2016 12:39:54 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Attempting bi-dialect session, assuming Postel's Law holds true on the remote end
1478588994625 mozprofile::profile INFO    Using profile path C:\Users\Divya\AppData\Local\Temp\rust_mozprofile.9LNcRBy7LvnX
1478588994628 geckodriver::marionette INFO    Starting browser C:\Program Files\Mozilla Firefox\firefox.exe
1478588994637 geckodriver::marionette INFO    Connecting to Marionette on localhost:3453
1478588996301 Marionette  INFO    Listening on port 3453
1478588998908 Marionette  INFO    startBrowser 533a5574-8667-4d6a-8455-b78be6709d83
Nov 08, 2016 12:39:59 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: W3C
JavaScript warning: http://reventics.infoversity.in/app/services/sharedProperties.js, line 13: unreachable code after return statement
JavaScript warning: http://reventics.infoversity.in/app/services/sharedProperties.js, line 13: unreachable code after return statement
[Utils] Attempting to create D:\ecl_ee\Projects\Reventics\test-output\Default suite\Default test.html
[Utils]   Directory D:\ecl_ee\Projects\Reventics\test-output\Default suite exists: true
[Utils] Attempting to create D:\ecl_ee\Projects\Reventics\test-output\Default suite\Default test.xml
[Utils]   Directory D:\ecl_ee\Projects\Reventics\test-output\Default suite exists: true
FAILED CONFIGURATION: @BeforeTest login
java.lang.NullPointerException
at Admin_Package.Role_Add.login(Role_Add.java:18)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:86)
at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:515)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:216)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:143)
at org.testng.TestRunner.beforeRun(TestRunner.java:656)
at org.testng.TestRunner.run(TestRunner.java:624)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:366)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:361)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:319)
at org.testng.SuiteRunner.run(SuiteRunner.java:268)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1225)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1150)
at org.testng.TestNG.runSuites(TestNG.java:1075)
at org.testng.TestNG.run(TestNG.java:1047)
at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:126)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:137)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:58)

SKIPPED CONFIGURATION: @AfterTest Create_Role
SKIPPED: link1

谢谢

迪维亚

最佳答案

创建局部变量会导致所有麻烦。

WebDriver driver = new FirefoxDriver();

在对象创建时删除WebDriver引用,这样引用就会被添加到全局driver对象中,以便子类可以引用。

关于java - Firefox浏览器49.0版本是否不支持selenium Standalone server 2.50?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40462355/

相关文章:

java - JButtons 显示在父面板之外(?)

eclipse - 如何在 Eclipse IDE 中拆分和取消拆分窗口/ View ?

java - 可滚动 JPanel 中的 Swing 流布局中断元素

java - 为什么我在 ~/.android 文件夹中没有 debug.keystore(对于 mac)?

java.lang.UnsatisfiedLinkError : no JCfiLib in java. 库.path

testing - 如何在 JUnit 4 Webdriver 中遍历父 dom 元素并获取 id?

python - Python Selenium 上的 StaleElementReferenceException 错误

java - 没有 SpringJUnit4ClassRunner 或 AbstractJUnit4SpringContextTests 的 Spring 测试上下文设置(在 Selenium 测试中)

java文本区域和文件输入

java - Android 获取在 EditText 中输入的文本