Reputation: 33
I am on this website and I am trying to click on Batch search using the selenium webDriver: https://metlin.scripps.edu/landing_page.php?pgcontent=mainPage
The HTML code for the link is:
<a href="landing_page.php?pgcontent=batch_search" style="color:white; font-weight:bold; font-size:13px">Batch Search </a >
My attempted solution is:
driver3.findElement(By.linkText("Batch Search")).click();
However, this doesn't seem to work. Any ideas?
Upvotes: 0
Views: 101
Reputation: 2858
linkText
is an exact match but there's an extra space character after "Batch Search" that's not present in your query so it won't match.
Either fix the search query or use partialLinkText
.
Upvotes: 1
Reputation: 798
I like to use css selectors, which would be:
String selector = "a[href=\"landing_page.php?pgcontent=batch_search\"]";
driver3.findElement(By.cssSelector(selector)).click()
Upvotes: 0