zMotoR 0 Posted February 26, 2021 (edited) 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 February 26, 2021 by zMotoR Share this post Link to post
zMotoR 0 Posted February 27, 2021 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
zMotoR 0 Posted February 28, 2021 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