I am executing a testNG class giving an extension to other class. While executing,it opens a two diff tabs to execute the operation and unable to locate the similar xpath which i used in different normal class,but now enter code hereit is showing the error: org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element: {"method":"xpath","selector":"/html/body/div[1]/div[1]/div[2]/ul[1]/li[1]/a"}
have tried with absolute and relative Xpath also,but the error is same
/
/first class (base class)
public class mlogin {
public WebDriver driver;
@Test
public void login() throws InterruptedException {
driver.findElement(By.id("UserName")).sendKeys("Jose");
driver.findElement(By.id("Password")).sendKeys("mick@1234");
Thread.sleep(2000);
driver.findElement(By.xpath("/html/body/div[2]/div/div/div/form/div/div/div/div/div[2]/div/div[2]/div[3]/div/input")).click();
}
@BeforeMethod
public void beforeMethod() {
System.setProperty("webdriver.chrome.driver", "E:\\jarfiles\\chromedriver.exe");
driver = new ChromeDriver();
driver.get(base URL);
driver.manage().window().maximize();
}}
//second class
public class branch_master extends mlogin{
@Test
public void b_master() throws InterruptedException {
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver.findElement(By.xpath("/html/body/div[1]/div[1]/div[2]/ul[1]/li[1]/a")).click();
Thread.sleep(2000);
}}