One more think
I need to select United Kingdom in the spinner.
I used driver.scrollToExact(“United Kingdom”);
I need to Pic the exact word ‘United Kingdom’
In my list 300 Country’s are available
it is scrolling slowly like user swapping.
How to pic exact word???
Use getText command immediate after driver.scrollToExact(“United Kingdom”);
like
driver.scrollToExact(“United Kingdom”);
driver.findElement(By.(locator)).getText();
i am using same for click(After scroll ), so i think for getText also it should word.
I am not able to select the state by using below code
driver.scrollToExact(“Uttar Pradesh”);
driver.findElementByName(“Uttar Pradesh”).getText();
Code is trying to pick the Uttar Pradesh state but numeric keyboard was already opened for mobile number field.
Can you please help me, how to hide the keyboard? so that i could call below script
river.scrollToExact(“Uttar Pradesh”);
driver.findElementByName(“Uttar Pradesh”).getText();
By.name has been deprecated.
Try using findElementByAndroidUIAutomator
Eg:
driver.findElementByAndroidUIAutomator(“new UiSelector().text(“America”)”).click();
public void swipeUpUntilTextExists(String expectedText, int howManyTimesToSwipe) {
int i = 0;
do {
swipeUP();
i++;
if (i == howManyTimesToSwipe)
break;
} while (!driver.getPageSource().contains(expectedText));
}
swipe method:
public void swipeUP(){
Dimension size = driver.manage().window().getSize();
log.info(size);
// calculate coordinates for vertical swipe
int startVerticalY = (int) (size.height * 0.8);
int endVerticalY = (int) (size.height * 0.2);
int startVerticalX = (int) (size.width / 2);
new TouchAction(driver).press(point(startVerticalX, startVerticalY)).waitAction(waitOptions(ofSeconds(3))).moveTo(point(startVerticalX, endVerticalY)).release().perform();
}
or this with uiAutomator: @AndroidFindBy(uiAutomator = “new UiScrollable(new UiSelector()).scrollIntoView(text(“Tokyo”))”)
public MobileElement tokyo;