Python – Locating Elements in Selenium

With selenium you look at the source code on a webpage to locate elements. Since I am using chromedriver, I locate elements by using chrome >> inspect.

Keywords for locating single elements:

  • find_element_by_id
  • find_element_by_name
  • find_element_by_xpath
  • find_element_by_link_text
  • find_element_by_partial_link_text
  • find_element_by_tag_name
  • find_element_by_class_name
  • find_element_by_css_selector

To find multiple elements and return them in a list:

  • find_elements_by_name
  • find_elements_by_xpath
  • find_elements_by_link_text
  • find_elements_by_partial_link_text
  • find_elements_by_tag_name
  • find_elements_by_class_name
  • find_elements_by_css_selector

 

<< Installation (Selenium and Chrome Driver), Open URL, and Basic Search