I am trying to automate a webpage through Python, Selenium and Chrome. The code is:
import time
from multiprocessing.dummy import Pool as ThreadPool
from selenium.webdriver.chrome.options import Options
from selenium import webdriver
from selenium.webdriver.common.proxy import Proxy, ProxyType
prox = Proxy()
prox.proxy_type = ProxyType.MANUAL
prox.http_proxy = "http://some-proxy.net:8090"
capabilities = webdriver.DesiredCapabilities.CHROME
prox.add_to_capabilities(capabilities)
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument('--disable-web-security')
chrome_options.add_argument('--ignore-certificate-errors')
chrome_options.add_argument("--disable-extensions")
chrome_options.add_argument("--disable-notifications")
chrome_options.add_argument("--enable-automation")
chrome_options.add_argument("--disable-save-password-bubble")
chrome_options.add_argument("test-type")
chrome_options.add_argument("start-maximized")
chrome_options.add_argument("test-type=browser")
chrome_options.add_argument("disable-infobars")
chrome_options.add_argument('--no-sandbox')
chrome_options.add_argument('--disable-dev-shm-usage')
driver_path = 'M:/chromedriver/chromedriver.exe'
driver = webdriver.Chrome(driver_path, chrome_options=chrome_options,desired_capabilities=capabilities)
driver.get('https://somepage.csintra.net/')
Chrome will open, but not load the page. Instead, I get the following "Not secure" warning displayed:
As per code above, I have tried disabling various Chrome options gathered from various SO answers, but to no avail. I have also tried chrome_options.add_argument('--headless')
as suggested here, but this causes the following error in chromedriver.exe:
Failed to resolve service name: metrics
As visible on the screenshot above, I also cannot unblock notifications, popups and location upon Selenium opening Chrome, since they are blocked by administrator - I am doing this at work (but anyway, in my Chrome settings "[*].csintra.net" is allowed to open popups and notifications).
Python's console output when the code is run:
Traceback (most recent call last):
File "<ipython-input-40-82760f33374f>", line 1, in <module>
runfile('M:/python scripts/coding_automation.py', wdir='M:/python scripts')
File "C:\Program Files\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 866, in runfile
execfile(filename, namespace)
File "C:\Program Files\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 102, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)
File "M:/python scripts/coding_automation.py", line 35, in <module>
driver = webdriver.Chrome(driver_path, chrome_options=chrome_options,desired_capabilities=capabilities)
File "C:\Users\M299700\AppData\Roaming\Python\Python36\site-packages\selenium\webdriver\chrome\webdriver.py", line 75, in __init__
desired_capabilities=desired_capabilities)
File "C:\Users\M299700\AppData\Roaming\Python\Python36\site-packages\selenium\webdriver\remote\webdriver.py", line 156, in __init__
self.start_session(capabilities, browser_profile)
File "C:\Users\M299700\AppData\Roaming\Python\Python36\site-packages\selenium\webdriver\remote\webdriver.py", line 251, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "C:\Users\M299700\AppData\Roaming\Python\Python36\site-packages\selenium\webdriver\remote\webdriver.py", line 320, in execute
self.error_handler.check_response(response)
File "C:\Users\M299700\AppData\Roaming\Python\Python36\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
WebDriverException: unknown error: Chrome failed to start: crashed
(unknown error: DevToolsActivePort file doesn't exist)
(The process started from chrome location C:\Program Files (x86)\Google\Chrome\Application\chrome.exe is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
(Driver info: chromedriver=2.41.578737 (49da6702b16031c40d63e5618de03a32ff6c197e),platform=Windows NT 6.1.7601 SP1 x86_64)
Is there any way to bypass this?
EDIT:
As mentioned above, solution posted in the "duplicate "thread did not help.