Jump to content
zMotoR

The app freezes on executing webdriver.Chrome

Recommended Posts

Hello. I'd like to use chromium to analyze web content via P2D + chromedriver.exe + chromium. But my app freezes on executing webdriver.Chrome. But this script works fine via python.exe. How to make the code to work fine with P2D?

 

import requests, os, urllib3, shutil, tempfile, zipfile, datetime, time, winreg
import selenium
from selenium import webdriver

CHROMEDRIVER = os.path.abspath("chromedriver.exe")
BINARY_LOCATION = os.path.abspath(r"chromium\chrome.exe")

chrome_options = selenium.webdriver.chrome.options.Options()
chrome_options.binary_location = BINARY_LOCATION

browser = webdriver.Chrome(CHROMEDRIVER, options=chrome_options)
browser.get('http://www.google.com/');

 

Edited by zMotoR

Share this post


Link to post

Hmm strange.. If I try to execute my script with webdriver.Chrome through ShellExecute + python.exe the script freezes also. Maybe there is a problem with some rights?

 

procedure TForm1.Button4Click(Sender: TObject);
var
  fileName: string;
  parameters: string;
  directory: string;
begin
  fileName := TPath.Combine(PythonEngine.DllPath, 'python.exe');
  parameters := 'A:\Projects\PythonTest2\Win32\Debug\test.py';
  directory := 'A:\Projects\PythonTest2\Win32\Debug';
  ShellExecute(0, 'open', PChar(fileName), PChar(parameters), PChar(directory), SW_NORMAL);
end;

 

Share this post


Link to post

I found a decision. Have to add the option --no-sandbox:

chrome_options.add_argument("--no-sandbox")

The full script:

import requests, os, urllib3, shutil, tempfile, zipfile, datetime, time, winreg
import selenium
from selenium import webdriver

CHROMEDRIVER = os.path.abspath("chromedriver.exe")
BINARY_LOCATION = os.path.abspath(r"chromium\chrome.exe")

chrome_options = selenium.webdriver.chrome.options.Options()
chrome_options.binary_location = BINARY_LOCATION
chrome_options.add_argument("--no-sandbox")

browser = webdriver.Chrome(CHROMEDRIVER, options=chrome_options)
browser.get('http://www.google.com/');

 

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×