【问题标题】:Selenium web driver : org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element: [duplicate]Selenium Web 驱动程序:org.openqa.selenium.NoSuchElementException:没有这样的元素:无法找到元素:[重复]
【发布时间】:2019-09-20 16:06:57
【问题描述】:

我点击图片按钮,但出现如下错误:

org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element

HTML:

<img src="../RupeeWeb/images/entry/trade_jm.png" style="width: 25px; margin-bottom: -1px;"/>

我的代码是:

driver.findElement(By.xpath("//*[@id=\"1556776066373-0-uiGrid-002G-cell\"]/a[1]/img")).click();

错误:

Exception in thread "main" org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element:

【问题讨论】:

  • 请使用适当的 HTML 更新您的问题。

标签: selenium selenium-webdriver selenium-chromedriver nosuchelementexception


【解决方案1】:

我认为Wait一定有问题。尝试代码以等待该特定元素。

WabDriverWait wait = new WebDriverWait(driver,20);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//*[@id=\"1556776066373-0-uiGrid-002G-cell\"]/a[1]/img")));
driver.findElement(By.xpath("//*[@id=\"1556776066373-0-uiGrid-002G-cell\"]/a[1]/img")).click();

【讨论】:

    猜你喜欢
    • 2017-05-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-07-07
    • 1970-01-01
    • 2013-12-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多