1

I'm trying to use Selenium to open a page and go to Netflix and open a video and play. Once I actually get to the video, I can't load it because I get the error:

Missing Components... Please visit chrome://components, locate the WidevineCdm component...

When going to chrome://components, there aren't any components installed. If I had opened Chrome regularly and navigated to the video like I did in Selenium, I can play it. When I got to chrome://components in regular Chrome, there are more components in there. I'm trying to find out how to import my normal Chrome settings but I can't seem to figure that out. I've tried using ChromeOptions and DesiredCapabilities.CHROME but I couldn't get it to work. I also can't find documentation on all the items inside the DesiredCapabilities.CHROME dictionary. I hope that once I'm able to get normal Chrome settings into the webdriver version, I'd be able to load Netflix videos via Selenium Chrome webdriver.

  • This has been answered here: http://stackoverflow.com/a/29970602/1559300 – ab77 Apr 05 '16 at 09:50
  • @Chainik, the answer you linked is not a working answer. At least not the python snippet. It builds the WebDriver but the WebDriver does not actually exclude the flag. Or something else needs to be done, because the same error shows up. Just a heads up. – RattleyCooper Apr 05 '16 at 17:44
  • I'll post the exact working code as a new answer. If it doesn't work for you, you'll need to be more specific to help identify the cause.. – ab77 Apr 05 '16 at 18:20
  • @Chainik, I posted mine as an answer here in case other people have the same issue: http://stackoverflow.com/a/36435132/2930045 – RattleyCooper Apr 05 '16 at 19:17

2 Answers2

2

The following works, at least on OS X. Make sure to have the correct chromedriver executable in the working directory..

from selenium import webdriver

def buildDriver():
    options = webdriver.ChromeOptions()
    args = ['--user-data-dir=./ChromeProfile',
            '--disable-session-crashed-bubble',                
            '--disable-save-password-bubble',
            '--disable-permissions-bubbles',
            '--bwsi',
            '--incognito',
            '--disable-extensions']

    options.add_experimental_option('excludeSwitches', ['disable-component-update',
                                                        'ignore-certificate-errors'])
    for arg in args:
        options.add_argument(arg)

    chromedriver = './chromedriver'
    return webdriver.Chrome(chromedriver, chrome_options=options)


if __name__ == '__main__':
    driver = buildDriver()
    driver.get('chrome://components/')

I am not quite sure why this answer is being down-marked, because it precisely answers the question asked.

ab77
  • 841
  • 12
  • 14
0

This is not exactly the full solution, but I figured if you use the Chrome's default user directory AND exclude the disable-component-update switch, the component will be loaded properly. You can find the path for Chrome's default user directory for different platforms here*.

So for example on a Mac OS X, do this:

options = webdriver.ChromeOptions()
options.add_experimental_option('excludeSwitches', ['disable-component-update'])
options.add_argument('--user-data-dir=~/Library/Application\ Support/Google/Chrome/')

driver = webdriver.Chrome(chrome_options=options)

driver.get('chrome://components/')

and you should see the WidevineCdm there!

I'll update this if I find a way to do it for custom user directories.

*Note that Default will be added to the end of the path automatically, so as you can see, I am NOT including Default at the end of user-data-dir passed to selenium.

UPDATE 1: Ok. I have a [hacky] solution if you want to use custom user dir. Excluding the --disable-component-update switch will load the components for you, but not completely. If you go to chrome://components you will see the components are there, but they all have version=0.0.0.0, and you need to click on the update button. Below is a simple loop that clicks on the update buttons:

options = webdriver.ChromeOptions()
options.add_experimental_option('excludeSwitches', ['disable-component-update'])
options.add_argument('--user-data-dir=path/to/your/dir')

driver = webdriver.Chrome(chrome_options=options)

driver.get('chrome://components/')

components = driver.find_elements_by_class_name('button-check-update')
for c in components:
    try:
        c.click()
    except:
        pass

Note the try-except. You need it because there are some hidden buttons which throw an exception when you try to click them.

kakhkAtion
  • 2,264
  • 22
  • 23