0

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.

Attached 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

1
  • Why you are not using id instead of xpath ? and you can try with xpath .//p[@class='btnRow' and @name='SearchButton'] Commented May 23, 2016 at 3:44

2 Answers 2

1

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']")));
Sign up to request clarification or add additional context in comments.

5 Comments

It is still not searchable Caused by: org.openqa.selenium.NoSuchElementException: Unable to find element with xpath == /p[@class='btnRow' and @name='SearchButton'] If we see the HTML div class is referring IFrameContent. Is there any other way to access the button
The xpath you used according to the error message is not the one from my answer.
Hello Andreas, Same thing Caused by: org.openqa.selenium.NoSuchElementException: Unable to find element with xpath == //p[@class='btnRow']/input[@name='SearchButton']
According to your screenshot of the html code the xpath in the answer is correct. See here: http://xpathfiddle.net/1WWQBN
You can see onmousedown=javascript:Hide() in html code Is that the problem
0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.