How to click a link with selenium Webdriver which have same names
driver.findElement(By.linkText("View All")).click();
There are some other Links also having same name like View All
How to click a link with selenium Webdriver which have same names
driver.findElement(By.linkText("View All")).click();
There are some other Links also having same name like View All
You should try to locate unique link with combinations of other attribute of this link such as class name and text by using xpath as below :-
WebDriverWait wait = new WebDriverWait(driver, 10);
WebElement link = wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath(".//a[contains(@class, 'absence-viewall') and contains(text(), 'View All')]")));
link.click();
Or if this link has unique class name, best way to use By.cssSelector() as below :-
WebDriverWait wait = new WebDriverWait(driver, 10);
WebElement link = wait.until(ExpectedConditions.presenceOfElementLocated(By.cssSelector("a.absence-viewall")));
link.click();