【问题标题】:Unable to click buttons with HtmlUnitDriver but able to click buttons with FirefoxDriver无法使用 HtmlUnitDriver 单击按钮,但能够使用 FirefoxDriver 单击按钮
【发布时间】:2022-02-01 19:39:33
【问题描述】:

我有一个使用 Selinium HtmlUnitDrive 的代码。我可以访问网站并点击cookies 除外,但我似乎无法点击播放演示 em> 按钮。我不知道有什么问题,因为我可以使用 FirefoxDriver 单击所有按钮。

在我无法使用 HtmlUnitDriver 访问任何元素之前,直到我使用 WebDriver driver = new HtmlUnitDriver(BrowserVersion.FIREFOX, true);

有人可以帮忙吗,因为我正在寻找使用 HtmlUnitDriver。

【问题讨论】:

    标签: javascript java selenium selenium-firefoxdriver htmlunit-driver


    【解决方案1】:

    这可能是一个错字,因为Play 之间没有空格。实际上,您的代码块将是:

    //CLICK DEMO BUTTON
    wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//button[text()='Play Demo ']"))).click();
    System.out.println("DEMO BUTTON CLICKED");
    

    容纳空格,你可以使用:

    wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//button[normalize-space()='Play Demo']"))).click();
    

    【讨论】:

      猜你喜欢
      • 2014-01-08
      • 2021-08-30
      • 2019-05-30
      • 2013-07-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多