Skip to content Skip to sidebar Skip to footer

What Is The Difference In "find_element_by_xpath" And "driver.find_elements(by.xpath)"

I have been using selenium for a while with these two methods interchangeably. elem = driver.find_element_by_xpath('some_xpath') elem = driver.find_element(By.XPATH,'some_xpath')

Solution 1:

find_element_by_xpath('xpath') calls find_element(By.XPATH,'xpath'), so actually there is no real difference.

From github

deffind_element_by_xpath(self, xpath):
    returnself.find_element(by=By.XPATH, value=xpath)

If you look at find_element() comment though you will see it recommends to use find_element_by_xpath

Find an element given a By strategy and locator. Prefer the find_element_by_* methods when possible.

Post a Comment for "What Is The Difference In "find_element_by_xpath" And "driver.find_elements(by.xpath)""