How do I check a link is existing in a web page or not using selenium java

Viewed 29

for(itemNum=0;itemNum<=11;itemNum++){ driver.get("http://automationpractice.com/index.php"); WebElement ele =driver.findElement(By.xpath("//header/div[3]/div1/div1/div[6]/ul1/li1/a1")); Actions action = new Actions(driver); action.moveToElement(ele).perform(); WebElement checkUrl = driver.findElement(By.linkText("http://automationpractice.com/index.php?id_category="+itemNum+"&controller=category")); if(checkUrl!=null) { System.out.println(checkUrl+" Existing"); }else{ System.out.println(checkUrl+" Not Existing"); } }

Error : no such element: Unable to locate element: {"method":"link text","selector":"http://automationpractice.com/index.php?id_category=0&controller=category"}

Here Is My code

0 Answers
Related