0

I have a menu dropdown like this. Using selenium i need to move the menu but can retreive the element by ID, xPath etc. Cau you help plz

<td id="140#200" nowrap="" class="k140" onclick="menuclic(&quot;140&quot;,this,&quot;#200&quot;)" onmousedown="menudown(&quot;140&quot;,this)" onmouseup="menuup(&quot;140&quot;,this)" onmousemove="menumousemove(&quot;140&quot;,this,'#200')" onmouseover="menuover(&quot;140&quot;,this)" onmouseout="menuout(&quot;140&quot;,this)">&nbsp;Suivi&nbsp;des&nbsp;réclamations&nbsp;</td>
Yanick_T
  • 1
  • 1

1 Answers1

0

You can deal with that problem like this. Of course, it is just an example.

//Instantiate Action Class        
Actions actions = new Actions(driver);
//Retrieve WebElement 'Music' to perform mouse hover 
WebElement menuOption = driver.findElement(By.xpath(".//div[contains(text(),'Music')]"));
//Mouse hover menuOption 'Music'
actions.moveToElement(menuOption).perform();
System.out.println("Done Mouse hover on 'Music' from Menu");

//Now Select 'Rock' from sub menu which has got displayed on mouse hover of 'Music'
WebElement subMenuOption = driver.findElement(By.xpath(".//div[contains(text(),'Rock')]")); 
//Mouse hover menuOption 'Rock'
actions.moveToElement(subMenuOption).perform();
System.out.println("Done Mouse hover on 'Rock' from Menu");

The resulting image is :

here.

NickCoder
  • 1,504
  • 2
  • 23
  • 35
Metalgear
  • 3,391
  • 1
  • 7
  • 16
  • The class seems to be dynamic on the page and there is only the ID which is static but not unique. Any advise? – Yanick_T Feb 26 '20 at 10:10