2013-04-24 26 views
0

我使用的是硒webdriver Chrome。我看到一些很奇怪的東西。我正在測試註冊帳戶。 Webdriver正在進入每個字段,看起來它是輸入文本,但沒有顯示任何內容。沒有文本結果顯示在字段中。我究竟做錯了什麼?Selenium 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("[email protected]"); 
    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); 
} 
+0

你怎麼知道它的輸入文字?它是否登錄? – vidit 2013-04-24 21:50:13

+0

我發給你一個視頻 – Selenio 2013-04-24 22:07:04

+0

你確定你正在檢索一個輸入字段,而不是一些覆蓋它的div嗎? – 2013-04-24 22:44:03

回答

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(); 

希望它能解決您的問題。 謝謝

+0

雖然它有什麼問題? @Umamaheshwar Thota – Selenio 2013-04-25 18:28:18

+0

有時候,Web應用程序不會在字段中保存輸入的數據。我也面臨同樣的問題。之後,通過使用上面的代碼,我已經解決了我的問題.. – 2013-04-26 10:57:48

相關問題