0

我正在使用 selenium webdriver Chrome。我看到了这么奇怪的东西。我正在测试一个注册帐户。Webdriver 将进入每个字段,看起来它正在输入文本,但没有显示任何内容。字段中不显示任何文本结果。我究竟做错了什么?

@Test
public void testAlreadyUsedEmailSignUp() throws InterruptedException {
     driver.findElement(By.cssSelector("html body.oneColFixCtrHdr div.container div#header div#innerHeader div#menu ul div.btn-gr")).click();
    Thread.sleep(5000);
    // switch to frames inside the webpage
    driver.switchTo().frame("GB_frame"); // 1st frame
    driver.switchTo().frame(0); // 2nd frame
    driver.findElement(By.id("firstName")).click();
    driver.findElement(By.id("firstName")).sendKeys("Tester");
    driver.findElement(By.id("lastName")).sendKeys("Automater");
    driver.findElement(By.id("email")).sendKeys("test11@gmail.com");
    driver.findElement(By.id("Ppassword")).sendKeys("prd1");
    driver.findElement(By.id("confirmPPassword")).sendKeys("pass7ord1");
    driver.findElement(By.id("State")).sendKeys("I");

    driver.findElement(By.id("myInput")).sendKeys("Mike Ward");

    Thread.sleep(2000);

    driver.findElement(By.name("term")).click();
    driver.findElement(By.id("formAccSubmit")).click();

    assertEquals(driver.findElement(By.id("errorContainer")).getText(),
            "The Email field must contain a valid email address.");

    Thread.sleep(5000);
}
4

1 回答 1

0

使用下面的代码,您的问题将解决,删除 OR.getProperty 并使用您的属性。

String txtuserzipID = OR.getProperty("txt_UserZip_ID"); 
WebElement txtuserZipInput = driver.findElement(By.id(txtuserzipID));
txtuserZipInput.clear(); 
txtuserZipInput.sendKeys(String.valueOf(79081));
txtuserZipInput = driver.findElement(By.id(txtuserzipID));
new Actions(driver).sendKeys(driver.findElement(By.id(OR.getProperty("txt_UserZip_ID"))), 
"").perform();

希望它会起作用并解决您的问题。谢谢

于 2013-04-25T14:00:19.493 回答