有一个脚本去网站。现在我想登录并进入下一个屏幕。找不到关于如何转到“用户名:”文本框,然后是“密码:”文本框的代码。
最佳答案
您需要向我们提供该页面的一些 HTML,但要给我们一个像这样的密码文本框:
<input type="password" id="passwordTextBox">
我会像这样使用 Selenium 的 WebDriver 找到它:
IWebDriver firefoxDriver = new FirefoxDriver();
IWebElement passwordTextBox = firefoxDriver.FindElement(By.Id("passwordTextBox"));
然后我会像这样“写入”它:
passwordTextBox.Clear();
passwordTextBox.SendKeys("password");
我会看一下 Selenium Web Driver 文档,并在您通读所有内容后提出任何问题:
关于c# - 在 C# 中使用 Selenium Webdriver,如何选择要写入的文本框,然后写入其中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10557196/