【问题标题】:"Can't find profile directory" error while running some tests in a Firefox browser window by SeleniumSelenium 在 Firefox 浏览器窗口中运行某些测试时出现“找不到配置文件目录”错误
【发布时间】:2020-01-16 17:45:04
【问题描述】:

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

壁虎驱动: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 org.openqa.selenium.remote.ProtocolHandshake createSession 信息: 检测到的方言:W3C

【问题讨论】:

    标签: java selenium selenium-webdriver automated-tests geckodriver


    【解决方案1】:

    不支持 Selenium Firefox Quantum [v69]

    请将 Firefox 降级到最低 v57。

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

    【讨论】:

    • geckodriver 0.30.0 确实支持更高版本的 Firefox,但我仍然收到此错误。
    猜你喜欢
    • 1970-01-01
    • 2019-08-04
    • 1970-01-01
    • 1970-01-01
    • 2014-01-17
    • 1970-01-01
    • 1970-01-01
    • 2011-03-28
    • 1970-01-01
    相关资源
    最近更新 更多