Reputation: 1
I am having a problem while trying to click on a hyperlink using Selenium Web-driver. I tried using Selector as well as xPath and nothing seem to work. All I am trying to do is click on the hyperlink
<a href="JavaScript:void(0)" id="id_34" alt="Title: Pending Changes-type: Web Intelligence-owner: Administrator-last viewed time: Nov 21, 2018 11:03 AM">Pending Changes</a>
Upvotes: 0
Views: 91
Reputation: 193108
The element is JavaScript enabled element so you need to induce WebDriverWait for the element to be clickable and you can use either of the following solutions:
Java Solution:
linkText
:
new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.linkText("Pending Changes"))).click();
cssSelector
:
new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.cssSelector("a[id^=id_][alt^='Title']"))).click();
xpath
:
new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.xpath("//a[starts-with(@id,'id_') and starts-with(@alt,'Title')]"))).click();
Upvotes: 1
Reputation: 799
Java:
driver.findElement(By.linkText("Pending Changes")).click();
or
driver.findElement(By.id("d_34")).click();
Upvotes: 0