I recently had an issue where I couldn't change my user-agent in selenium. I got that fixed but then had a chrome driver issue where it required chrome driver version 81. I got that fixed but don't know how to implement the user-agent solution into the chrome driver-specific code.|
Here is the code:
from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager
driver = webdriver.Chrome(ChromeDriverManager().install())
Before, this is how I was changing the user agent:
from selenium import webdriver
# Below is where my code would give me the chrome driver error. So I used the solution above for that.
driver = webdriver.Chrome(executable_path=r'C:\WebDrivers\chromedriver.exe')
driver.execute_cdp_cmd('Network.setUserAgentOverride', {"userAgent": 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.97 Safari/537.36'})