Chrome canary headless mode does not work on windows10 - python-3.x

Google Chrome Canary does not work with headless on Windows.
Chrome headless does not work on windows.
The Error happens like following when I tried to execute below code.
But it works on non-headless mode.
I know Canary is unstable but I want to using it to learning about web advanced spec.
This error caused by bug in canary?
Or caused by my code?
code:
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
op = Options()
op.binary_location = "C:\\Users\\username\\AppData\\Local\\Google\\Chrome SxS\\Application\\chrome.exe"
op.add_argument("--headless")
op.add_argument("--disable-gpu")
driver = webdriver.Chrome("chromedriver.exe", chrome_options=op)
driver.get("http://www.google.com")
Error:
[1205/232511.644:ERROR:gpu_process_transport_factory.cc(1017)] Lost UI shared context.
[1205/232511.644:ERROR:instance.cc(49)] Unable to locate service manifest for metrics
[1205/232511.644:ERROR:service_manager.cc(890)] Failed to resolve service name: metrics
DevTools listening on ws://127.0.0.1:12022/devtools/browser/3d7c8ff8-625a-4326-b968-bbff
[1205/232511.714:ERROR:instance.cc(49)] Unable to locate service manifest for metrics
[1205/232511.714:ERROR:service_manager.cc(890)] Failed to resolve service name: metrics
[1205/232511.714:ERROR:instance.cc(49)] Unable to locate service manifest for metrics
[1205/232511.714:ERROR:service_manager.cc(890)] Failed to resolve service name: metrics
[1205/232513.037:ERROR:instance.cc(49)] Unable to locate service manifest for metrics
[1205/232513.037:ERROR:service_manager.cc(890)] Failed to resolve service name: metrics
OS: windows 10 Home 1709
Chrome: 65.0.3285.0 (Official Build) canary 64bit
ChromeDriver: 2.33.506120

As your error logs reports as follows :
[1205/232511.644:ERROR:gpu_process_transport_factory.cc(1017)] Lost UI shared context.
[1205/232511.644:ERROR:instance.cc(49)] Unable to locate service manifest for metrics
[1205/232511.644:ERROR:service_manager.cc(890)] Failed to resolve service name: metrics
I will suggest the following steps :
Uninstall Google Chrome Canary from your system through Revo Uninstaller
Use CCleaner tool to wipe off all the OS chores.
Install fresh Google Chrome Canary
Use the following code block :
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
op = Options()
op.binary_location = "C:\\Users\\username\\AppData\\Local\\Google\\Chrome SxS\\Application\\chrome.exe"
op.add_argument("--headless")
op.add_argument("--disable-gpu")
driver = webdriver.Chrome(chrome_options=op, executable_path=r'C:\path\to\chromedriver.exe')
driver.get("http://google.com/")
You can find about multiple ways to work with multiple Chrome Browser Binaries in Set chrome browser binary to chrome webdriver in Python discussion.

Related

Open a browser tab with Selenium on Databricks

I have installed Selenium in Databricks and able to import selenium web-driver.
I am looking if we can open a separate browser window. I am able to hit a URL with headless option but if I set the headless option to False, getting this error:
WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally.
This works fine on my local machine setting headless to False, but I am looking for something similar on databricks.
Any help would be really appreciated.
Here is the code that I tried:
from selenium import webdriver
chrome_options = webdriver.ChromeOptions()
#chrome_options.add_argument("--headless")
chrome_options.add_argument('--no-sandbox')
driver = webdriver.Chrome('path to chrome diver' ,
options=chrome_options)
driver.get('https://www.google.com')
print(driver.title)

Can't run selenium firefox browser

I have a problem with run selenium firefox browser.
It started after last update OS.
I use ubuntu 22.04
When I try to run test i catch this exception
selenium.common.exceptions.WebDriverException: Message: Process unexpectedly closed with status 127
I try google it, but didn't find information.
Also I have the such information in firefox log file/snap/firefox/current/firefox.launcher: 46: exec: /snap/pycharm-community/302/usr/lib/firefox/firefox: not found
Try this:
from selenium import webdriver
from selenium.webdriver.firefox.service import Service
firefox_options = webdriver.FirefoxOptions()
# Your location binary file firefox
firefox_options.binary_location = "/usr/bin/firefox"
# location geckodriver
s = Service("config/geckodriver")
driver = webdriver.Firefox(options=firefox_options, service=s)

GitLab's CI/CD pipelines: Selenium Chrome driver failed to start: exited abnormally or google-chrome is no longer running, Chrome has crashed

