简体   繁体   中英

Chromedriver selenium opens page but closes 2 seconds later (Multiple Error Messages)

I'm currently using chromedriver 2.25 to launch a webpage. Everything is done in python but however, when i run the script, i get the following error below.

my chrome version is chrome 54+ and I'm running windows 7 professional.

I've tried using chromedriver 2.27 but I still get the same error message. Does anyone know why I keep getting this error message :/? Would really apperciate any help here :)

   [0131/143630:ERROR:angle_platform_impl.cc(33)] ANGLE Display::initialize 
   error 4 : Could not create D3D11 device.

   [0131/143630:ERROR:gl_surface_egl.cc(612)] eglInitialize D3D11 failed 
   with error EGL_NOT_INITIALIZED, trying next display type

   [0131/143630:ERROR:angle_platform_impl.cc(33)] ANGLE Display::initialize 
   error 4 : Renderer does not support PS 3.0.aborting!

   [0131/143630:ERROR:gl_surface_egl.cc(612)] eglInitialize D3D9 failed 
   with error EGL_NOT_INITIALIZED

   [0131/143630:ERROR:gl_initializer_win.cc(272)] 
   GLSurfaceEGL::InitializeOneOff failed.
   [0131/143630:ERROR:gpu_child_thread.cc(352)] Exiting GPU process due to 
   errors during initialization
   [4632:5396:0131/143630:ERROR:browser_gpu_channel_host_factory.cc(113)] 
   Failed to launch GPU process.   

This is how I start my driver in python

options = Options()
# options.add_argument('--headless')
options.add_argument('--incognito')
options.add_argument('--disable-gpu')
options.add_argument('--log-level=3')
#options.add_argument('--window-position=10000,10000')
chrome_driver = os.getcwd() +"\\chromedriver.exe"
driver = webdriver.Chrome(chrome_driver, chrome_options=options)

The reason is that you have reached at the end of your program... It's as simple as that.. Try to use time.sleep(100) to wait 100 seconds before terminating your program. Put it at the last line in your script like so:

import time

#----- YOU CODE -----
options = Options()
# options.add_argument('--headless')
options.add_argument('--incognito')
options.add_argument('--disable-gpu')
options.add_argument('--log-level=3')
#options.add_argument('--window-position=10000,10000')
chrome_driver = os.getcwd() +"\\chromedriver.exe"
driver = webdriver.Chrome(chrome_driver, chrome_options=options)
#...
#...
time.sleep(100) #waits 100 seconds

Try adding this argument --use-gl=desktop :

options = Options()
# options.add_argument('--headless')
options.add_argument('--incognito')
options.add_argument('--use-gl=desktop')
options.add_argument('--disable-gpu')
options.add_argument('--log-level=3')
#options.add_argument('--window-position=10000,10000')
chrome_driver = os.getcwd() +"\\chromedriver.exe"
driver = webdriver.Chrome(chrome_driver, chrome_options=options)

If this does not work update your chromedriver to at least v2.27 .

To see the compatibility list of chromedrivers to Chrome Browser see @DebanjanB 's answer here .

Hope this helps you!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM