How To Execute Selenium Scripts On Already Opened Browser Using Python
ฝัง
- เผยแพร่เมื่อ 25 ก.พ. 2021
- In this video, I will share how to execute selenium test or script on already opened browser using Chrome DevTools Protocol in Python.
Chrome Devtools
chromedevtools.github.io/devt...
All Videos
/ mukeshotwani
All Playlist
/ mukeshotwani
Connect with us:
Linkedin- / mukesh-otwani-93631b99
Instagram- / mukeshotwani
Facebook Group- / 256655817858291
Facebook Page- / seleniumwebdrivermukesh
Twitter- / mukeshotwani
Blog- learn-automation.com - วิทยาศาสตร์และเทคโนโลยี
YOU'RE MY FKING HERO! I've been grinding the whole damn day trying to interact with the same webdriver session and to no results, until you showed how it's done... I've done some tweaks of course, I do everything inside my python code, no console required, BUT without you I couldn't have done NOTHING. Thank you again.
I've been getting a deprecation warning, do you know any solution?
@@juanpablomessmer2630 same here did you get any solution ?
From Nigeria 🇳🇬, you are amazing.....This solved a lot of problems
Yo what project are you using selinium for
Omg.... you saved me so much time. THANK YOU!!!
Very Nice, saved huge amount of time with simple steps to introduce.
nice
Looking forward for more videos on python sir thank u mukesh..
I've been looking for couple of days for thinking this, you're definitely a live saver. Thanks sir for your kind sharing
You are most welcome
Man, I would watch this guy code the whole day!
Quality Content, precise You rock mannnn solved my problem of login cookie
Thanks for showing us a working solution!
Thank you , This is very useful video .👍👍
Thanks for the new learning
Amazing. Thank you very much for this awesome tutorial.
nice
Thanks much for doing with python.
fantastic tutorial! thanks for explaining everything clearly
most welcome mate
nice
Thanks a lot! It was very helpfull!
Thank, you Sir. Really appreciate your effort.
You are most welcome Chetan.
Very clear explanation brother. thanks a lot
Thanks Aswin
Great video, helped me out a lot!
Awesome, thank you!
Love this channel 👍🏻👍🏻👍🏻
Glad you liked it! Thanks Gulshan
I must say it's a Life saving hack. Thanks a lot and really appreciate for demonstrating in Python.
Glad you liked it! Godwin. Cheers
nice
hey can you give me source code im getting errors
Thanks for the video, btw: Do you know if CloudFlare DDoS protection will redirect correctly if it gets executed when doing tests using this method shown in the video? I ask because when you use the chromedriver even with user data dir and profile directory, after several tests CloudFlare DDoS protection appears and it doesn't redirect you because it thinks you are a bad bot that wants to shut down the website in which you are doing tests, please let me know if this doesn't happen when using this method.
cooool!!! internet rebellion time!
Great content! Thanks bro!
Glad you liked it! Thanks Mate
Nice really appreciated
I am glad it helped.
GOD! Thank you for this tutorial! 🏆
I am glad it helped
Thank you.
Thank you bro
It was nice and easy.
Thanks Rahman
You saved my life, the Selenium visual Chrome driver cannot show some image file frome web, thank you.
Most welcome Sub
can you please share the code?
Let Me tell You. I love hearing Your voice Mukesh. So concise, so beautiful. I almost remember Cherry Blossoms while I was watching this video. So good. So so good~ xFredAgain&Again I cannot tell You that if I could just hear You. Explain. The Code. SANK YIOUUU SIIIR 😊🎉
loved the fact that it is available on python also
Yes I am loving this too.
Thank you sir
Welcome
awesome . thank you . you are nice man bro. xxxx
Always welcome Hakan
thanks man it worked!
You're welcome! Cheers
I can't get it working, Nothing is happening in the browser.
Nice video sir❤️❤️❤️❤️❤️❤️
Thanks Mate
Thanks!
Welcome!
thanks for this tutorial , this can it run with firefox
Cool
Could you reply, how to run tasks in headless mode using this?
works great if you have only 1 browser instant open for that account but what about if you have many accounts open...can we access that specific instance?
hello, I tried to do as you said, and it worked for about a week but all of a sudden python just isnt going to the opened chrome tab, I updated my webdriver and made sure it is in line with my chrome version and it works without options.
cmd:
cd C:\Program Files\Google\Chrome\Application
chrome.exe --remote-debugging-port=8989 -user-data-dir="C:\Users\Mac\Desktop\Drive D\MJ\Python\chromeprofile"
in python:
opt = Options()
opt.add_experimental_option("debuggerAddress", "localhost:8989")
driver = webdriver.Chrome(options=opt)
please help, very much appreciated
nice 👍
Thanks mate
Great sir, Is there any github link for the code ?? I had'nt found in description.
Bro you are a fucking GOAT. no way bro you are the one who saved my life. thankyou so much bhai.
Thank you so much it means alot to me.
I am trying to make a whatsapp bot. but web needs a registration right after opening the window. so I needed this buddy. thx
Great Orhan, I am glad it helped.
Tks from Brasil!! o/
Welcome from India
Hey Mukesh, can you do the same thing using robotframework?
how can i open slenium browser window at client(user) side in selenium with python when I hit go button on my auto login system?
Hello, what if o want open a new brownser, and get logged in, after that I want open a new browser but with the same session (that remain logged in) , how can I do it? I want be logged in two different windows of same browser and be managed each window with different parts of script
Hi bro this code is not working chrome version 117. Could you please help us with this version?
Can this be done in firefox? Not sure if it has the dev tools
Same is possible with IE ?
In this code I need to manually type the username, password and two factor auth, after that code should run. what to do?
First to watch..😇
fantastic!! how could i use remote debugging with proxy ?
How would you do this exact same thing on a Mac? I’m having trouble setting up the local host.
Any help is appreciated, thanks!
Great tutorial! How can i download the chrome driver shown at 6:50?
I use to update my profile inevery 5 minutes on a local job platform, Thank Yoıu
hello there, did this method worked with you,
selenium keep getting stuck at my end
Awesome Yasin
Hey Peter, what issues you are getting here.
is there any way to open in firefox also in this same method
Hello sir how can i do login multiple Facebook ids in multiple chrome profile and these login ids save for me if i opened these chrome profile than open Facebook that ids will be open how can i do that ???
Can you do the tutorial in robotframework?
this tutorial is lit
Please create a complete playlist for framework development in selenium-python.
Hi Nasir, sure will do soon.
This is so great, thank you. Is there a way to also include the first part into the script? I mean that instead of going to "cmd" and manually inputing all the "-- remote-debuggin-port" we can also include that in the script somehow?
You can add this to your code:
import shlex, subprocess
subprocess.Popen(shlex.split(r''' FIRST PART '''))
Or also you can put it in a .bak before the "start python file.py"
Mukesh, is it possible to explain/comment on this question?
you can use pyautogui to do that part by gui automation
Yes make a bat file and then include in your program using subprocess module
i think , os module has a class that inputs cmd commands
Sir, can you please say why did you take remote-debugging-port (8989) instead of (9222) which is shown on Chrome Devtools Protocal... What port number should I take
You can use any port number you can use 8989 or 9222 you just have to the same in program.
@@Mukeshotwani Thank You
for firefox
what i have to do bro
Hello Sir, How to achieve this in macbook? Can you please guide me.
So for me I want to do a script that is automated to do some scraping, but how I can automate the part of cmd?
Using batch command or shell
sir please make a video same for Internet Explorer,
How to do this in firefox browser as experimental_option debuggerAddress is not present. If anyone know help me out...
Any Idea how do we remote debug from a host computer to remote computer using webdriver.Remote(command_executer=:port) instead of webdriver.Chrome()
thankyou
others had java n shit
but I love Python
Hi Aadesh + 1
@@Mukeshotwani ❤️
Hello, you opened the browser in cmd, how can i open like this but in a python code? i mean like: my code open the chrome in debug mode and after connect
use Cython.
sir its showing error
No pyvenv.cfg file
Can i use with firefox browser ? If its possible, can u make a video teaching us ?
Will try
can i use headless mode?
Please help I got this error. Do you know how to fix it? driver = webdriver.chrome(executable_path= "C:\\Users\\PC-home\\Documents\\Dan\\chromedriver.exe" , chrome_options = opt)
TypeError: 'module' object is not callable
Thanks Mukesh!! Is there a way to use selenium on Chrome with the Chrome extensions already installed?
just use specific profile where it was installed.
@@mrnobody_23 how to?? how to use user profiles where i have already logged in??
sir but without command proamt how can we use
how to achieve this thing for edge
Is there other way to connect already opened browser without using remote debugging port? 🤔
It was great video but i was thinking can we open the browser which we opened manually in which already all cookies are stored which helps us bypass login option?
moreover how to perform this action on linux, as i am a newbie.
Hey Shuham once you open browser using DevTools you can login which will have session active, then you can use the same.
can you make a tutorial or send some code on how to do this in JS? ive been beating my head for three days trying to figure it out
ur the GOAT
Thank you sir
How to do this on Javascript :(
?
getting error please anyone help!!
'''DeprecationWarning: use options instead of chrome_options
driver = webdriver.Chrome(executable_path="F:\\top secret\\chromedriver.exe", chrome_options=opt)'''
Hi Mukesh , Very clearly explained.
I am trying to save cookies for already logged in session in python and trying to use it for every instance of web driver to get rid of login but i am not able to achieve it, can you please do a small video on this
Are you able to resolve this
Nope
@@krishnachaitanya836 : can i get your number to discuss few things
This worked for me for a few days. But now it gives me and error saying: selenium.common.exceptions.WebDriverException: Message: unknown error: cannot connect to chrome at localhost:9222
from session not created: This version of ChromeDriver only supports Chrome version 91
Current browser version is 93.0.4577.82
Hello sir can you make video on multiple facebook ids auto login on Facebook with chrome users. i have multiple facebook ids likes thousands of ids and i am tried to login in making new chrome user and login and this will take much time from can you tell me plz humble request ??
hello sir nicely explained....can u plz explain how to run the session in an already logged in account???
Hi Fringe, it only works with chrome started by CDP commands.
Wondering the same thing as @fringe, can you elaborate a little bit more please?
please how can i use it (chromiun --remote-debuggin-port=9105 --user-data-dir='/home/olix/Desktop/data9105') in linux but have it stay like it is on windows even if i close terminal. ???
thanks for answer.
Once you close the terminal it will close the session.
@@Mukeshotwani thank you for your answer you are a good person. what I would like to know is how to do to keep the session in linux if I want to close the terminal or is it impossible to do? thank you.
Hey Mukesh ! I wish to make the same process in Firefox. Can you tell me small steps in the comment plz.
Hi Malik, I will try for FF as well if possible.
how to setup this for mac
How to open a link from signed in chrome profile using selenium python. I googled and didn't found the correct way to do that. Your help would be great.
Thanks
Hi Gowtham, you can start default user profile.
@@Mukeshotwani can you guide me how
Hi Mukesh,
In the start i got error likr"DeprecationWarning: use options instead of chrome_options". so i tried using options but ended with following error.
selenium.common.exceptions.WebDriverException: Message: unknown error: cannot connect to chrome at localhost:8080
from chrome not reachable.
Previously i was using "chrome.exe --remote-debugging--port=8080 --user-data-dir="C:\Drivers\ChromeData""
But i use the following cmd line to open a chrome in debugger mode , i am able to proceed.
chrome.exe --remote-debugging-port=8080 --no-first-run --no-default-browser-check --user-data-dir="C:\Drivers\ChromeData"
Great Minati thank you for updating.
thank you so much
Thanks for sharing
by using jupyter notebook or something similar you can easily execute code line by line thus you don't have to comment previous lines.
In my use case I wanted to make a web bot which involved a lot of trial and error and loading session each time was pain in the ass.
Noted Sir.
Please do this for c#... Pls pls
Does it work on mac as well ?
Yes Caner why not.
Hi man thanks for your support, i followed your steps and did the same code but when i run the code with the browser closed its give me this error :
"selenium.common.exceptions.WebDriverException: Message: unknown error: cannot connect to chrome at localhost:8989 from chrome not reachable"
but when i run the chrome.exe pointing to the session from the console i can open the session created normaly. Looking forward for more videos, thanks again!
did you solve this? Getting the same error.
im getting the same error too
did your problem slove? can you give source code?
how can we change the download director to download files to a specific folder?
Hi Ninjamoshi,
Official link chromedriver.chromium.org/capabilities
Please find below code
ChromeOptions options = new ChromeOptions();
Map prefs = new HashMap();
prefs.put("download.default_directory", "/directory/path");
options.setExperimentalOption("prefs", prefs);
@@Mukeshotwani hi sir can give an example regarding the same ? like make video or a blog
using python
also can ou change the download path On Already Opened Browser?
can we open another tab in this existing window
i tried with driver.execute_scripts("window.open();"), but didn't work
2:25 why did u change protocol from 9222 to 8989?
You can use any port and make sure you use same port number is code as well. I have 8989 is my code too.