如何通过 Selenium VBA 向某些 HTML 元素发送文本? [英] How to send text to some HTML elements through Selenium VBA?
本文介绍了如何通过 Selenium VBA 向某些 HTML 元素发送文本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在通过 VBA 中的 Selenium 引用网站上的搜索框时遇到了麻烦.盒子的HTML代码是:
I have been having trouble on referring to a search box on a website through Selenium in VBA. The HTML code of the box is:
<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")
但它们似乎都不起作用.非常感谢任何帮助.
But none of them seems to work. Any help is greatly appreciated.
推荐答案
要在所需元素中发送 字符序列,您可以使用以下任一 定位器策略:
To send a character sequence within the desired element you can use either of the following 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")
您可以在以下位置找到一些相关讨论:
You can find a couple of relevant discussions in:
这篇关于如何通过 Selenium VBA 向某些 HTML 元素发送文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文