Search code examples
pythonseleniumgoogle-chromewebdriver

Chrome page opened with selenium remains blank


I am trying to save a screenshot of a webpage, to do so I am trying to use Selenium. The problem is that once the webpage is opened, it stays blank with "data:" in the URL.

Here is my code:

from selenium import webdriver
options = webdriver.ChromeOptions()
options.add_experimental_option('useAutomationExtension', False)
driver = webdriver.Chrome(options=options,executable_path='aPath/chromedriver.exe',service_log_path='aPath/mylog.txt')
driver.get('http://myURL.html')
screenshot=driver.save_screenshot('aPath/my_screenshot.png')
driver.quit()

NB: I have checked that my chromedriver version is compatible with my chrome browser version.


Solution

  • Thanks for your help guys, actually Guy was right, I had to specify the port:

    options.add_argument('--remote-debugging-port=9222')
    

    Now it works!