What is the difference between "find_element_by_name(‘name’)" and "find_element(By.NAME, ‘name’)"?

Examples:

# method 1
from selenium import webdriver

PATH = '...'
driver = webdriver.Chrome(PATH)
driver.get('https://google.com')
driver.find_element_by_name('q').send_keys('test')
# method 2
from selenium import webdriver
from selenium.webdriver.common.by import By

PATH = 'c:Program Files (x86)chromedriver.exe'
driver = webdriver.Chrome(PATH)
driver.get('https://google.com')
driver.find_element(By.NAME, 'q').send_keys('test')

Basically, I want to know:

1 – Are there differences between the two? If there are, what are they?

2 – Generally speaking, are there differences between these?

find_element_by_class_name(el): find_element(By.CLASS_NAME, el);

find_element_by_name(el): find_element(By.NAME, el)

3 – Why is a DeprecationWarning shown when the first method is executed?

Source: Python Questions

LEAVE A COMMENT