I am running git lab ci cd pipeline for selenium Python UI automated tests. My tests are passing ok on my local. I have initialized Google Chrome using below code
driver = chromedriver_autoinstaller.install()
options = webdriver.ChromeOptions()
prefs = {'profile.default_content_setting_values.automatic_downloads': 1}
options.add_experimental_option("prefs", prefs)
driver = webdriver.Chrome(options=options)
When I am running GitLab job, my pipeline is failing with below error
Below if the GitLab runner I can see used while running :
I also tried to used remote driver and headless mode-
In headless mode most of tests are failing. In remote mode, it not instantiating driver. Remove driver code as below
elif self.browser == 'remote':
driver = webdriver.Remote(options=webdriver.ChromeOptions(), command_executor='http://selenium__standalone-chrome:4444/wd/hub')
I am not sure if its happening due to gitlab runner. Or Do I need to create my custom gitlab runner to run on specific machine.
I am running selenium UI tests , so not sure runner which is used in my case don't have facility to run in GUI mode.
I found similar issue here- WebDriverException: Message: unknown error: Chrome failed to start: crashed error using ChromeDriver Chrome through Selenium Python on Amazon Linux
Tried below code but still same issue
options = Options()
options.binary_location = '/usr/bin/google-chrome'
driver = webdriver.Chrome(options=options,
executable_path='/usr/local/bin/chromedriver')
I am spinning image with -Docker executor with image joyzoursky/python-chromedriver:3.8
Probably you are missing below options:
options = webdriver.ChromeOptions()
options.add_argument('--no-sandbox')
options.add_argument('--disable-dev-shm-usage')
For more inspirations go to:
WebDriverException: unknown error: DevToolsActivePort file doesn't exist while trying to initiate Chrome Browser

Selenium, VBA - ERR_PROXY_CONNECTION_FAILED with chromedriver update 86.0.4240.111

It's been working fine until the latest chrome update. As usual I downloaded the latest Chromedriver update to complement the newest release of chrome but now I'm getting the following error once it tries to open a page.
I'm using a proxy so initially I launch chrome without the proxy to ensure there is no connection without proxy, then I launch Putty and connect the proxy server. This has all worked seamlessly until this latest update.
I've included a section of my code below:
Public Driver As New WebDriver
Set Driver = New ChromeDriver
Driver.SetProfile Sheets("Settings").Range("B52").Value
Driver.AddArgument ("--proxy-server=socks5://localhost:1194")
'Set download directory
Driver.SetPreference "download.default_directory", Sheets("Settings").Range("B44").Value
Driver.Get "https://www.google.co.uk/", timeout:=none ', False
If Driver.FindElementsByXPath("//*[contains(text(),'The proxy server is refusing connections')]").Count Or Driver.FindElementsByXPath("//*[contains(text(),'There is something wrong with the proxy server')]").Count Then
Open_Putty_and_Connect_to_Host_Network
end if
Error occurs at driver.get
Full Error Message:
Run_time error '13':
UnknownError
unknown error: net::ERR_PROXY_CONNECTION_FAILED
(Session info: chrome=86.0.4240.111)
(Driver info: chromedriver=86.0.4240.22)
(398b0743353ff36fb1b82468f63a3a93b4e2e89e-refs/branch-heads/424
NT 10.0.18362 x86_64)
I've been looking online and what I can see I need to pass an argument to the chrome driver but I'm not sure how to or what I need to pass to it.
The code will run beyond this point normally and connect to the proxy and perform it's standard function but I can't understand why this error is occurring or how to fix it. Any help would be greatly appreciated!

Running protractor tests on IE 11

OK, so I have been searching a lot to get proper solution to the blocker I am facing right now. Let me give you a background of what I have done so far :
I want to run protractor tests (located on Linux machine) on IE 11 of Windows Server 2012 R2 (IP : 10.81.73.248). My protractorTest.conf.js has below :
exports.config = {
seleniumAddress: 'http://10.81.73.248:4444/wd/hub',
baseURL: 'http://10.81.78.137:80000/',
capabilities: {
browserName: 'internet explorer',
platform: 'ANY',
version: '11'
},
On my Windows Server 2012 R2 machine, I've downloaded IEDriverServer_Win32_2.47.0 and placed it under C:\Windows\System32, environment variable PATH has been updated with above location. Protected mode settings are same for all zones. Windows machine also has selenium-server-standalone-2.48.2.jar placed under C:\Users\Selenium.
On Windows machine, I am starting selenium server using below command :
java -jar selenium-server-standalone-2.48.2.jar -port 4444 -Dwebdriver.ie.driver="C:\Windows\System32\IEDriverServer_Win32_2.47.0\IEDriverServer.exe" , which starts selenium server fine.
With above settings, I run protractor tests from my Linux machine using grunt protractor_test, which launches IE browser on Windows machine, shows localhost:dynamic port and a message as : This is the initial page of webdriver server and within 2 seconds, closes the browser.
The exception I get on selenium server terminal is as below :
Session ID is null. Using WebDriver after calling quit() ?
This is where I am stuck at. I looked at various posts which describes similar issue (?) as mine along with the potential solution, but I am unable to resolve my issue here.
Is there anything I might be doing wrong to setup the connections ? or am I missing some steps to get me through ?
I would really appreciate if you guide me in resolving this long time pending blocker.
I think you are trying to run using old selenium version.It should be 2.53.x something.
Few basics things to check first regarding IE execution:
1).IE Setting for protractor(Selenium)
http://elgalu.github.io/2014/run-protractor-against-internet-explorer-vm/
2).Take IE driver of 32 bit(don't take 64 it has known slowness issues) and manually copy on the following path:
Root Folder\node_modules\protractor\node_modules\webdriver-manager\selenium\IEDriverServer_Win32_2.53.1
3). IE Driver can be downloaded from following path:
http://selenium-release.storage.googleapis.com/index.html?path=2.53/
**OR**
Please upgrade your protractor version to latest like 4.0.11 by changing the version in package.json file and do from command prompt(inside project root directory):
npm update
and then give update your selenium driver with following command from command prompt
webdriver-manager update --ie
it will update the selenium version of IE driver to latest and then try running your tests again.

Resources