Selenium Chromedriver not navigating to url - python

What I have now is:
chrome_options = Options()
chrome_options.add_extension(r"C:\Users\x\OneDrive\Desktop\pp\crxSolver.crx")
driver = webdriver.Chrome(r'C:\Users\x\OneDrive\Desktop\chromedriver.exe', options=chrome_options)
driver.get("https://www.google.com")
I am able to open the webdriver and I see the extension that I added on the right top corner in google Chrome, however the driver doesn't go to google.com. I have searched a lot and I can't find the solution to it.
Here is the link to the extension:
https://chrome.google.com/webstore/detail/buster-captcha-solver-for/mpbjkejclgfgadiemmefgebjfooflfhl/related
Watch the video here for complete information

Try upgrading to chrome 75, your issue should resolve. Seems to be some issue with the machine and your browser compatibility.

Related

Why driver.get doesn't work in Python Selenium when using Profile

What I need
I need to run Selenium with Chrome Profile
Here is my code:
from selenium import webdriver
import time
options = webdriver.ChromeOptions()
options.add_argument("--user-data-dir=/home/atom/.config/google-chrome") #Path to your chrome profile
options.add_argument('--profile-directory=Profile 1')
driver = webdriver.Chrome(options=options)
driver.get('https://youtube.com')
time.sleep(5)
Problem
The code opens Google Chrome instead of Chromedriver. Profile is loaded. But driver.get doesn't work
Question
How can I use Selenium with Chrome profile?
What chromedriver does is briefly described here. When you call get on the webdriver, you are asking for the site to be opened on the chrome browser. If you want to use brave browser or another browser implementation using the chromium engine, you may specify the location of the browser's binary using:
ChromeOptions options = new ChromeOptions();
options.setBinary("/path/to/other/chrome/binary");
You may load a specific profile by using:
ChromeOptions options = new ChromeOptions();
options.addArguments("user-data-dir=/path/to/your/custom/profile");
Specifying no profile (not including this option should load the default profile).
A complete list of supported options may be found here.

Python: Selenium ChromeDriver opens blank page ('data:,')

I'm trying to use Selenium (3.141.0) with ChromeDriver (87.0.4280) to access a page. When accessed manually, it brings me to a policy page (different URL) where you have to hit 'Ok' before continuing to the site. Edit This is using Win 10 and I have the folder with the chromedriver on PATH.
When using the following code, I'm able to get to the policy page with the ("--headless") option but without it I get a blank page with 'data:,' in the URL and nothing else loads. I've tried accessing straight from the policy page and the site URL but they both get stuck when the webdriver is created. Am I missing something? I'm open to any suggestions, thanks!
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
chrome_options = Options()
chrome_options.add_argument("--headless")
driver_path = 'D:\....\chromedriver.exe'
driver = webdriver.Chrome(executable_path= driver_path, options= chrome_options)
driver.get(...) # left out the url
This is the output page I get without using ("--headless")
Funny enough, I realized it was because my Chrome Developer tools had become disabled. Not sure how but when I re-enabled them, it worked perfectly again. Weird.

Chrome can't open a profile using selenium python

When I run this code
import time
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
chrome_options = Options()
chrome_options.add_argument("--disable-infobars")
chrome_options.add_argument("--start-maximized")
chrome_options.add_argument(r"user-data-dir=C:\Users\micha\AppData\Local\Google\Chrome\User Data\Profile 1")
driver = webdriver.Chrome(executable_path=r'C:\Users\micha\Desktop\Visual_projects\chromedriver.exe', chrome_options = chrome_options)
driver.get("https://store.steampowered.com/")
This error pops up : [12216:1336:0411/232857.718:ERROR:browser_switcher_service.cc(238)] XXX Init()
Could someone please help me. I don't know what is wrong but the programm won't open the new profile I created. Any help would be appreciated.
I searched everywhere how to fix this error but I think the guides are outdated
Check your Chrome browser version and your Chrome webdriver version. If both are same then issue should be solved.
One thing to check would be, if your ChromeDriver-Executable matches the version of the Chrome you have installed (under Help/About Google Chrome in your browser). There are versions 79, 80 and 81 mostly in use. You can find the current ChromeDrivers for all three versions here: https://chromedriver.chromium.org/downloads.

Headless Selenium suddenly stopped working

I have been using Selenium and python to web scrape for a couple of weeks now. It has been working fairly good. Been running on a macOS and windows 7. However all the sudden the headless web driver has stopped working. I have been using chromedriver with the following settings:
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
options = Options()
options.add_argument("--headless")
options.add_argument('--no-sandbox')
options.add_argument('--disable-gpu')
chrome_options.add_argument("--window-size=1920x1080")
driver = webdriver.Chrome(chrome_options=options)
driver.get('url')
Initially I had to add the window, gpu and sandbox arguments to get it work and it did work up until now. However, when running the script now it gets stuck at driver.get('url'). It doesn't produce an error or anything just seems to run indefinitely. When I run without headless and simply run:
from selenium import webdriver
driver = webdriver.Chrome()
driver.get('url')
it works exactly as intended. This problem is also isolated to my windows machine. Where do I start?
Solved
For some reason the proxy setting was slowing it down. Therefore it got solved by adding:
options.add_argument(f'--proxy-server={None}')
I had exactly the same problem. It appeared randomly after the script has run fine for weeks. OP has led me to the right direction, but his solution doesnt worked for me. I had to add:
chrome_options.add_argument("--no-proxy-server")
chrome_options.add_argument("--proxy-server='direct://'");
chrome_options.add_argument("--proxy-bypass-list=*");
My complete code:
chrome_options = Options()
chrome_options.add_argument("--headless")
chrome_options.add_argument("--start-maximized")
chrome_options.add_argument("--start-fullscreen")
chrome_options.add_argument("--no-proxy-server")
chrome_options.add_argument("--proxy-server='direct://'");
chrome_options.add_argument("--proxy-bypass-list=*");
chrome_options.binary_location = "C:\Program Files (x86)\Google\Chrome Dev\\Application\chrome.exe"
browser = webdriver.Chrome(options=chrome_options)
browser.set_window_size(2000, 1080)
please see also:
Headless chrome driver too slow
and:
Chrome webdriver produces timeout in selenium

Python selenium how to load the browser's data(cookies or bookmarks)

When using selenium to open a web page, it automatically deletes all cookies u had saved in browser which is inconvenient.
Find solution in this page java solution
but don't know how to solve the problem using Python.
Point the browser to a profile file (that's what the java example in the given link is doing)
from selenium import webdriver
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument('user-data-dir=<path to chrome profile>')
browser = webdriver.Chrome(chrome_options=chrome_options)
On Linux the <path to chrome profile> is /home/<user>/.config/google-chrome.

Categories

Resources