Identified xpath is not working in testng, if the xpath is in first line of the method logout. The same xpath is working without using testng.
I am getting error:
Unable to locate element: {"method":"xpath","selector":"//*[@class='level1 menu static']/li[2]/a"}
Program is below:
@Test
public void login(){
driver1.findElement(By.id("txtUsername")).sendKeys("***");
driver1.findElement(By.id("txtPassword")).sendKeys("***");
driver1.findElement(By.id("btnLogin")).click();
System.out.println("Logged into the application");
}
@Test
public void Logout() throws InterruptedException
{
WebElement l =driver1.findElement(By.xpath("//*[@class='level1 menu static']/li[2]/a"));
act.moveToElement(l).perform();
driver1.findElement(By.xpath("//*[@class='level1 menu static']/li[2]/ul/li[1]/a")).click();
}}
Please help me to identify the problem
ul/li[1]
in the second line ?