Reputation: 1
How to click on Apply Now button
Apply Now
I have try with bunt did not work
WebElement Apply =driver.findElementByXPath("/a[text()[contains(.,' Apply Now ')]]");
Upvotes: 0
Views: 67
Reputation: 168197
The correct syntax for partial match using XPath contains() function would be:
WebElement Apply =driver.findElementByXPath("//a[contains(text(),'Apply now')]");
You might find ByPartialLinkText locator easier to use
WebElement Apply = driver.findElement(By.partialLinkText("Apply Now"));
You might also want to wrap this into WebDriverWait:
WebElement Apply = new WebDriverWait(driver, 10)
.until(ExpectedConditions
.presenceOfElementLocated(By
.partialLinkText("Apply Now")));
And finally according to Java naming conventions you might want to make this Apply
to start with the lowercase a
Upvotes: 0
Reputation: 5718
I think that your xpath query was not ok. I would write it like this
WebElement applyButton = driver.findElementByXPath("//a[text() = 'Apply Now']");
applyButton.click()
Upvotes: 2