在 Firefox 浏览器窗口中通过 Selenium 运行一些测试时出现“找不到配置文件目录”错误

问题描述 投票:0回答:1

请给我建议。我正在学习 Selenium WebDriver 工具并尝试在 Firefox 窗口中运行一些测试,但第二次测试总是失败。我怎样才能避免这种情况?

Gecko 驱动程序:v0.25.0-win32;

硒:3.141.59;

框架:JUnit;

火狐浏览器:69.0

我尝试了隐式和显式等待,但没有帮助。

我的通用 TestBase java 类:

public class TestBase {

  public static WebDriver driver;
  public static WebDriverWait wait;

  @Before
  public void start() {
    if (driver !=null){
      return;
    }

    DesiredCapabilities caps = new DesiredCapabilities();
    //caps.setCapability(FirefoxDriver.MARIONETTE, false);
    driver = new FirefoxDriver(caps);
    System.out.println(((HasCapabilities) driver).getCapabilities());
    wait = new WebDriverWait(driver, 10);


    Runtime.getRuntime().addShutdownHook(
            new Thread(() -> { driver.quit(); driver=null;}));
  }

和基于测试的课程:

public class MyThirdTest extends TestBase {

  @Test
  public void mySecondTest() {
    driver.navigate().to("https://google.com");
    driver.findElement(By.name("q")).sendKeys("webdriver");
    wait.until(ExpectedConditions.visibilityOfElementLocated(By.name("btnK"))).click();
    wait.until(titleIs("webdriver - Поиск в Google"));
  }

  @Test
  public void myThirdTest() {
    driver.navigate().to("https://google.com");
    driver.findElement(By.name("q")).sendKeys("webdriver");
    wait.until(ExpectedConditions.visibilityOfElementLocated(By.name("btnK"))).click();
    wait.until(titleIs("webdriver - Поиск в Google"));
  }
}

我的输出是错误的:

JavaScript 错误:resource://gre/modules/XULStore.jsm,第 66 行:错误: 找不到配置文件目录。 1568573084487 木偶INFO听力 在端口 58557 2019 年 9 月 15 日 9:44:44 PM org.openqa.selenium.remote.ProtocolHandshake createSession 信息: 检测到的方言:W3C

java selenium selenium-webdriver automated-tests geckodriver
1个回答
0
投票

Firefox Quantum [v69] 不支持 Selenium

请将 Firefox 降级至最低 v57。

https://firefox-source-docs.mozilla.org/testing/geckodriver/Support.html

© www.soinside.com 2019 - 2024. All rights reserved.