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;
//@Test
public void FreeTrail() throws Exception {
driver.findElement(By.xpath("//button[@type='submit']")).click();
driver.findElement(By.id("name")).sendKeys("subhankar jena");
Thread.sleep(5000);
// driver.findElement(By.id("companyname")).sendKeys("itworld");
driver.findElement(By.name("phone")).sendKeys("7684914257");
driver.findElement(By.id("email")).sendKeys("xyz143@gmail.com");
driver.findElement(By.id("inputPassword")).sendKeys("Bbsr@2021");
// driver.findElement(By.id("subdomain")).sendKeys("iddomain");
driver.findElement(By.id("terms_check")).click();
driver.findElement(By.id("nextbtn")).click();
}
@Test
public void f() {
}
@BeforeTest
public void openURL() throws Exception{
System.setProperty("webdriver.chrome.driver", "F:\Library\chromedriver.exe");
driver = new ChromeDriver();
// Opening the Browser and Entering the URL
driver.get("https://www.muvi.com/");
// Maximize the Browser window
driver.manage().window().maximize();
//driver.manage().timeouts().implicitlyWait(2, TimeUnit.SECONDS);
Thread.sleep(1000);
driver.findElement(By.id("load_login")).click();
driver.findElement(By.id("LoginForm_email")).sendKeys("subhankarjena14@gmail.com");
driver.findElement(By.id("LoginForm_password")).sendKeys("Gulu@123");
driver.findElement(By.id("btn-login")).click();
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();
}
}
Source: Read More