【问题标题】:How to manually enterText box values while running Selenium WebDriver using NUnit in c#如何在 c# 中使用 NUnit 运行 Selenium WebDriver 时手动输入文本框值
【发布时间】:2015-10-07 07:02:29
【问题描述】:

我是 selenuim 的新手,我正在尝试在 c# 中使用 NUnit 实现 Selenium WebDriver。为此,我在 Visual Studio 中创建了一个测试项目。

我正在使用下面的代码来访问用户名和密码。

        driver.FindElement(By.Id("UserName")).Clear();
        driver.FindElement(By.Id("UserName")).SendKeys("ABC");
        driver.FindElement(By.Id("Password")).Clear();
        driver.FindElement(By.Id("Password")).SendKeys("XXXX");

现在如何在 C# 中使用 NUnit 运行 Selenium WebDriver 时手动输入文本框值

谢谢

【问题讨论】:

  • 在您的自动化测试脚本中,您已经使用 SendKeys 输入了用户名和密码的值。值将在相应的文本框中自动输入/输入。为什么需要手动输入?

标签: visual-studio c#-4.0 selenium-webdriver nunit


【解决方案1】:

SendKeys 用于将值传递给 Selenium WebDriver 中的任何文本框。当您通过 SendKeys 发送密码时,同样通过标识符查找任何文本框并使用 SendKeys()。我希望这会有所帮助。

【讨论】:

    猜你喜欢
    • 2013-05-05
    • 2016-12-11
    • 2012-08-05
    • 1970-01-01
    • 2012-02-13
    • 2014-06-29
    • 2016-06-20
    • 2021-04-26
    • 2014-11-08
    相关资源
    最近更新 更多