I'm getting
start.py:146: DeprecationWarning: firefox_profile has been deprecated, please use an Options object
start.py:163: DeprecationWarning: firefox_profile has been deprecated, please pass in an Options object
selenium\webdriver\remote\webdriver.py:483: UserWarning: find_element_by_* commands are deprecated. Please use find_element() instead
selenium\webdriver\remote\webdriver.py:723: UserWarning: find_element_by_* commands are deprecated. Please use find_element() instead
when I compile my .py and I want to find a way to suppress this. I've looked at other threads but all of them seemed to have not worked.
Edit more code:
profile = webdriver.FirefoxProfile(profile)
profile.set_preference("dom.webdriver.enabled", False)
profile.set_preference('useAutomationExtension', False)
profile.update_preferences()
options = FirefoxOptions()
options.add_argument('--no-sandbox')
options.add_argument('--disable-dev-shm-usage')
options.add_argument('--user-agent=Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.5 Safari/605.1.15')
options.add_argument('--disable-plugins-discovery')
options.add_argument('referer=https://www.youtube.com/')
options.add_argument('--disable-extensions')
options.add_argument('--profile-directory=Default')
options.add_argument('--disable-blink-featuresi=AutomationControlled')
options.add_argument('--disable-blink-features')
driver = webdriver.Firefox(firefox_profile=profile, options=options)
for fixing error UserWarning: find_element_by_* commands are deprecated. Please use find_element() instead
you can use the below method
from selenium.webdriver.common.by import By
then use like this
driver.find_element(By.XPATH, '//input[@id='search']')
for error Firefox DeprecationWarning:
profile = webdriver.FirefoxProfile(profile)
profile.set_preference("dom.webdriver.enabled", False)
profile.set_preference('useAutomationExtension', False)
profile.update_preferences()
gecko_path = "path_to_geckodriver\\geckodriver.exe"
path = "path_to_firefoxs\\Mozilla Firefox\\firefox.exe"
binary = FirefoxBinary(path)
options = FirefoxOptions()
options.add_argument('--no-sandbox')
options.add_argument('--disable-dev-shm-usage')
options.add_argument('--user-agent=Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.5 Safari/605.1.15')
options.add_argument('--disable-plugins-discovery')
options.add_argument('referer=https://www.youtube.com/')
options.add_argument('--disable-extensions')
options.add_argument('--profile-directory=Default')
options.add_argument('--disable-blink-featuresi=AutomationControlled')
options.add_argument('--disable-blink-features')
driver = webdriver.Firefox(firefox_profile=profile, options=options, executable_path=gecko_path)
in addition, you can add your firefox profile directly like this
profile = webdriver.FirefoxProfile('C:/Users/x/AppData/Roaming/Mozilla/Firefox/Profiles/some-long-string')
profile.set_preference("dom.webdriver.enabled", False)
profile.set_preference('useAutomationExtension', False)
profile.update_preferences()
gecko_path = "path_to_geckodriver\\geckodriver.exe"
path = "path_to_firefoxs\\Mozilla Firefox\\firefox.exe"
binary = FirefoxBinary(path)
options = FirefoxOptions()
options.add_argument('--no-sandbox')
options.add_argument('--disable-dev-shm-usage')
options.add_argument('--user-agent=Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.5 Safari/605.1.15')
options.add_argument('--disable-plugins-discovery')
options.add_argument('referer=https://www.youtube.com/')
options.add_argument('--disable-extensions')
options.add_argument('--profile-directory=Default')
options.add_argument('--disable-blink-featuresi=AutomationControlled')
options.add_argument('--disable-blink-features')
driver = webdriver.Firefox(firefox_profile=profile, options=options, executable_path=gecko_path)