Reputation: 429
I am finding difficulty in identifying search button in selenium. The issue is the same when i am using xpath. My action would be to click on SearchButton Here is the snippet of HTML code.
I am trying to identify element using below xpath
WebElement search=new WebDriverWait(driver,15)
.until(ExpectedConditions.presenceOfElementLocated(
By.xpath("//p[@class='btnRow']/name[@name='SearchButton']")));
Kindly help me in this regard as i am not able to proceed
Upvotes: 0
Views: 1376
Reputation: 2305
Class is usually not unique. You must understand what are unique properties in the html code that you can use to select the element. ID is usually unique, therefore people commonly search by id.
Please give this a try:
by.Xpath("//div[@id='maincontent']//input[@id='SearchButton']")
In case, if you still can't find the element, try separating the xpath and debug if you get the element that you wanted. Including the Xpath from @Andreas Scheibleger which looks fine to me too.
Upvotes: 0
Reputation: 297
Your xpath searches for an element name
but it is an input
. Try the following instead:
WebElement search=new WebDriverWait(driver,15).until(ExpectedConditions.presenceOfElementLocated(By.xpath("//p[@class='btnRow']/input[@name='SearchButton']")));
Upvotes: 1