How To Execute Selenium Scripts On Already Opened Browser Using Python

Поделиться
HTML-код
  • Опубликовано: 9 янв 2025

Комментарии •

  • @alexjulius69
    @alexjulius69 2 года назад +16

    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.

    • @juanpablomessmer2630
      @juanpablomessmer2630 Год назад

      I've been getting a deprecation warning, do you know any solution?

    • @omiqureshi276
      @omiqureshi276 Год назад

      @@juanpablomessmer2630 same here did you get any solution ?

  • @tiiirecords8004
    @tiiirecords8004 2 года назад +2

    From Nigeria 🇳🇬, you are amazing.....This solved a lot of problems

    • @elookoye2231
      @elookoye2231 Год назад

      Yo what project are you using selinium for

  • @rudiantoxu2497
    @rudiantoxu2497 Год назад +3

    I've been looking for couple of days for thinking this, you're definitely a live saver. Thanks sir for your kind sharing

  • @vijayppatel
    @vijayppatel 3 года назад +4

    Very Nice, saved huge amount of time with simple steps to introduce.

  • @lawrenceogola6002
    @lawrenceogola6002 Год назад

    Man, I would watch this guy code the whole day!

  • @godwinjoy2647
    @godwinjoy2647 3 года назад +3

    I must say it's a Life saving hack. Thanks a lot and really appreciate for demonstrating in Python.

  • @subpakk
    @subpakk Год назад +1

    You saved my life, the Selenium visual Chrome driver cannot show some image file frome web, thank you.

  • @alamar11
    @alamar11 3 года назад

    Omg.... you saved me so much time. THANK YOU!!!

  • @mallikarjunag4078
    @mallikarjunag4078 3 года назад +2

    Looking forward for more videos on python sir thank u mukesh..

  • @Gulsatile
    @Gulsatile 2 года назад +1

    Love this channel 👍🏻👍🏻👍🏻

    • @Mukeshotwani
      @Mukeshotwani  2 года назад +1

      Glad you liked it! Thanks Gulshan

  • @dungeonmaster2844
    @dungeonmaster2844 3 года назад

    Quality Content, precise You rock mannnn solved my problem of login cookie

  • @artyroo7747
    @artyroo7747 Год назад +1

    GOD! Thank you for this tutorial! 🏆

  • @Aswinvishnu2
    @Aswinvishnu2 3 года назад +1

    Very clear explanation brother. thanks a lot

  • @DJCharalampos
    @DJCharalampos Год назад

    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 😊🎉

  • @jonskill2236
    @jonskill2236 10 месяцев назад +1

    Great video, helped me out a lot!

  • @cryptobote3220
    @cryptobote3220 3 года назад +2

    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.

  • @NazarMalyy
    @NazarMalyy 3 года назад

    Thanks for showing us a working solution!

  • @abhinavagarwal7373
    @abhinavagarwal7373 3 года назад +1

    loved the fact that it is available on python also

  • @chetanmishra422
    @chetanmishra422 3 года назад +1

    Thank, you Sir. Really appreciate your effort.

  • @KhalilYasser
    @KhalilYasser 3 года назад +1

    Amazing. Thank you very much for this awesome tutorial.

  • @HelloWorld-dn9mm
    @HelloWorld-dn9mm 3 года назад +3

    Cool
    Could you reply, how to run tasks in headless mode using this?

  • @curiodidadeinfinita
    @curiodidadeinfinita 6 месяцев назад +3

    Can i use with firefox browser ? If its possible, can u make a video teaching us ?

  • @armanajith9004
    @armanajith9004 2 месяца назад +1

    Very thankful! Is it also possible to execute the Selenium script on an already opened browser, but headless? Meaning, that the browser's window won't pop up?

    • @Mukeshotwani
      @Mukeshotwani  2 месяца назад +1

      Interesting but not tried. You can use --headless=new for the same. Here is the video ruclips.net/video/_j0S9Fbs3dY/видео.html

  • @kobruh9642
    @kobruh9642 2 года назад +1

    I am trying to make a whatsapp bot. but web needs a registration right after opening the window. so I needed this buddy. thx

    • @Mukeshotwani
      @Mukeshotwani  2 года назад

      Great Orhan, I am glad it helped.

  • @educatech8450
    @educatech8450 3 года назад +2

    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

    • @Mukeshotwani
      @Mukeshotwani  3 года назад

      You can use any port number you can use 8989 or 9222 you just have to the same in program.

    • @educatech8450
      @educatech8450 3 года назад +1

      @@Mukeshotwani Thank You

  • @NetSolutionAkash
    @NetSolutionAkash 3 года назад +2

    Nice video sir❤️❤️❤️❤️❤️❤️

  • @PRO-ko4gx
    @PRO-ko4gx 2 года назад +1

    Great content! Thanks bro!

  • @Duke_Nukem-42
    @Duke_Nukem-42 Год назад

    Thanks a lot! It was very helpfull!

  • @_____________________joa000
    @_____________________joa000 2 года назад +1

    2:25 why did u change protocol from 9222 to 8989?

    • @Mukeshotwani
      @Mukeshotwani  2 года назад

      You can use any port and make sure you use same port number is code as well. I have 8989 is my code too.

  • @taylorreed9740
    @taylorreed9740 3 года назад

    Great tutorial! How can i download the chrome driver shown at 6:50?

  • @thor3203
    @thor3203 2 года назад

    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?

  • @rkn3383
    @rkn3383 3 года назад +1

    Thanks much for doing with python.

  • @FireFly969
    @FireFly969 8 месяцев назад +1

    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?

    • @Mukeshotwani
      @Mukeshotwani  8 месяцев назад

      Using batch command or shell

  • @anilm871
    @anilm871 3 года назад +2

    Great sir, Is there any github link for the code ?? I had'nt found in description.

  • @juanwea223
    @juanwea223 3 года назад +1

    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?

    • @fillipeamg5877
      @fillipeamg5877 3 года назад +1

      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"

    • @taylorreed9740
      @taylorreed9740 3 года назад +1

      Mukesh, is it possible to explain/comment on this question?

    • @sheikhraisulislam4483
      @sheikhraisulislam4483 2 года назад

      you can use pyautogui to do that part by gui automation

    • @biplabnath8458
      @biplabnath8458 2 года назад

      Yes make a bat file and then include in your program using subprocess module

    • @sadlyanengineer
      @sadlyanengineer Год назад

      i think , os module has a class that inputs cmd commands

  • @Mshahzaibkundi
    @Mshahzaibkundi 2 года назад +1

    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 ???

  • @yasinerdem3811
    @yasinerdem3811 2 года назад +1

    I use to update my profile inevery 5 minutes on a local job platform, Thank Yoıu

    • @peterpann7778
      @peterpann7778 2 года назад +1

      hello there, did this method worked with you,
      selenium keep getting stuck at my end

    • @Mukeshotwani
      @Mukeshotwani  2 года назад

      Awesome Yasin

    • @Mukeshotwani
      @Mukeshotwani  2 года назад

      Hey Peter, what issues you are getting here.

  • @haseebuetian
    @haseebuetian 3 месяца назад +1

    can you please tell me how can I attach this session to one of my profile because I need to enable extension but on the fly it takes time, does it possible?

    • @Mukeshotwani
      @Mukeshotwani  3 месяца назад

      Sorry mate, this I have not tried.

    • @haseebuetian
      @haseebuetian 3 месяца назад

      @@Mukeshotwani thank you so much for your reply. Is that possible that we can run the session with an extension enabled.

  • @Marcus_405
    @Marcus_405 2 года назад

    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

  • @S0UR413
    @S0UR413 3 года назад +1

    Same is possible with IE ?

  • @saidulmolla3477
    @saidulmolla3477 Год назад +1

    Hi bro this code is not working chrome version 117. Could you please help us with this version?

  • @hakanoguz3899
    @hakanoguz3899 2 года назад +1

    awesome . thank you . you are nice man bro. xxxx

  • @shubhamjha5738
    @shubhamjha5738 3 года назад +1

    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?

    • @shubhamjha5738
      @shubhamjha5738 3 года назад

      moreover how to perform this action on linux, as i am a newbie.

    • @Mukeshotwani
      @Mukeshotwani  3 года назад

      Hey Shuham once you open browser using DevTools you can login which will have session active, then you can use the same.

  • @juanjunior99
    @juanjunior99 Год назад

    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

  • @Klightfive
    @Klightfive 2 года назад

    Can this be done in firefox? Not sure if it has the dev tools

  • @sarasjain904
    @sarasjain904 5 месяцев назад +1

    great, it really helps

  • @jiffinraj6796
    @jiffinraj6796 3 месяца назад +1

    if we wanted the same result, but not on the existing tab. but a new tab should open on the already window and execute the script. can anyone help please?

    • @Mukeshotwani
      @Mukeshotwani  3 месяца назад

      Hi Raj, not tried this. You might have to do some R&D here.

  • @ashishb-y7d
    @ashishb-y7d Год назад

    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?

  • @xolaninqubezelo3091
    @xolaninqubezelo3091 Год назад

    Hey Mukesh, can you do the same thing using robotframework?

  • @minatimishra2471
    @minatimishra2471 3 года назад +1

    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.

    • @minatimishra2471
      @minatimishra2471 3 года назад +1

      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"

    • @Mukeshotwani
      @Mukeshotwani  3 года назад +1

      Great Minati thank you for updating.

    • @7355-e4k
      @7355-e4k 3 года назад

      thank you so much

    • @andresgutierrezquintero4921
      @andresgutierrezquintero4921 3 года назад

      Thanks for sharing

  •  3 года назад

    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

  • @amongus-rq2hb
    @amongus-rq2hb 10 месяцев назад +1

    Bro you are a fucking GOAT. no way bro you are the one who saved my life. thankyou so much bhai.

    • @Mukeshotwani
      @Mukeshotwani  10 месяцев назад

      Thank you so much it means alot to me.

  • @mrbaertek
    @mrbaertek 3 года назад +1

    Thanks Mukesh!! Is there a way to use selenium on Chrome with the Chrome extensions already installed?

    • @mrnobody_23
      @mrnobody_23 3 года назад

      just use specific profile where it was installed.

    • @fringeanomaly9284
      @fringeanomaly9284 2 года назад

      @@mrnobody_23 how to?? how to use user profiles where i have already logged in??

  • @fringeanomaly9284
    @fringeanomaly9284 2 года назад +1

    hello sir nicely explained....can u plz explain how to run the session in an already logged in account???

    • @Mukeshotwani
      @Mukeshotwani  2 года назад

      Hi Fringe, it only works with chrome started by CDP commands.

    • @brendanguhle5761
      @brendanguhle5761 2 года назад

      Wondering the same thing as @fringe, can you elaborate a little bit more please?

  • @hoonyur5973
    @hoonyur5973 3 года назад +3

    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!

  • @oliverli9630
    @oliverli9630 2 года назад

    cooool!!! internet rebellion time!

  • @imshaiknasir
    @imshaiknasir 3 года назад +1

    Please create a complete playlist for framework development in selenium-python.

  • @RahmanHaghparast
    @RahmanHaghparast Год назад +1

    It was nice and easy.

  • @malikmoinawan6942
    @malikmoinawan6942 3 года назад +1

    Hey Mukesh ! I wish to make the same process in Firefox. Can you tell me small steps in the comment plz.

    • @Mukeshotwani
      @Mukeshotwani  3 года назад

      Hi Malik, I will try for FF as well if possible.

  • @tofiqrafiq1171
    @tofiqrafiq1171 2 года назад +1

    Nice really appreciated

  • @ninjamoshi5708
    @ninjamoshi5708 2 года назад +1

    how can we change the download director to download files to a specific folder?

    • @Mukeshotwani
      @Mukeshotwani  2 года назад

      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);

    • @ninjamoshi5708
      @ninjamoshi5708 2 года назад

      @@Mukeshotwani hi sir can give an example regarding the same ? like make video or a blog

    • @ninjamoshi5708
      @ninjamoshi5708 2 года назад

      using python

    • @ninjamoshi5708
      @ninjamoshi5708 2 года назад

      also can ou change the download path On Already Opened Browser?

  • @pierremichel-angealexandre4488
    @pierremichel-angealexandre4488 2 года назад +1

    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.

    • @Mukeshotwani
      @Mukeshotwani  2 года назад +1

      Once you close the terminal it will close the session.

    • @pierremichel-angealexandre4488
      @pierremichel-angealexandre4488 2 года назад

      @@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.

  • @JeevanBabu-w6o
    @JeevanBabu-w6o 9 месяцев назад

    In this code I need to manually type the username, password and two factor auth, after that code should run. what to do?

  • @sriramkasu5286
    @sriramkasu5286 3 года назад

    is there any way to open in firefox also in this same method

  • @ANNUETAWAHCRPF
    @ANNUETAWAHCRPF 3 года назад

    sir its showing error
    No pyvenv.cfg file

  • @malyajlikhar5605
    @malyajlikhar5605 Год назад

    Any Idea how do we remote debug from a host computer to remote computer using webdriver.Remote(command_executer=:port) instead of webdriver.Chrome()

  • @joaoteixeira6982
    @joaoteixeira6982 2 года назад

    fantastic!! how could i use remote debugging with proxy ?

  • @gowthambalu1932
    @gowthambalu1932 3 года назад +1

    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

    • @Mukeshotwani
      @Mukeshotwani  3 года назад

      Hi Gowtham, you can start default user profile.

    • @gowthambalu1932
      @gowthambalu1932 3 года назад

      @@Mukeshotwani can you guide me how

  • @pramodkumarmohapatra9152
    @pramodkumarmohapatra9152 3 года назад

    Thanks for the new learning

  • @beastgamer7903
    @beastgamer7903 Год назад +1

    Not working for selenium 4. Is there any solution for this problem in selenium 4?

    • @NayyarAbbas-sh1vw
      @NayyarAbbas-sh1vw 10 месяцев назад +1

      For selenium 4.10.0+
      executable_path was removed and need to use a service
      from selenium.webdriver.chrome.service import Service
      service = Service(executable_path='./chromedriver.exe')
      options = webdriver.ChromeOptions()
      driver = webdriver.Chrome(service=service, options=options)
      ^if you make the above changes it will work

    • @beastgamer7903
      @beastgamer7903 10 месяцев назад

      @@NayyarAbbas-sh1vw thanks dude I will try it out

  • @lamechtennyLT
    @lamechtennyLT 3 года назад

    for firefox
    what i have to do bro

  • @aps8511
    @aps8511 Год назад +1

    thanks man it worked!

    • @Mukeshotwani
      @Mukeshotwani  Год назад

      You're welcome! Cheers

    • @whozproxy
      @whozproxy Год назад

      I can't get it working, Nothing is happening in the browser.

  • @zrlcproject
    @zrlcproject 2 года назад

    can i use headless mode?

  • @GQCodes
    @GQCodes 2 года назад +1

    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.

  • @krishnachaitanya836
    @krishnachaitanya836 3 года назад

    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

  • @ANNUETAWAHCRPF
    @ANNUETAWAHCRPF 3 года назад

    sir please make a video same for Internet Explorer,

  • @danielerikschaconbaquerizo2957
    @danielerikschaconbaquerizo2957 3 года назад +2

    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!

    • @azkymohamed123
      @azkymohamed123 3 года назад

      did you solve this? Getting the same error.

    • @KanYatKin
      @KanYatKin 3 года назад

      im getting the same error too

    • @IIT_sarcasm
      @IIT_sarcasm 3 года назад

      did your problem slove? can you give source code?

  • @galaxyslayers3335
    @galaxyslayers3335 2 года назад

    thanks for this tutorial , this can it run with firefox

  • @veenaysingh8027
    @veenaysingh8027 2 года назад +1

    hello sir, Can we run this code on multiple open drivers?

    • @Mukeshotwani
      @Mukeshotwani  2 года назад +1

      Hi Veenay it works on specific browser with port.

    • @veenaysingh8027
      @veenaysingh8027 2 года назад

      @@Mukeshotwani Ok thank you so much, I'll mail you regarding one small query if you can help.

  • @채신욱
    @채신욱 Год назад

    Is there other way to connect already opened browser without using remote debugging port? 🤔

  • @canercevik6406
    @canercevik6406 3 года назад +1

    Does it work on mac as well ?

  • @hirenpanchal971
    @hirenpanchal971 2 года назад

    Hello Sir, How to achieve this in macbook? Can you please guide me.

  • @arkahazra4334
    @arkahazra4334 2 года назад +1

    Can we able to do it in Robot Framework

    • @arkahazra4334
      @arkahazra4334 2 года назад +1

      Egerly waiting for your reply

    • @Mukeshotwani
      @Mukeshotwani  2 года назад

      Hi Arka, why not.Initial steps are same then we need to pass desired capability robotframework.org/SeleniumLibrary/SeleniumLibrary.html#Open%20Browser

  • @abrarahmeda8989
    @abrarahmeda8989 2 года назад

    How to do this in firefox browser as experimental_option debuggerAddress is not present. If anyone know help me out...

  • @lewisbaker-o9b
    @lewisbaker-o9b Год назад

    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

  • @saidhanushlalam4786
    @saidhanushlalam4786 3 года назад

    Can you do the tutorial in robotframework?
    this tutorial is lit

  • @aadeshgurav905
    @aadeshgurav905 3 года назад +1

    thankyou
    others had java n shit
    but I love Python

  • @vishnuvardhan4093
    @vishnuvardhan4093 2 года назад

    can we open another tab in this existing window

    • @vishnuvardhan4093
      @vishnuvardhan4093 2 года назад

      i tried with driver.execute_scripts("window.open();"), but didn't work

  • @dineshjangra7413
    @dineshjangra7413 Год назад

    how to achieve this thing for edge

  • @akcandlestick8948
    @akcandlestick8948 2 года назад

    sir but without command proamt how can we use

  • @darkrain5562
    @darkrain5562 3 года назад

    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 ??

  • @zbmadon
    @zbmadon 3 года назад

    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

  • @ishasaikumar868
    @ishasaikumar868 3 года назад +1

    How to do this on Javascript :(
    ?

  • @danielhadziosmanovic3240
    @danielhadziosmanovic3240 3 года назад

    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

  • @shubhamjha5541
    @shubhamjha5541 2 года назад

    how to setup this for mac

  • @TheJJSIL
    @TheJJSIL 2 года назад +1

    Tks from Brasil!! o/

  • @mohitpannu27
    @mohitpannu27 3 года назад +1

    sir how we can do this same with mozilla firefox??

  • @mrnobody_23
    @mrnobody_23 3 года назад +1

    nice 👍

  • @IIT_sarcasm
    @IIT_sarcasm 3 года назад

    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)'''

  • @nancygupta9293
    @nancygupta9293 2 года назад +1

    How to do it for Edge?

    • @Mukeshotwani
      @Mukeshotwani  2 года назад

      Hi Nancy, you can start edge as well in cdp mode and follow the current video.

    • @nancygupta9293
      @nancygupta9293 2 года назад

      @@Mukeshotwani but edge options doesn’t have the function to add experimental options