Reputation: 521
I am using Webdriver with java. I want to input some numeric value in a text field by using Java. I am using the following code:
driver.findElement(By.id("igtxtctl00_MasterPlaceHolder_WTxtZip")).sendKeys("25025");
But after entering the value completely, the entered value is erased automatically. After the value is stored, I have to click on tab (using script), so that the City field is populated automatically after running the back end process.
I have achieved the same thing using Selenium RC by using below code:
selenium.typeKeys("igtxtctl00_MasterPlaceHolder_WTxtZip", "25025");
Thread.sleep(x);
selenium.keyPress("igtxtctl00_MasterPlaceHolder_WTxtZip", "9");
Upvotes: 1
Views: 2161
Reputation: 5667
try some thing like this
driver.findElement(By.id("igtxtctl00_MasterPlaceHolder_WTxtZip")).sendKeys("25025");
after typing zip code just try to click some where else in the page
driver.findElement(By.id("igtxtctl00_MasterPlaceHolder_WTxtZip")).sendKeys(Keys.TAB);
OR
Try with Actions class.
new Actions(driver).sendKeys(driver.findElement(By.id("igtxtctl00_MasterPlaceHolder_WTxtZip")), "").perform();
Upvotes: 1
Reputation: 2156
From inspecting your code, I see that there is client-side logic based on that zip element. There is a post-back to the server to determine the city. The trigger to the post-back is the tab key.
This means that if you want to effectively test your page, you must send the tab key.
Upvotes: 1