undetected-chromedriver
undetected-chromedriver copied to clipboard
Debug mode error
import time
import undetected_chromedriver as uc
from selenium.webdriver.chrome.options import Options
if __name__ == '__main__':
options = Options()
options.debugger_address = "127.0.0.1:9222"
driver = uc.Chrome(driver_executable_path='C:\\Users\\guide\\Downloads\\chromedriver.exe', options=options)
driver.get("https://abrahamjuliot.github.io/creepjs/")
time.sleep(1000)
When I run with debug mode, it will run 2 chromes the same as the picture. Anyone can show me a method to fix it? Thank you
- You should use
uc.ChromeOptions()
instead of the Selenium one. - Why do you need to specify a debug address ? UC already looks for a free port for you...
-
There's a bug indeed with
options.debugger_address
which is not reflected in the debugger address and port. To fix it you'll have to modify the code in__init__.py
, line 250 :
# debug_port = selenium.webdriver.common.service.utils.free_port()
# debug_host = "127.0.0.1"
# if not options.debugger_address:
# options.debugger_address = "%s:%d" % (debug_host, debug_port)
# FIX : REPLACED BY
if not options.debugger_address:
debug_port = port if port != 0 else selenium.webdriver.common.service.utils.free_port()
debug_host = "127.0.0.1"
options.debugger_address = "%s:%d" % (debug_host, debug_port)
else:
debug_host, debug_port = options.debugger_address.split(":")
debug_port = int(debug_port)
# END of FIX
EDIT : Or you can use my fork where this bug has been fixed.
- You should use
uc.ChromeOptions()
instead of the Selenium one.- Why do you need to specify a debug address ? UC already looks for a free port for you...
- There's a bug indeed with
options.debugger_address
which is not reflected in the debugger address and port. To fix it you'll have to modify the code in__init__.py
, line 250 :# debug_port = selenium.webdriver.common.service.utils.free_port() # debug_host = "127.0.0.1" # if not options.debugger_address: # options.debugger_address = "%s:%d" % (debug_host, debug_port) # FIX : REPLACED BY if not options.debugger_address: debug_port = port if port != 0 else selenium.webdriver.common.service.utils.free_port() debug_host = "127.0.0.1" options.debugger_address = "%s:%d" % (debug_host, debug_port) else: debug_host, debug_port = options.debugger_address.split(":") debug_port = int(debug_port) # END of FIX
EDIT : Or you can use my fork where this bug has been fixed.
It still opened 2 chromes the same as the picture. Chrome 1 can remote port to debug. Chrome 2 did not do anything, just opened. Can you have any video showing me the method to fix it?
I have run cmd with "C:\Program Files\Google\Chrome\Application\chrome.exe" -remote-debugging-port=9222 --user-data-dir="D:\test" Then I run my code:
import undetected_chromedriver as uc
if __name__ == '__main__':
options =uc.ChromeOptions()
options.debugger_address = "127.0.0.1:9222"
driver = uc.Chrome(options=options)
driver.get("https://abrahamjuliot.github.io/creepjs/")
time.sleep(100000)
driver.close()
Sure you launch twice your chrome, once with cmd
and a second time with uc.Chrome()
in your script !!
And by the way the correct command line switch is --remote-debugging-port
...
Anyway you don't have to launch a chrome by hand or specify an address or a port :
import undetected_chromedriver as uc
if __name__ == '__main__':
driver = uc.Chrome()
driver.get("https://abrahamjuliot.github.io/creepjs/")
input("hit a key to quit")
driver.quit()
Thanks for closing this non issue.
Sure you launch twice your chrome, once with
cmd
and a second time withuc.Chrome()
in your script !! And by the way the correct command line switch is--remote-debugging-port
...Anyway you don't have to launch a chrome by hand or specify an address or a port :
import undetected_chromedriver as uc if __name__ == '__main__': driver = uc.Chrome() driver.get("https://abrahamjuliot.github.io/creepjs/") input("hit a key to quit") driver.quit()
Thanks for closing this non issue.
But when I run this code
from selenium import webdriver
option = webdriver.ChromeOptions()
option.debugger_address = "127.0.0.1:9222"
driver = webdriver.Chrome(executable_path= 'C:\\Users\\guide\\Downloads\\chromedriver.exe', options=option)
driver.get("https://abrahamjuliot.github.io/creepjs/")
time.sleep(1000)
it only opened 1 chrome. My aim is to control chrome in cmd and not open more chrome browser.
Why would you want to do that ?!
Why would you want to do that ?!
I want to remote gologin profile by undetect_chromedriver.
why don't you use the Chrome browser launched and controlled by UC for that ? Sorry it doesn't make sense.
why don't you use the Chrome browser launched and controlled by UC for that ? Sorry it doesn't make sense.
gologin can fake all fingerprint browsers and I want to remote it.
I guess it's possible but it would mean a lot of change in UC because there are some conflicts between the 2 packages. UC does launch a Chrome browser in a detached process and handles it's termination. So you'll have to get rid of all this code to make it works. Then you'll have to check that UC options do not conflict with the one added in the package you mentioned, especially everything about user_data_dir, address, host and port. I'm not sure it's worth it since one interesting UC feature is that it starts a pristine browser in a detached process and that comes with a price : experimental options (except prefs) won't work... If I were you I'd ask for help to the gologin owners, their service is not free so it should come with actual support. EDIT : please close this issue, it has nothing to do with UC.
Duplicate of #461
@guidetuanhp Have you solved the problem yet I also need to control the open browser and have the same problem as you
@guidetuanhp @fomsun I fixed it, pm me
@hoanm1206 How you fix it? Can you pm me? Discord: WhySoSerious#2434
@guidetuanhp @fomsun @hoanm1206 did u guys found how to do it? I'm really struggling to find a fix