RE: How to code mouse hover with Selenium Webdriver

I was trying to code for mousehover
and i actually followed someone’s code and to me
its not working

RE: How to code mouse hover with Selenium Webdriver

also the I can’t really find the element id for

RE: How to code mouse hover with Selenium Webdriver


for this part
there is no id specified

Add Comment
3 Answers

Hi
Let me show you the code for mouse hover

//navigate index page
driver.get(“http://www.flipkart.com/”);

//hover electronics tab
WebElement moveonmenu=driver.findElement(By.xpath(“.//*[@id=’fk-mainhead-id’]/div[2]/div/div/ul/li[1]/a/span”));
Actions actions=new Actions(driver);
actions.moveToElement(moveonmenu).perform();
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
e.printStackTrace();
}
//hover and click Mi from Mobiles
WebElement mi=driver.findElement(By.xpath(“.//*[@id=’menu-electronics-tab-0-content’]/ul[1]/li[5]/a”));
actions.moveToElement(mi).click().perform();

If you have any question just ask
Janani

Train Answered on July 14, 2015.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.