I want to click and select the options in location autocomplete dropdown but can’t find its id by using uiautomator viewer.
the only approach you can use is tap with offset. If element not visible hardly you can do more.
Can you attach the UIDump??
How to get the UIDump?
Thanks and Regards
Shashi Kumar Raja
open Uiautomator viewer( which would be at Android/sdk/tools/uiautomatorviewer
click on 2nd icon and then 4th icon.
@Aleksei can you provide me the JavaScript code to tap on the screen.Also, how will I know the exact coordinates.
what coordinates? of element?
as i remember something like …
center:
((MobileElement) el).getCenter().getX();
((MobileElement) el).getCenter().getY();
left upper corner:
el.getLocation().getX();
el.getLocation().getY();
Attaching the uidump.
So far I have tried using
return driver.elementById(this.enterLocationTextBox).getLocation()
.then(function (location) {
el = driver.elementById(this.mobileNumberSelectedText);
var tapOpts = {
x: location.x, // in pixels from left
y: location.y + 50, // in pixels from top
element: el.value // the id of the element we want to tap
};
return driver.execute("mobile: tap", [tapOpts])
});
but I am getting error:
Error: [execute("mobile: tap",[{"x":210,"y":816}])] Error response status: 13, , UnknownError - An unknown server-side error occurred while processing the command. Selenium error: Method has not yet been implemented
Was able to make it work using:
var TouchAction = wd.TouchAction;
exports.selectLocationFromAutoComplete = function (driver, callback) {
return driver.elementById(this.enterLocationTextBox).getLocation()
.then(function (location) {
el = driver.elementById(this.enterLocationTextBox);
var tapOpts = {
x: location.x, // in pixels from left
y: location.y - 100 // in pixels from top
};
//steps to perform tap action on the screen
var action = new TouchAction(driver);
action.tap(el.value, tapOpts);
action.perform().then(function(err, res){
return callback(err, res);
})
})
};