excel - 如何通过 Selenium VBA 向某些 HTML 元素发送文本?
问题描述
我在通过 VBA 中的 Selenium 引用网站上的搜索框时遇到了麻烦。盒子的HTML代码是:
<input type = "search" class ="form-control input-sm"
placeholder aria-controls="result_table"> ==$0
我努力了
bot.findElementByCssSelector(".form-control").SendKeys ("werresf")
bot.findElementByCssSelector(".form-control.input-sm").SendKeys ("werresf")
bot.findElementByCssSelector(".input-sm").SendKeys ("werresf")
bot.findElementByCssSelector(".form-control input-sm").SendKeys ("werresf")
bot.findElementByClassName("form-control input-sm").SendKeys ("werresf")
但它们似乎都不起作用。任何帮助是极大的赞赏。
解决方案
要在所需元素中发送字符序列,您可以使用以下任一Locator Strategies:
使用
FindElementByCss
:bot.FindElementByCss("input.form-control.input-sm[aria-controls='result_table']").SendKeys ("werresf")
使用
FindElementByXPath
:bot.FindElementByXPath("//input[@class='form-control input-sm' and @aria-controls='result_table']").SendKeys ("werresf")
参考
您可以在以下位置找到一些相关的讨论:
推荐阅读
- firebase - 我是否正确使用 Firestore 索引?
- c# - 使用 C# 将数据从 CSV 文件批量复制到 PostgreSQL 数据库
- c++ - Windows经典示例中“静态声明”注释的含义
- excel - 将 1 长水平块更改为垂直块
- django - 如何使用 GraphQLTestCase 在石墨烯 django 中使用 django-grahql-jwt 进行身份验证?
- javascript - 将隐藏值添加到输入表单(可能是 JS)
- sql - 使用 Try Catch 块开始事务
- c# - 从 http 请求流中解析内容类型标头
- azure-cosmosdb - 如何让 cosmosdb 模拟器向 OSX 上运行的 nodejs 应用程序公开端口?
- css - 如何在“oe_structure”中放置“轮播”div而不重叠