【问题标题】:Robot framework: How to locate a input text field and how to input a value in it机器人框架:如何定位输入文本字段以及如何在其中输入值
【发布时间】:2021-01-13 04:33:12
【问题描述】:

我的 HTML 是这样的:

<input type="text" placeholder="Search for extensions" class="user-input" style="width: 370px;">

如果我尝试获取 html 路径的 Xpath,我会低于输入文本路径,但我也无法输入任何文本并低于错误

带有定位符的元素 'xpath://*[@id="extensions-container"]/div/div[3]/div2/div2/div/div2/form/span 2/input' 未找到。

Click Element    name:extensions
Input Text       xpath://*[@id="extensions-container"]/div/div[3]/div[1]/div[1]/div/div[1]/form/span[1]/input    cli 

【问题讨论】:

  • 先检查有没有iframe。
  • input[class='user-input'] 会是更好的 xpath 使用。
  • 我附上了图片,没有iframe。我也很乐意只使用类,但是完整的关键字是什么?
  • 您还可以从开发人员工具的页面中获取 css 选择器。 //输入[class='用户输入']
  • 我确实尝试过使用它,但我收到了这个错误。 找不到定位器“css:input.user-input”的元素.

标签: html selenium selenium-chromedriver robotframework rpa


【解决方案1】:

这应该可行:

Input Text    css:input[placeholder="Search for extensions"]    cli

【讨论】:

  • 谢谢,我能用同样的。
【解决方案2】:

试试这个定位器:

//input[@placeholder="Search for extensions"] 

【讨论】:

    猜你喜欢
    • 2016-11-15
    • 2016-09-09
    • 2018-03-27
    • 1970-01-01
    • 1970-01-01
    • 2018-07-29
    • 2013-07-15
    • 1970-01-01
    • 2020-03-20
    相关资源
    最近更新 更多