'Selenium webdriver is opening the browser, but not opening the given url
This is the screenshot of the error I'm getting.
I have recently taken up the task to learn functional testing and web automation using selnium webdriver with python. When I execute my code, the web browser opens up, but the URL doesn't. I have tried all the suggestions on the internet such as: updating chrome, trying a different IDE, using FireFox. None of these have helped my code carry out what I want.
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
chrome = webdriver.Chrome(executable_path='/Applications/Google Chrome.app/Contents/MacOS/Google Chrome')
chrome.get('https://www.youtube.com/watch?v=oM-yAjUGO-E')
Solution 1:[1]
For anyone encountering this issue, please make sure that you have installed the chromedriver (or whatever driver is available for your browser). For chrome you first need to check your information and find out the version from chrome://version/ then from, https://sites.google.com/a/chromium.org/chromedriver/downloads download the corresponding driver and copy the filepath into the the executable_path section.
Solution 2:[2]
Ensure you have installed chromedriver. The install path would typically be "/usr/local/bin", although whatever the path, that's the one to use as "executable_path"
Also remember to keep Chrome browser and chromedriver versions in sync i.e. if you have Chrome version 81, you should install chromedriver version 81.
Solution 3:[3]
I also have encountered this trouble. Before that, you're supposed to check the status code of your access. If it is 400, this station may set anti reptile which preventing any operation of reptile. I solved that by adding following code:
chrome.execute_cdp_cmd("Page.addScriptToEvaluateOnNewDocument", {
"source": """
Object.defineProperty(navigator, 'webdriver', {
get: () => undefined
})
"""
})
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Splitwire Z |
Solution 2 | 0buz |
Solution 3 | KANG haoyu |