What is the python source code for selenium webdriver "find_element_by" [duplicate]

Solution 1:

They are the same, the find_element_by_name call find_element method and pass By.NAME to by arguments. This is the source code:

def find_element_by_name(self, name):
    """
    Finds an element by name.

    :Args:
     - name: The name of the element to find.

    :Returns:
     - WebElement - the element if it was found

    :Raises:
     - NoSuchElementException - if the element wasn't found

    :Usage:
        element = driver.find_element_by_name('foo')
    """
    return self.find_element(by=By.NAME, value=name)

All the find_element_by_* methods are call find_element method with different by arguments. You should go to see selenium webdriver class sourcecode for detail.

This is selenium official api doc. https://www.selenium.dev/selenium/docs/api/py/_modules/selenium/webdriver/remote/webdriver.html#WebDriver