Uneven responses when selecting from a drop-down lists

I am using native Android App. I have three drop-down menus on the page. The first selects properly, but the last two tends to not be selecting sometimes. It may work and then stop. The drop-down lists is not visible on the DOM. What is the best way to select this?

Selecting the state automatically loads the city.

This is the code i was using that stopped working recently

 // Select and Click on the Gender drop-down

MobileElement gender = *driver* .findElement(By. *id* ("loandirect.com.loandirect:id/autoGender"));


int x = gender.getLocation().getX();

int y = gender.getLocation().getY();

System. ***out*** .println(x + " "+ y);

action.tap(PointOption. *point* (x+10, y+150)).perform();

loginTests.log( *Status* . ***PASS*** , "Gender is selected");

//Enter value for the address

*driver* .findElement(By. *id* ("loandirect.com.loandirect:id/etAddress")).sendKeys("Test address");

loginTests.log( *Status* . ***PASS*** , "Address is entered");

// Select and Click on the State drop-down

MobileElement state = *driver* .findElement(By. *id* ("loandirect.com.loandirect:id/autoState"));



int x1 = state.getLocation().getX();

int y1 = state.getLocation().getY();

System. ***out*** .println(x1 + " "+ y1);

action.tap(PointOption. *point* (x1+10, y1+150)).perform();

//action.tap(PointOption.point(x1+10, y1-250)).perform();

loginTests.log( *Status* . ***PASS*** , "State is selected");

MobileElement city = *driver* .findElement(By. *id* ("loandirect.com.loandirect:id/autoCity"));



int x2 = city.getLocation().getX();

int y2 = city.getLocation().getY();

System. ***out*** .println(x2 + " "+ y2);

action.tap(PointOption. *point* (x2+10, y2+150)).perform();

loginTests.log( *Status* . ***PASS*** , "City is selected");

I will really appreciate a quick response from you, thank you.

I don’t suspect it has to do with the typo here ‘abia’ ~ ‘aba’, I’m also experiencing dropdowns being not visible to the inspector or driver actions.

@SCoureFoure, this is not a typo. “Abia” is for the state while “Aba” is for the city. I found a workaround with it. I removed the sendkeys option, i now only use clicks. I click and try to select from down coordinates, if this isn’t available, i select from the upper coordinates, pending where the drop-down shows as it usually differs following the screen resolutions.

1 Like