Reputation: 459
I am not able to click on following link using selenium webdriver
:
<center>
<a class="xyz" style="" href="/Folder">My Folders</a>
<span></span>
</center>
I am using the code:
abhiFX.findElement(By.partialLinkText("My Folders")).click();
Upvotes: 1
Views: 1989
Reputation: 2746
Try to use xpath instead:
public void clickElement() {
try {
WebElement element = abhiFX.findElement(
By.xpath("//a[contains(text(),'My Folders')]"));
element.click();
} catch (InvalidSelectorException e) {
throw new AssertionError("[FAIL] Click Element: Xpath is invalid.");
} catch (NoSuchElementException e) {
throw new AssertionError(
"[FAIL] Click Element: Unable to locate element");
}
}
Upvotes: 2
Reputation: 8624
I see these potential problems:
abhiFX
initialized properly? Does .click()
on other elements work well?Upvotes: 3