-1

I want to initialize chrome webdriver with proxy. I found a solution in this link. I did just like this but got exception like this.

   driver = webdriver.Chrome(chrome_options=chrome_options, executable_path='/usr/lib/chromium-browser/chromedriver')
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/chrome/webdriver.py", line 75, in __init__
    desired_capabilities=desired_capabilities)
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 154, in __init__
    self.start_session(desired_capabilities, browser_profile)
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 243, in start_session
    response = self.execute(Command.NEW_SESSION, parameters)
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 312, in execute
    self.error_handler.check_response(response)
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally
  (Driver info: chromedriver=2.35 (0),platform=Linux 4.4.0-122-generic x86_64)

As I need to created to file described in the link, here is my background.js

var config = {
                mode: "fixed_servers",
                rules: {
                  singleProxy: {
                    scheme: "http",
                    host: "172.241.11.1", //modified it for privacy
                    port: parseInt(29842)
                  },
                  bypassList: ["foobar.com"]
                }
              };

        chrome.proxy.settings.set({value: config, scope: "regular"}, function() {});

        function callbackFn(details) {
            return {
                authCredentials: {
                    username: "aedqbb01",
                    password: "ac7DMjR"
                }
            };
        }

        chrome.webRequest.onAuthRequired.addListener(
                    callbackFn,
                    {urls: ["<all_urls>"]},
                    ['blocking']
        ); 

and manifest.json

{
            "version": "1.0.0",
            "manifest_version": 2,
            "name": "Chrome Proxy",
            "permissions": [
                "proxy",
                "tabs",
                "unlimitedStorage",
                "storage",
                "<all_urls>",
                "webRequest",
                "webRequestBlocking"
            ],
            "background": {
                "scripts": ["background.js"]
            },
            "minimum_chrome_version":"22.0.0"
        }

and here is my python program

from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from bs4 import BeautifulSoup
chrome_options = Options()
chrome_options.add_argument("--headless")
#chrome_options.add_argument("--window-size=1920x1080")
chrome_options.add_argument("user-agent=Mozilla/5.0 (Windows NT 6.3; rv:36.0) Gecko/20100101 Firefox/36.0")
chrome_options.add_extension("proxy.zip") #where is manifest.json and background.json 
driver = webdriver.Chrome(chrome_options=chrome_options, executable_path='/usr/lib/chromium-browser/chromedriver')
driver.get("https://www.google.com")
soup = BeautifulSoup(browser.page_source, 'lxml')

Code works fine without proxy file.

I did I missing here. Please correct me.

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
Dip Deb
  • 1
  • 1

1 Answers1

0

This error message...

selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally

...implies that the ChromeDriver was unable to initiate/spawn a new WebBrowser i.e. Chrome Browser session.

Your main issue is the version compatibility between the binaries you are using as follows :

  • You are using chromedriver=2.35
  • Release Notes of chromedriver=2.35 clearly mentions the following :

Supports Chrome v62-64

  • You are using chrome=65.0
  • Release Notes of ChromeDriver v2.38 clearly mentions the following :

Supports Chrome v65-67

  • Your Selenium Client version is 3.11.0.

So there is a clear mismatch between the Selenium Client v3.1.0 , ChromeDriver version (v2.35) and the Chrome Browser version (v65.0)

Solution

  • Upgrade ChromeDriver to current ChromeDriver v2.38 level.
  • Upgrade Chrome version to current Chrome v66.x levels. (as per ChromeDriver v2.38 release notes)
  • Clean your Project Workspace through your IDE and Rebuild your project with required dependencies only.
  • Use CCleaner tool to wipe off all the OS chores before and after the execution of your test Suite.
  • If your base Web Client version is too old, then uninstall it through Revo Uninstaller and install a recent GA and released version of Web Client.
  • Take a System Reboot.
  • Execute your @Test.
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • updated chromedriver to(2.38.552522), Google Chrome 66.0.3359.139 Got error again selenium.common.exceptions.WebDriverException: Message: unknown error: failed to wait for extension background page to load: chrome-extension://nkfjhnfkkgabeghamphipepjpbcjkkfd/_generated_background_page.html from unknown error: page could not be found: chrome-extension://nkfjhnfkkgabeghamphipepjpbcjkkfd/_generated_background_page.html – Dip Deb May 02 '18 at 14:00
  • @DipDeb I have solved this question for the error you were seeing as **selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally**. Can you raise a new question for your new requirement please? – undetected Selenium May 02 '18 at 14:04