【问题标题】:How do I find an element for this HTML code for selenium?如何为这个硒的 HTML 代码找到一个元素?
【发布时间】:2021-04-12 01:53:25
【问题描述】:

如何从该 HTML 代码中找到搜索框的定位器?我尝试了所有可能的方法,但没有运气。

【问题讨论】:

  • 你能分享一些你无法继续的代码吗?
  • 请不要将 HTML 作为图像发布,将其发布为格式化文本,以便社区成员能够将其复制到 xpath 测试工具或其他工具中。

标签: python selenium xpath css-selectors robotframework


【解决方案1】:

有很多选择:

XPath = "//input[@placeholder='Enter a question']"
CSS = "[type='search']"
ID = "rc_select_1"

【讨论】:

    【解决方案2】:

    要定位元素,您可以使用以下任一Locator Strategies

    • 使用css_selector

      input.ant-input.ant-input-lg[placeholder='Enter aquestion']
      
    • 使用xpath

      //input[@class='ant-input ant-input-lg' and @placeholder='Enter aquestion']
      

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-06-12
      • 2023-03-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-05-11
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多