Selinium webdriver C#无法在文本字段中输入文本

时间:2015-10-15 00:59:19

标签: selenium

我无法使用selenium webdriver C#和IE11在文本框字段中输入文本。它打开了URL并点击了登录按钮,但没有输入用户名。

我在用户名文本框字段中输入文字的代码是

IWebElement myField = driver.FindElement(By.Id(“Loginlogin”));
myField.SendKeys("sandy");

HTML

<form method="post" name="Login" action="lg01.asp?ccsForm=Login">
   <table class="RecordImpac" cellspacing="0" cellpadding="0">
      <tr class="Controls">
         <td><strong>Username</strong></td>
      </tr>
      <tr class="Controls">
         <td valign="top">
            <input id="Loginlogin" maxlength="100" size="30" value="" name="login">
            <br>
         </td>
      </tr>

ENV:

Browser IE11
IE webdriver server: IEDriverServer_x64_2.47.0
Visual Studio 2015 community

1 个答案:

答案 0 :(得分:1)

我可以成功将文本发送到用户名文本框。代码是Java。您可以相应地转换为C#。尝试一些隐含的等待。

System.setProperty("webdriver.ie.driver","pathtoiedriver\\IEDriverServer.exe");
      WebDriver driver=new InternetExplorerDriver();
    driver.get("location/test_html.html");
    driver.manage().timeouts().implicitlyWait(80, TimeUnit.SECONDS);

    driver.findElement(By.id("Loginlogin")).sendKeys("sandy");