My code worked perfectly until yesterday when I updated Google Chrome to version 110.0.5481.77. Now it's not working in headless mode:
options.add_argument("--headless")
I even tried adding options.add_argument("--window-size=1280,700") but still not working. Although if I remove the headless option it again works correctly!
Accroding to this answer and Google Chrome release notes you should add the headless mode option like below:
options.add_argument("--headless=new")
and no need to specify the window size
Related
I have a Raspberry PI and Docker containers in it.
One of the containers (Python + Selenium script) is supposed to access Netflix headless and run a movie.
It works fine in my Windows PC using Chrome (non-headless) or Firefox driver (headless and non-headless).
Then, because it works on Firefox driver headless I decided to go with it and try on the PI. Unfortunately it doesn't work and I get the same message as always(I am screenshooting the screen in headless mode):
Firefox driver image:
Chrome driver image:
I've read some possible fixes here and there with the libwidevine.so and so on, no lucy yet!
Anything else that I might have missed here? Somebody else on the same boat?
Thanks a lot!
It works fine in my Windows PC using Chrome (non-headless) or Firefox driver (headless and non-headless).
Then, because it works on Firefox driver headless I decided to go with it and try on the PI. Unfortunately it doesn't work and I get the same message as always
I'm using selenium chromedriver with Google Chrome profiles on Mac OS and Windows. As I understand it, in the usual case the selenium script will not work if another profile in Google Chrome is open. This causes some inconvenience as a regular google chrome user - every time before I run the script I have to close the browser completely.
I would not be comfortable switching to the gecko driver because firefox does not allow me to install the extensions I need. Are there any other options on how to solve this problem?
I am using chromedriver for web scraping by giving the binary path.
driver = webdriver.Chrome(r"C:\Program Files\JetBrains\PyCharm Community Edition 2017.3.3\bin\chromedriver.exe")
driver.get("https://www.example.com/")
This invoke chromedriver in GUI mode. How can I start chrome in headless mode?
Chrome headless is ideally much better than PhantomJS, whose owner decided to stop maintaining the project because the arrival of Chrome headless made it a bit less necessary. That being said, if you have a Chrome version which supports headless, you can do this:
from selenium import webdriver
options = webdriver.ChromeOptions()
options.add_argument('headless')
driver = webdriver.Chrome(chrome_options=options)
As you see, headless is an argument, so if for some reason you want to run the same code but you need to see the GUI, remove that argument.
By the way, if you ever wanted to give the binary location, a nice way to do it is also with options:
options.binary_location = 'path to your chrome binary'
But if your installed version is recent enough, there should be no reason to do so.
I have a selenium script that scraps a website. Each time selenium driver opens a new link, the Chrome driver launches a new instance of Google Chrome and provides input to a search query using send_keys.
And, the newly opened chrome tab appears in front of any other windows (i.e Nautilus or say Firefox) open on my Ubuntu 16.04 LTS
I tried running the script in different workspace but still it automatically switches workspace to show the newly opened chrome tab (by the script).
Also, Even if I make the currently visible window Always on top by right clicking on the Title bar. It still loses focus as soon as the chrome browser opens the link (On the other workspaces)
Is there any way to prevent chrome driver's newly opened tab from getting focus?
I couldn't find a solution for chromedriver so, I just switched back to phantomjs again.
Download link of PhantomJS: http://phantomjs.org/download.html
Start a headless browser can be an option
final var options = new ChromeOptions();
options.setAcceptInsecureCerts(true);
options.addArguments("--headless");
final var driver = new ChromeDriver(options);
I am running selenium via python 3 with the chromedriver browser on windows 10.
The program is very active and should run constantly. Means: lots of logging going on.
Problem: the crhomedriver logs get way too long after a few hours, and windows tends to crash.
Everything is working fine, the logs are just minor issues about which I do not really care.
Question:
How may I disable the chromedriver logs?
Notes:
I did my research and did not find any working solution yet.
I am forced to use chromedriver, hence no headless browser like phantomJS is a valid alternative.
Try this, not sure it will work. Pass the options to your chromedriver
from selenium.webdriver.chrome.options import Options
options = Options()
options.add_argument('--disable-logging')