Vishnu
March 28, 2016, 6:20am
1
i tried the below code for entering username and password in my text field and then click on the login button :
@Test
public static void test() throws Exception
{
WebElement elementUser = driver.findElement(By.id(“com.sample.en:id/etUserName”));
elementUser.sendKeys(“vishnu”);
WebElement elementPass = driver.findElement(By.id(“com.sample.en:id/etPassword”));
elementPass.sendKeys(“vishnu”);
driver.findElement(By.name(“Sign in”)).click();
Thread.sleep(9000);
}
but what happens is when the username(vishnu) is entered the keypad pops up and the next text field is not accesssed.
Can anyone tell me how to scroll down after the password is being entered so that the sign in button below it can be clicked…
you can simply use driver.hideKeyboard()
which would let you access the
Login button without scrolling
1 Like
Vishnu
March 28, 2016, 8:55am
3
Thank u so much…where should i put the code can u tell me…
bipin
March 28, 2016, 9:50am
4
Vishnu:
@Testpublic static void test() throws Exception{
WebElement elementUser = driver.findElement(By.id(“com.sample.en:id/etUserName”));elementUser.sendKeys(“vishnu”);
driver.navigate.back();
WebElement elementPass = driver.findElement(By.id(“com.sample.en:id/etPassword”));elementPass.sendKeys(“vishnu”);
driver.findElement(By.name(“Sign in”)).click();Thread.sleep(9000);
}
Use above code in your Test Suite
driver.navigate.back();
the step after which your keyboard appears
try any of mentioned above. Valid with Android only.
@Test
public static void test() throws Exception {
WebElement elementUser = driver.findElement(By.id("com.sample.en:id/etUserName"));
elementUser.sendKeys("vishnu");
// hide keyboard
// method 1:
driver.hideKeyboard()
// or method 2:
((AndroidDriver) driver).pressKeyCode(AndroidKeyCode.BACK);
// or method 3:
driver.navigate.back();
WebElement elementPass = driver.findElement(By.id("com.sample.en:id/etPassword"));
elementPass.sendKeys("vishnu");
driver.findElement(By.name("Sign in")).click();
Thread.sleep(9000);
}
1 Like