Menu(Hamburger icon) items selection in Mobile app

Hi

In my mobile app have Menu icon tap on that list of items is available.
Html code is
a href="#" class=“menu jqm-navmenu-link ui-link”> Menu /a>

So in selenium web driver i written
driver.findElement(By.name(“Menu”)).click();

In Menu Home, Settings etc… items are available
Ex: Home
div class=“ui-btn-inner ui-li”>
div class=“ui-btn-text”
a href="#" class=“ui-link-inherit”>
img src=“images/home.png” alt="" class=“ui-li-thumb”>Home /a>
div class=“line”>/div>
/div> /div>

Same like that i written
driver.findElement(By.name(“Home”)).click();

but it showing bellow error
org.openqa.selenium.NoSuchElementException: An element could not be located on the page using the given search parameters. (WARNING: The server did not provide any stacktrace information)

please help…

Thank’Q
jyothi

Hi jo

you can find xpath in appium for ios in that you inspect the element

Hi,

I tried name, xpath, css for all it showing NoSuchElementException only.
This is Android app(Hybrid app and Elements are coming dynamically)

HI Guys,
Please help me…

Hi jo,
I am facing the same issue.
can u please update it if u find any solution for that.

You can click Hamburger icon using it content description. Like this:

        driver.findElementByAccessibilityId("Open navigation drawer").click();

Hi all,

Using:
io.appium java client 6.1.0
selenium-java 3.14.0
guava 26.0-jre
UIAutomator2
on Oreo and Marshmallow.

I too am working on an app having hamburger menu on a landing page.
Sometimes the element in Hamburger Menu does not get identified. On investigating further, I found out that the xml skeleton of the app UI does not get updated with the hamburger menu elements after the hamburger menu button is clicked in the landing page of the app.

How I identified this ?:

  1. During script run - tried
    xmlFormat = driver.getPageSource();
    if(xmlFormat.contains(“Logout”)){
    //do something
    }
  2. Using UIAutomatorViewer.bat
  3. Using Appium 1.6.2.907

Same is the behavior even after waiting for 1 to 2 minutes and retrying.

Hi all,

Using:
io.appium java client 6.1.0
selenium-java 3.14.0
guava 26.0-jre
UIAutomator2
on Oreo and Marshmallow.

I have tried to do some workaround for the same.

//Get X Y Coordinates
public Map<String, ArrayList> Get_XY(MobileElement element, String elementName) throws InterruptedException{

	p = new Point(0, 0);
	
	try{
		p = element.getLocation();
		x = 80 + p.getX();
		hmItemsCoord.put(elementName, new ArrayList<Integer>()); //new LinkedList<String>()
		hmItemsCoord.get(elementName).add(x);
		hmItemsCoord.get(elementName).add(p.getY());
		elementGap = p.getY()-y;
		hmItemsCoord.get(elementName).add(elementGap);
		y = p.getY();
		LOGGER.info("TRY_hmItemsCoord.toString(): "+hmItemsCoord.toString());
		LOGGER.info("Element: "+elementName+" coordinates: ["+x+", "+y+"]. ");
	}catch(NoSuchElementException nsee){
		hmItemsCoord.put(elementName, new ArrayList<Integer>()); //new LinkedList<String>()
		hmItemsCoord.get(elementName).add(x);
		hmItemsCoord.get(elementName).add(y+elementGap);
		hmItemsCoord.get(elementName).add(elementGap);
		LOGGER.info("NSEE_hmItemsCoord.toString(): "+hmItemsCoord.toString());
		temp = y + elementGap;
		a[1] = temp;
		y = temp;
		LOGGER.info("Element: "+elementName+" not found in XML DOM. Getting approximate coordinates: ["+x+", "+y+"]. ");
	}finally{
		LOGGER.info("Control is in 'Finally' Block. ");
	}
	return hmItemsCoord;

}

You can use this method to get all the required coordinates of the HM links along with the elementGap.

Next, you need to use the below method to tap on the relevant HM links:

//Tap on X Y Coordinates
public Map<String, ArrayList> Tap_XY(MobileElement element, String elementName) throws InterruptedException{

	x = hmItemsCoord.get(elementName).get(0)+rnd.nextInt(5);
	y = hmItemsCoord.get(elementName).get(1)+rnd.nextInt(50);
	new TouchAction(driver).tap(PointOption.point(x, y)).perform();
	LOGGER.info("Clicked on ["+x+", "+y+"]. ");
	TimeUnit.SECONDS.sleep(2);
	return hmItemsCoord;

}