I am getting this error when I attempt to run code on 2 of 3 computers:
[0502/155335.565:ERROR:gpu_process_transport_factory.cc(1007)] Lost UI shared context.
Here is the code:
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
import os
chrome_options = Options()
chrome_options.add_argument("--headless")
chrome_options.add_argument("--disable-gpu")
chrome_options.add_argument("--window-size=1920x1080")
chrome_driver = os.getcwd() + "\\chromedriver.exe"
print "chrome driver:" + chrome_driver
driver = webdriver.Chrome(chrome_options=chrome_options,
executable_path=chrome_driver)
driver.get("http://www.google.com")
luck_button = driver.find_element_by_css_selector("[name=btnI")
luck_button.click()
driver.get_screenshot_as_file("capture.png")
Now I have checked all of the systems, they are running windows 10 64-bit, google chrome 64 bit Version: 66.0.3359.139, python 2.7 32-bit, chromedriver.exe 32-bit, pycharm 2018.1.1
funny thing is if I run this without the headless options then everything works. The browser pops up, the "I'm feeling lucky" button is pressed, and a screen shot is taken. Only if I add in the headless bit does this error occur.
I am not sure what could be different on 1 system that would allow this to work when the other systems are running the same software.
I had the same problem. Try adding these flags to Chrome driver options:
See this link for more information.
When Headless Chrome was first released as GA (General Availability) by Google Team the article
Getting Started with Headless Chrome
mentioned that :A note was added as :
As per the discussion
Headless: make --disable-gpu flag unnecessary
it was clear that :What happened under the hood?
As per the discussion
headless: Switch from osmesa to SwiftShader
as Google/Chromium team decided to ship SwiftShader with Chrome the team thought to start using it to render GL content in Headless Mode. This required a couple of changes as follows :The idea to
Support WebGL in headless
is still under discussion butSwiftShader fails an assert on Windows in headless mode
with an error as :Conclusion
This error doesn't impact your
@Test
and you can ignore the error for the time being.