Ask a Question
Ask Question Login
Corporate Training
  1. Community
  2. QA Testing
  3. Question
QA Testing

How can I resolve this issue - find_elements_by_xpath?

Asked by Ananya Pawar May 6, 2022 943 views 1 answer
Share

About this question

I'm trying to complete the basic python Selenium demo (https://selenium-python.readthedocs.io/getting-started.html) but I'm attempting to do that same procedure on https://www.ncbi.nlm.nih.gov/. However, it seems to be returning an empty list/it can't find the element. I tried to use the class_name but that also gave me an error because the class name has a space in it.

elem = driver.find_elements_by_class_name("typeahead tt-hint")
elem2 = driver.find_elements_by_xpath('//*[@id="main_content"]/section[1]/div/div[2]/div/form/div/span/input[1]')

Also, when doing the tutorial and trying the find_elements command on the different options <input id="id-search-field" name="q" type="search" role="textbox" class="search-field" placeholder="Search" value="" tabindex="1"> I don't quite understand why I seemed to get a type if I used elem = driver.find_element_by_name('q') and a if I used anything else (xpath, id, class_name, etc).

Your answer

1 Answer

More QA Testing discussions

Learn & Explore

Free tutorials and interview questions from industry experts — learn the skill, then get ready to prove it.

Latest QA Testing Blogs

Guides, tips and career advice on QA Testing from JanBask experts.