且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用SendKeys时,元素无法与Selenium Excel VBA交互

更新时间:2023-11-16 15:00:34

您非常接近。具有 id 属性为 navbar_password Password 字段具有以下属性:

You were pretty close. The Password field with id attribute as navbar_password is having the property:

style="display: none;"

因此您将无法与该元素进行交互。

So you won't be able to interact with the element.

要将字符序列发送到用户名密码 >字段,您可以使用以下任一定位器策略

To send a character sequence both to the User Name and Password field you can use either of the following Locator Strategies:


  • 使用 FindElementById()

.FindElementById("navbar_username").SendKeys "username"
.FindElementById("navbar_password_hint").SendKeys "password"


  • 使用 FindElementByCss()

    .FindElementByCss("input#navbar_username").SendKeys "username"
    .FindElementByCss("input#navbar_password_hint").SendKeys "password"
    


  • 使用 FindElementByXPath()

    .FindElementByXPath("//input[@id='navbar_username']").SendKeys "username"
    .FindElementByXPath("//input[@id='navbar_password_hint']").SendKeys "password"
    


  • 您可以在以下地方找到一些有趣的讨论:

    You can find a couple of revelant discussions in:

    • Trying to fill text in input box with dynamic drop down
    • Need help to fill number into Chrome input box with Selenium