I’m trying to get this element in Chrome Browser for Android //*[@resource-id=“com.android.chrome:id/menu_button_wrapper”]
I’m opening chrome browser and I’m switching the context to NATIVE_APP
Then I try to click on this id, but it always fails.
Then I’ve used driver.getPageSource() to get a list of all elements but the CHROME navigation bar controls aren’t listed in there.
My question is: Is there a way to control “More options” button in Chrome, then the rest like “Bookmark button”?
Thanks!
getDriver().get("https://m.cnn.com");
AppiumDriver<?> driver = (AppiumDriver<?>)((EventFiringWebDriver)getDriver()).getWrappedDriver();
Set<String> contextNames = driver.getContextHandles();
for (String contextName : contextNames){
System.out.println(contextName);
}
driver.context((String) contextNames.toArray()[0]);
System.out.println(driver.getContext().toString());
System.out.println(driver.getPageSource().toString());
try split problem into:
- did element found before tap and has correct location?
- does tap/click happens? enable in developer menu show touches
try also another approach
-> open chrome as native app! instead of as browser (although this will need another approach how to enter URL). for example i am closing all tabs in some case like:
myApp().homePage().waitHelpers.waitElementsLoaded(MobileBy.id("com.android.chrome:id/tab_switcher_button"), 10);
myApp().homePage().tap(getDriver().findElement(MobileBy.id("com.android.chrome:id/tab_switcher_button")));
myApp().homePage().tap(getDriver().findElement(MobileBy.id("com.android.chrome:id/menu_button")));
myApp().homePage().tap(getDriver().findElement(MobileBy.id("com.android.chrome:id/close_all_tabs_menu_id")));
Hi @Aleksei,
in this morning I’ve run my script, one more time, and this time I was able to click on
[@resource-id=“com.android.chrome:id/menu_button_wrapper]
Also
System.out.println(driver.getPageSource().toString());
printed all the elements from NATIVE_APP correctly.
For the past few days, I wasn’t able to make it work but today it did. Due to your reply, my problem got magically solved. 

Thanks and Cheers!