【问题标题】:How to find a certain web-element on the web-page如何在网页上找到某个网页元素
【发布时间】:2019-07-22 12:01:00
【问题描述】:

使用 WebDriver(Java 驱动)的自定义 XPath 无法在 https://cloud.google.com/products/calculator/ 上找到“实例数”字段

我已经尝试过 xpath: //input[@name = "quantity" and @id="input_52"] 它适用于 Ctrl + F 和 Chrome 检查代码功能,但不适用于 WebDriver

这是 Idea 中的堆栈跟踪消息: org.openqa.selenium.NoSuchElementException: 没有这样的元素: 无法定位元素: {"method":"xpath","selector":"//input[@name = "quantity" and @id="input_52"]" }

提前感谢您的帮助

【问题讨论】:

    标签: java google-chrome webdriver


    【解决方案1】:

    您尝试操作的元素在框架内,您必须选择框架然后您可以对元素执行操作执行以下步骤以到达 iframe 内的元素(id of iframe is - id="idIframe") -

    driver.switch_to.frame('idIframe');
    driver.find_element_by_xpath("//input[@name = 'quantity' and @id='input_52']");
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-08-18
      • 1970-01-01
      • 1970-01-01
      • 2019-04-16
      • 1970-01-01
      • 2012-05-20
      • 1970-01-01
      相关资源
      最近更新 更多