Using Action - Element visible only on mouse over | Selenium Forum
M
Posted on 01/06/2016
Hi Ashish,

I have a scenario where the element is visible only when we mouse over. But when i tried its not clickable and getting error. Pls find my Selenium code
package MouseOverAndClick;

import org.openqa.selenium.By;
import org.testng.annotations.Test;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.interactions.Actions;

public class Example {

@Test

public void MouseOver(){

WebDriver driver=new FirefoxDriver();
driver.manage().window().maximize();
driver.get("http://play.dcsuperherogirls.com");

WebElement ApplePlay=driver.findElement(By.xpath("//*[@id='shg-sect-app']/div/div[2]/div/a[1]/img[2]"));

driver.findElement(By.xpath(".//*[@id='shg-sect-app']/div/div[2]/div/a[1]/img[2]"));

Actions action=new Actions(driver);

action.moveToElement(ApplePlay);

action.click(ApplePlay).perform();

driver.findElement(By.xpath("//*[@id='shg-sect-app']/div/div[2]/div/a[1]/img[2]")).click();

driver.quit();

}
}

Let me know whats wrong?

M
Replied on 02/06/2016

try to use explicit wait.