更新时间: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: