I can't find my XPath so that I can't run the code. Can anyone solve this issue?

I have to do mouse hover manage content then click on content Library:

package TestNG;

import org.testng.annotations.Test;

import java.util.concurrent.TimeUnit;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.testng.annotations.BeforeTest;

public class MuviOTT {

    public WebDriver driver;
    static WebElement element;
    public void FreeTrail() throws Exception {
        driver.findElement(By.id("name")).sendKeys("subhankar jena");
        // driver.findElement(By.id("companyname")).sendKeys("itworld");
        driver.findElement(By.id("email")).sendKeys("[email protected]");
        // driver.findElement(By.id("subdomain")).sendKeys("iddomain");
    public void f() {

    public void openURL() throws Exception{
        System.setProperty("webdriver.chrome.driver", "F:\\Library\\chromedriver.exe");
        driver = new ChromeDriver();
        // Opening the Browser and Entering the URL
        // Maximize the Browser window
        //driver.manage().timeouts().implicitlyWait(2, TimeUnit.SECONDS);
        driver.findElement(By.id("LoginForm_email")).sendKeys("[email protected]");

        Actions action = new Actions(driver);
        // Mouse Hover actions on an element using Action Class:
        action.moveToElement(driver.findElement(By.xpath("//em[@class='icon-film left-icon']"))).perform();
        WebDriverWait wait = new WebDriverWait(driver, 10);
        element= wait.until(ExpectedConditions.elementToBeClickable(By.id("//a[contains(.,'Content Library')]")));
        driver.findElement(By.xpath("//a[contains(text(),'Content Library')]")).click();


1 Answer 1


It might be the case that the exact locator is not found. As when you mouse over > then the element appears, and it would be disappearing if you are moving out. Pausing or debugging will help to find out the locator.

You can try this:

  1. Hover over the element by using Action class:

    Actions action = new Actions(driver); action.moveToElement(we).build().perform();

  2. Use the Debugger in the Network of your browser(after clicking F12)

  3. Move to the element mentioned in the step one and right click on the 3 dots(see picture below) and click > break on subtree modification

  4. This will pause you execution whenever there is a change in the DOM i.e in case of Mouse over.

enter image description here

  1. Then you can use the arrow keys to navigate to the hidden elements of the DOM

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.