NewTester
NewTester

Reputation: 3

How to keep a collapsing menu item in open condition?

In my mobileweb testing using Selenium and Appium code, when a 'Shop' menu is clicked, 'Conduit' menu is opened and by clicking this item 'Steel Conduit' sub menu has to be opened and this has to be clicked.

On Android every thing is fine. But on iOS device, after 'Shop' is clicked and 'Conduit' seen, before it is clicked to see 'Steel Conduit', the menu is collapsing in to 'Shop' again. I can't figure out the reason why !!

How to keep the 'Conduit' menu item in open condition so that it can be clicked, and NOT collapse in to the parent 'Shop' ? Any JavaScript based help perhaps ?

I am using JDK 21, Selenium 4.x, Appium 2.x, Java-Client 9.x

Here is my code:

WebElement categoryElm = waitingDriver.until(ExpectedConditions.elementToBeClickable(By.xpath(String.format("//a[contains(text(),'%s')]",category)))); // Conduit menu web element
doWait(3000);// sleep
System.out.println("category Text="+categoryElm.getText());// prints 'Conduit'
elementActionsTap(categoryElm);// clicking using W3C Actions class


WebElement sub_categoryElm = waitingDriver.until(ExpectedConditions.elementToBeClickable(By.xpath(String.format("//a[normalize-space()='%s']",sub_category))));
System.out.println("sub_categoryElm Text="+sub_categoryElm.getText());// should print 'Steel Conduit'
elementJSClick(sub_categoryElm);//clicking using JavaScriptExecutor

Upvotes: 0

Views: 19

Answers (0)

Related Questions