java - Selenium WebDriver : Error communicating with the remote browser. 它可能已经死了

标签 java selenium webdriver

这是我的Selenium 浏览器测试类(派生类,但应该不难理解它在做什么)。当我运行测试用例时,所有交互都按预期发生。但最终测试用例的结果显示失败。

package dmswebui.CR;

import org.infineta.webui.selenium4j.MainTestCase;

public class TestLogin extends MainTestCase {

  @Override
  public void setUp() throws Exception {
    super.setUp();
    startSeleniumSession("ChromeDriver", "http://192.168.8.207/");
  }

  public void testMethod() throws Exception {

        session().open("/");
        session().type("name=user","admin");
        session().type("name=password","infineta123");
        session().click("id=btnLogin-button");      session().waitForPageToLoad("30000");
        session().click("id=btnUserLogout-button");
        session().click("id=yui-gen0-button");      session().waitForPageToLoad("30000");
  }
  public void tearDown() throws Exception {
        super.tearDown();
        closeSeleniumSession();
  }
}

我得到的错误是:

Testcase: testMethod took 13.939 sec
Caused an ERROR
Error communicating with the remote browser. It may have died.

最佳答案

这通常发生在您尝试多次关闭同一个 webdriver 实例时。你知道 super.teardown() 发生了什么吗?当我检查 selenium4j 源代码时,它扩展了 junit Testcase。您的 super.tearDown 将调用 jUnitTeardown 并在调用 closeSeleniumSession() 之前终止浏览器实例。

您可以将 closeSeleniumSession() 放在 super.tearDown() 之前。

关于java - Selenium WebDriver : Error communicating with the remote browser. 它可能已经死了,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11058948/

相关文章:

java - 无法使用 classLoader.getResource(fileName).getFile() 获取文件

python-3.x - selenium.common.exceptions.SessionNotCreatedException : Message: session not created: Chrome version must be between 70 and 73 with ChromeDriver

java - 使用 Selenium webdriver 测试自动完成

python - Selenium 和新标签

java - JPanel 没有出现在 JDialog 中

java - 列出 Active Directory 组中的所有用户

java - 有什么办法可以阻止我的 Android 应用程序在后台扫描 nfc 标签吗?

python - 从 Selenium 导入 webdriver ModuleNotFoundError : No module named 'selenium' (PyCharm)

python - 使用 selenium 和 Chrome 设置代理服务器

java - Eclipse Selenium Facebook登录问题(新页面邮件) driver.findElement(By.id ("email")).sendKeys (""); java