【问题标题】:findElement by.xpath not working for Html5 section tag?findElement by.xpath 不适用于 Html5 部分标记?
【发布时间】:2014-07-31 07:26:36
【问题描述】:

xpath 的 findElement 不适用于部分标签。我尝试了几次 xpath 也不是动态的,它是静态的,但我仍然收到此消息

线程“主”org.openqa.selenium.NoSuchElementException 中的异常:无法定位元素:{"method":"xpath","selector":"/html/body/div[2]/section/div/div/div/div/div/form/div/div[2]/div[3]/div/div[2]/div/input"} 命令持续时间或超时:6.66 秒"

我还搜索了几个关于这个问题的表格,许多人说使用最新的 selenium 独立 jar 文件。我只使用最新版本的“selenium-server-standalone-2.42.2.jar”

相关HTML:

<div id="uploading-url">
   <p class="reduce-space"><img alt="web_image" src="/images/content/duelr/web.png"></p>
   <input placeholder="Enter URLs to upload from web" type="text">
</div>

【问题讨论】:

  • 向我们展示相关的 HTML
  • @olyv 相关的 HTML 是

标签: java xpath selenium-webdriver


【解决方案1】:

使用以下 xpath 获取 input 标签的元素:

//div[@id='uploading-url']//input

【讨论】:

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