this works if I run the below command manually:
google-chrome --remote-debugging-port=9222 --user-data-dir=\"/usr/local/xxx\"'
then I have to open a tab within an existing session manually as well. And than run the Selenium script to get data from manually opened a webpage.
I would like to automate these steps and came up with the below script, but unfortunately it does not work.
is there a way to have a script which opens chrome in debugging mode, then open a new tab, then connect to it with selenium webdriver ?
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
import webbrowser
import subprocess
from subprocess import call
import os
myCmd = 'google-chrome --remote-debugging-port=9222 --user-data-dir=\"/usr/local/xxx/Project\"'
print (myCmd)
subprocess.call(myCmd,shell=True)
chrome_options = Options()
chrome_options.add_experimental_option("debuggerAddress", "127.0.0.1:9222")
#Change chrome driver path accordingly
driver = webdriver.Chrome('/usr/local/xxx/chromedriver') # Optional argument, if not specified will search path.
driver = webdriver.Chrome(chrome_driver, chrome_options=chrome_options)
webbrowser.open('https://www.seleniumhq.org')
# print driver.title