【问题标题】:Webelement finding issuesWebelement 发现问题
【发布时间】:2019-06-12 09:02:01
【问题描述】:

在下面提到的案例中发现Webelement问题

在网页https://pastebin.com/ 上,需要从下拉菜单“粘贴到期:”中选择“10 分钟”选项

以下是采取的步骤:

//Identification the Never option and clicking it the dropdown to show up
//This part of the code works
WebElement pasteExpiration = driver.findElement(By.xpath("//*[@class='form_frame_left']//*[@title = 'Never']"));
pasteExpiration.click();

//Selecting the'10 Minute' option, this code is not identified by the WebDriver
WebElement pasteExpiration10Minutes = driver.findElement(By.cssSelector("#select2-paste_expire_date-q4-container"));

WebDriver 没有看到“10 分钟”选项字段,我们尝试编写自己的 xpath,但没有任何效果。

【问题讨论】:

    标签: java selenium google-chrome selenium-webdriver


    【解决方案1】:

    请尝试以下几行:

    driver.findElement(By.xpath("//span[starts-with(@id,'select2-paste_expire_date')]")).click();
    driver.findElement(By.xpath("//li[text()='10 Minutes']")).click();
    

    它对我有用。我已经检查了 chrome 浏览器。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多