Python Selenium Tutorial - Automate Websites and Create Bots

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

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

  • @MohammedSalah2405
    @MohammedSalah2405 3 месяца назад +66

    What makes me feel suspecious about the comments is that I hardly find anyone facing an issue, while if you're following the same steps you WILL definitely face issues with the code. But the comments section is full of angels

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

      I'm sure they are not real people

    • @Make-Money-Online74
      @Make-Money-Online74 3 месяца назад +9

      For your kind information, most people watch this to just have an overview of how it works. For development docs are available officially

    • @ransom2156
      @ransom2156 Месяц назад +2

      just like the video, theyre all bot

    • @Tiwad
      @Tiwad Месяц назад +2

      this tutorial is just outdated. It worked at the time, but selenium updated their library, changing a bunch of things

  • @AsuGhimire
    @AsuGhimire 10 месяцев назад +4

    DUDE I NEEDED THIS AND YOU JUS UPLOADED IT XD

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

    Somewhy, when I run the ''python main.py'' command in terminal, I don't get anything, chrome doesn't start, nothing happens, at all.

  • @soufinator3631
    @soufinator3631 Месяц назад

    Every time I execute my code, Chrome shows the message that I need to select a browser to set as default, I already did that and made sure to re-do it just for the issue to remain, any solutions?

    • @abiodunjohn9790
      @abiodunjohn9790 Месяц назад +1

      set argument option to "--disable-search-engine-choice-screen"

    • @soufinator3631
      @soufinator3631 Месяц назад

      @@abiodunjohn9790 Thanks a lot, I can't tell you how many hours I spent trying to figure this out lol

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

    Which vs code theme do u use?

  • @emperor8716
    @emperor8716 7 месяцев назад

    3:20

  • @HebbenBeeld
    @HebbenBeeld 10 месяцев назад +40

    @28:50 If you want to go straight to the html element in inspection (here: the number of cookies), click on the arrow in the dotted square at the top left corner of the inspection window (it'll turn blue) and then click on the element on the webpage you want to find in the html. The inspection window will then take you straight to the html where the element is at.
    Having said that: great video!

  • @MrIncredible-mu5ec
    @MrIncredible-mu5ec 10 месяцев назад +39

    One question still remains: how to upload Selenium to a remote server and run it? For me, it's #1 reason why I try to avoid using Selenium.

    • @architech5940
      @architech5940 10 месяцев назад +12

      Create an API for your selenium script and host it on a linode instance. There are tutorials for both.

    • @moumnalmunawy1806
      @moumnalmunawy1806 10 месяцев назад +2

      So what do you use?

    • @gustavojuantorena
      @gustavojuantorena 10 месяцев назад +2

      You can use a docker container. There is containers with selenium already installed.

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

      Look at AWS CloudWatch Synthetics. It can use selenium and save the screenshots, run on a schedule and alert you if the tests start failing.

    • @ikennamanagwu9646
      @ikennamanagwu9646 9 месяцев назад +1

      Using a Linux server is doable but much more complex

  • @doug8487
    @doug8487 7 месяцев назад +6

    Hopefully this helps someone, I was having issues around 28:24 and getting the following error: "Message: stale element reference: stale element not found".
    This seemed to be because the page would load after clicking the language?
    I added time.sleep(5) to the line before finding the cookie and it solved the error. I'm not sure why the WebDriverWait function wasn't working as intended though, I'm assuming it was finding the cookie after the language was pressed but due to the loading screen popping up, Selenium ended up losing the cookie and errored out?

    • @andyliu4890
      @andyliu4890 6 месяцев назад

      that worked for me!

  • @ViralKiller
    @ViralKiller 3 дня назад

    What about an actual robotic mouse mover and clicker... impossible to detect a bot then...hardly high tech would work like a 3d printer nozzle

  • @dfsed1057
    @dfsed1057 10 месяцев назад +19

    Love your tutorials. I use xpath quite often when trying to find what to click on. In chrome, when you right click and inspect an element, it brings up the page source. Then if you right click the item that you are looking for, you can copy the xpath and paste it in your program as well.

  • @thembekilethembekile5839
    @thembekilethembekile5839 7 месяцев назад +20

    It’s been years now and you still manage to release content when I need it the most. You just clutch dude ❤

  • @mishkathossain2984
    @mishkathossain2984 8 месяцев назад +2

    Hey this is paid stuff right?? Bright data is paid. I can't do it do it for free.

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

      No the web driver and everything else is free

  • @luisfcocontreras
    @luisfcocontreras 10 месяцев назад +9

    You should do an updated selenium series 🔥 would love that, some automation testing for things like SDET or QA

  • @kivala1695
    @kivala1695 4 месяца назад +1

    if you run into COOKIE pop up issue that has to be accepted watch the video from 18:14

  • @spazztik
    @spazztik 7 месяцев назад +15

    Been trying to figure out this for the last 2 days and could only find outdated and irrelevant videos. This video was really what i needed and even more. Props to you bro!

    • @jeeadvanced4719
      @jeeadvanced4719 7 месяцев назад

      Bro what you trying automate?

    • @AshokanandChaudhary786
      @AshokanandChaudhary786 7 месяцев назад

      Have you found more videos about the slenium?

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

      When I search YT or Google I always set my search to find stuff in the last year only.

  • @artabra1019
    @artabra1019 9 месяцев назад +8

    Thanks for your selenium tutorials I have made 20k$ earnings as freelancer web scraping in Upwork.

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

      علمني معك اريد ان اربح معك 20 الف دولار اخي

  • @phaedrus2633
    @phaedrus2633 10 месяцев назад +8

    You go way too fast for this 65-year-old brain, but I understand, a slower pace would be boring for young programmers. But for the first time, I have a handle about the concepts of web scraping. You are using the Selenium Python library to bot web surfing. Too cool!

    • @Alien-by3gb
      @Alien-by3gb 2 месяца назад

      If u 65 why u coding?

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

      @@Alien-by3gb It's a hobby of mine, ever since PCs hit the market. I remember when Apple IIs were the rage. I've been messing around with programming ever since.

  • @mihaiciobanu-v6i
    @mihaiciobanu-v6i 7 месяцев назад +4

    Is no one else getting ElementNotInteractableException: Message: element not interactable?

    • @pathetic-f3h
      @pathetic-f3h Месяц назад

      I had same issue when testing Google, I suppose because of another window covering search bar. I switched to another browser like DuckDuckGo and code worked.

  • @LuKaS2oo9
    @LuKaS2oo9 12 дней назад +1

    10:30 get_element is deprecated. Now it's called find_element

  • @mahapeyuw5946
    @mahapeyuw5946 7 месяцев назад +4

    service=service didn't run. It gave me a traceback error.

  • @MelTrades
    @MelTrades 9 месяцев назад +2

    Hey Tim how do i fix it if chrome driver is 120.0.6099.62 but mine is 120.0.6099.63

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

    hi Im getting this error when trying to install chrome driver,
    Google-Edge-Cache: forbidden
    Error: 7
    please help me with it

  • @Agnarr_Valhalla
    @Agnarr_Valhalla 7 месяцев назад +2

    What do i do if chroome cookies consent block me from doing anything ?

    • @Agnarr_Valhalla
      @Agnarr_Valhalla 6 месяцев назад

      Btw i solved it myself, u search by xpath instead of class. You input the declines button xpath and then also a time.sleep(2) so the cookies have time to load properly

  • @jaschyns
    @jaschyns 6 месяцев назад +1

    I dont know where my selenium folder is man, i installed it through Pycharm.. dont know the default location.

  • @makobobinzers
    @makobobinzers 4 месяца назад +2

    is there a free alternative to brightdata?

  • @jocois
    @jocois 7 месяцев назад +2

    Does anyone know how to have the browser open with the default account? Mine always opens without it and its an issue, especially with SSO.

  • @memeshouse8621
    @memeshouse8621 7 месяцев назад +1

    when try to login into gmail it says "could nkt sing in , browser not secure" how to solved it?

  • @adesinapsalmlord7305
    @adesinapsalmlord7305 9 месяцев назад +5

    I really love Tim tutorial for it conciseness and Simplicity
    Thanks for always serving us the best

  • @user-wu4ip7mp3z
    @user-wu4ip7mp3z 5 месяцев назад +1

    Just a question, instead of waiting for 5seconds for the elements to exist. Can you implement some kind of a loop to keep searching for the element until they do exist?
    Would this best be done with a while loop, and what would it look like?

  • @fernandomartino4708
    @fernandomartino4708 10 месяцев назад +2

    Hi, Tim. Wouldn't be easier to use webdriver_manager library where it gets the last version of the driver to match the browser you have installed? because everytime you have a version upload you have to download it and retest this?

  • @pravachanreal
    @pravachanreal 6 месяцев назад +1

    Fucking Great Video My Man, I have been getting errors everytime when i try to get the selenium working...
    after watching this video i solved my problem and its workingggg.

  • @joshuawiley6506
    @joshuawiley6506 9 месяцев назад +1

    Hi there, I'm having a major issues with my paths, I've added the driver to the PATH, I've pinpointed it specifically using an exact path, and a local path...still, it doesn't find the chrome driver.
    Message: unknown error: cannot find Chrome binary
    Stacktrace:
    It's been plaguing me and stopping my progress on every tutorial....please help! Thanks!

  • @rudyruderabbit
    @rudyruderabbit 6 месяцев назад +1

    nothing is happening when i try run google. i dont see selenium on the top left as you have, but it was innstalled...im stuck

  • @ParziNguyen
    @ParziNguyen Месяц назад

    How to be undetectable, especially when we scrape small data from < 10 videos from Tiktok? Can anyone help me?

  • @yassinehsouna5425
    @yassinehsouna5425 7 месяцев назад +1

    i cant find the same version of the webdriver

  • @diegoho4885
    @diegoho4885 2 месяца назад

    I can't use the driver since my Mac displays an error saying it can't verify that this app is free from malware. Has anyone had that issue?

  • @tilltheend6634
    @tilltheend6634 9 месяцев назад +2

    how to disable the pop up page asking to refuse or accept the chart please

    • @tilltheend6634
      @tilltheend6634 9 месяцев назад +1

      great video btw

    • @marcmuehleisen
      @marcmuehleisen 9 месяцев назад +1

      @@tilltheend6634 weird that tim still did not answer this as lots of ppl had this question already

    • @tilltheend6634
      @tilltheend6634 9 месяцев назад

      @@marcmuehleisen i had the solution once with chatgpt

    • @marcmuehleisen
      @marcmuehleisen 9 месяцев назад

      What did you ask?

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

    Merci pour tes supers vidéos ! Voici un post à venir qui pourraient intéresser plusieurs abonnés et autres, c'est le fait de pouvoir trouver comment cliquer sur les choix de demandes de consentements comme sur le site Mappy, qui contient une masse d'infos de Pros et surtout leur email..., ais il y a des fenêtres qui sont bloquantes et difficiles à contourner ("Accepter & Fermer" + "Continuer sans accepter" + "Connexion" ...), merci pour ton écoute? Roby

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

    It's a little disappointing knowing how difficult it is to avoid detection and all the extra steps you have to take. I have to login to our work website once a day to check some boxes, so I wanted to just automate that boring task and was excited about figuring it out, but now knowing I'll probably get blocked for being a bot really took the wind out of my sails lol great video tho. I'm sure I'll use this information... Somehow.

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

      Not really… build showcase it as flaw in the system to the hr

    • @dominusdone5023
      @dominusdone5023 Месяц назад

      do you have to do it on a large scale? Can you just use pyautogui instead?

  • @bogart047
    @bogart047 2 месяца назад

    if you would use normal IDE like PyCharm, you never met attr errors

  • @Chrrvn
    @Chrrvn 11 дней назад

    Selenium just removed this get element method in version 4.3.0

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

    It doesn't work for me :( , after launching the browser I see info about accepting or rejecting cookies and I can't get to the search element .Error > selenium.common.exceptions.ElementNotInteractableException: message: element not interactable

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

      this will happen when a popup window blocks the element that is trying to be clicked. i think he had the similar thing when the language popup occured for example.

  • @Warley.Araujo
    @Warley.Araujo 13 дней назад

    Great Video Tim, Thanks for Sharing!!

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

    I know that this may be asking for a lot, but could you make a tutorial on how to run parallel testing with selenium and pytest? Or whichever other tools you think are better for running multiple test cases at once?

  • @fromage7695
    @fromage7695 9 дней назад

    Great tutorial, clear and to the point. Thanks!

  • @py_world
    @py_world 6 месяцев назад

    I would like to do this with brave browser which is also based on chromium,
    chromium version my brave instance is 122 while the downloaded version of the chrome driver is 123, I am unable to get driver version 122 nor am I able to update the brave browser. (win64)

  • @jakemcardle1936
    @jakemcardle1936 5 месяцев назад

    I'm having an issue at 11.05 when google opens I get a pop-up asking to accept/decline cookies, because of this "the tech with tim" doesn't get inputted, instead the window with google closes immediately. Do you know how I can stop that pop-up from showing?

    • @Tortexxxx
      @Tortexxxx 2 месяца назад

      Did u get answer?

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

    thank you

  • @cristianionut9885
    @cristianionut9885 9 месяцев назад

    Hello. I am a beginner and I use VSC as well. For some reasons, when I run the exactly same code you typed, it opens my chromedriver without accessing the link. Why is that?

  • @SatoOnAir
    @SatoOnAir 2 месяца назад

    Guys why is the "stale element not found" error automatically fixed itself? I meet this bug muptile times and dont know why it can fix itself everytime i rerun the program

  • @Tortexxxx
    @Tortexxxx 2 месяца назад

    How u disabled asking about cookies?

  • @FlockofSmeagles
    @FlockofSmeagles 6 месяцев назад

    I'm wanting to run a bot for an agency that my wife works for. Urgent shifts pop up fairly often. But, from what I suspect. Someone else is running a bot and snapping them up before she can get to them. I'd like to combat that, but there's no way to be sure. What I'm wanting to know is if there any way to detect whether or not the agency can detect bot activity. Since her ID is connected to the account. I won't be able to just spoof my IP.
    Any help would be appreciated.

  • @Hotshot24-7
    @Hotshot24-7 2 месяца назад

    What’s the point of creating the service object if when you create the driver object the browser still opens when running the code from the IDE?

  • @leongbk7107
    @leongbk7107 Месяц назад

    Excellent! Thank you very much for making and sharing this video.
    Great help!

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

    Thanks, but my Mac mini won;t let me run that file!

  • @sajidghanchi7591
    @sajidghanchi7591 4 месяца назад

    Hey can someone please help me I am desperately looking to resolve this issue. I want to perform the same task but in my regular chrome browser instead of testing browser. Will it be possible? If yes then how?

  • @Strawberry00562
    @Strawberry00562 Месяц назад

    thanks for video and git link 😘😘😘😘

  • @alchris2978
    @alchris2978 26 дней назад

    I keep getting an error on the service line (line 6):
    driver = webdriver.Chrome(service=Service(executable_path =chrome_driver_path), options=options)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    TypeError: 'module' object is not callable

    • @alexlh_h
      @alexlh_h 22 дня назад

      chrome_driver_path you need to change that

    • @alchris2978
      @alchris2978 20 дней назад

      @@alexlh_h Thank you. That wasn't the problem. I figured it out about an hour later.
      I messed up an import.
      I did import this as that, instead of from this import that.
      Five years in and still making these silly mistakes 🐸

  • @samson6707
    @samson6707 7 месяцев назад

    not sure why you do this extra step of downloading a webdriver and including it with Service instead of just using webdriver Chrome without the service parameter

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

    is it possible to make a robot that monitor a website name BLS international visa embacy and robot notify me when appointment date are available???

  • @REALANSHUMAN
    @REALANSHUMAN 5 месяцев назад

    hello sir , i have no experience of coding . how can i learn to make automation bots or integrating api (i dont know what this is but it pays good on upwork ) ? how long do i need to learn it ? I need to come up with money by the end of july for my moms surgery

  • @tallyhoswilly_4973
    @tallyhoswilly_4973 2 месяца назад

    I'm having a hard time installing selenium. I can't figure out and I have python path and extension installed.

    • @tallyhoswilly_4973
      @tallyhoswilly_4973 2 месяца назад

      Ok update i have it installed however... now im have a hard time to run the script to open google

  • @justgoto8
    @justgoto8 6 месяцев назад

    one thing I'll add in here, you need to open the driver before selenium can actually use it. I was getting errors of selenium not being able to find the driver even though my route was correct. as soon as a double clicked on the driver file and opened it, selenium was able to open the browser. I use MAC

  • @jaouadbenji7088
    @jaouadbenji7088 2 месяца назад

    Help : when i try to click on a element the browser just closed and the programme stops

  • @jdoublea2023
    @jdoublea2023 5 месяцев назад

    Just wondering if anyone else has been trying to get past the collect data popup that appears when you directly open google using this method I cant interact with the search bar

  • @FatihMumtaz-tt5to
    @FatihMumtaz-tt5to 3 месяца назад

    if i have do it and nothing changes , what's wrong??? its not opened the chrome.....

  • @vascomarques2380
    @vascomarques2380 9 месяцев назад +2

    LETS GO, UPDATED VIDEOOO

  • @itstechshow7747
    @itstechshow7747 10 месяцев назад +2

    You are a genius 🔥
    Your effort is remarkable ❤

  • @shreyaschavan7976
    @shreyaschavan7976 9 месяцев назад +1

    can't we just use 'from selenium import * '?

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

    I came to look for copper and I found gold. thanks for the video. you saved me. I hate pychar. I love vsc.

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

    hey some one help me i try to make my router restart using this libarary but it wont work it stuck and show error while confirmation windos not popup and i try everything but it wont work why ?/ any soluction for this

  • @alimihakeem841
    @alimihakeem841 2 месяца назад

    Thanks for this great content. I love the way you explained in details

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

    great!!, thanks for the tutorial just what i needed

  • @hurleytom
    @hurleytom 2 дня назад

    I had to add the following after driver.get() to get the cookies pop-up to be dismissed everytime:
    # Wait for the cookie pop-up and accept it
    try:
    accept_cookies_button = WebDriverWait(driver, 10).until(
    EC.element_to_be_clickable((By.XPATH, "//button[.//div[text()='Accept all']]"))
    )
    accept_cookies_button.click() # Click the "Accept all" button
    except Exception as e:
    print("No cookie pop-up found or timed out:", e)

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

    Do I have to update the chrome driver every time Google updates actual Chrome?

  • @johnmantzanis1213
    @johnmantzanis1213 5 месяцев назад

    what if the ID and class names are changing every time you log in to the website?

  • @shawntiaw
    @shawntiaw 7 месяцев назад

    Hi Tech With Tim, i follow your tutorial and it works super fine! learn some basic from you but i encounter some issue. how to use if and else if i want a button to be clickable. if not clickable then auto refresh until it become clickable?

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

    Great one, this is what i'm looking for, Automation, web scraping, bots, pytho automation, Qa automation.. Thank you so much. You are amazing.

  • @liamfleming4220
    @liamfleming4220 Месяц назад

    As soon as I open up the editor there's no tab for selenium.....

  • @vinodvyash3866
    @vinodvyash3866 Месяц назад

    Your VScode theme name?

  • @goldcandles
    @goldcandles 4 месяца назад

    Can i make option with bot doing order according to telegram channel

  • @jenelynsambayon4324
    @jenelynsambayon4324 Месяц назад

    just a question. Can i use this bot to make shein new user in shein games ?

  • @DylanWoods-kw6km
    @DylanWoods-kw6km 3 месяца назад

    IF IT DOES NOT WORK 100% CHECK CAPITALIZATION

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

    I feel nostalgic, I remember watching your selenium series a few years ago

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

    You are the BEST

  • @kayoutube690
    @kayoutube690 4 месяца назад

    Is this working if the app is saml integrated??

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

    can someone tell me where he got the class gLFyf because i didnt see it

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

    tim whats your vs code settings for syntax colors I've tried some methods but none of them was working for example (ctrl + K + T) can you make a video about that or if you already have one tag me please

  • @bisyrim1030
    @bisyrim1030 9 месяцев назад

    also you can use driver.implicity_wait(10) instead of time.sleep(10)

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

    Does selenium still need us to install the drivers, i thought its now installed with the selenium 4.10

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

    Спасибо за подробный разбор, новая связка на отлично. Два круга, все сработало!

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

    Thanks Tim bro😊😊😊

  • @sa34w
    @sa34w Месяц назад

    This is a video made by a bot made for a bot😂

  • @melisbas190
    @melisbas190 4 месяца назад

    I have the issue with pip install selenium. It always gives command not found error .

    • @JohnWickXD
      @JohnWickXD 4 месяца назад

      Then that means you have to install pip first! But even before that check if python is installed on your pc or not by typing:
      python --version
      On your cmd/ terminal

  • @Kiraa478
    @Kiraa478 4 месяца назад

    Can i do this for automate an telegram bot? Please if somebody can fast reply me. Thanks.

    • @jacknoob8875
      @jacknoob8875 2 месяца назад

      Есть другие библиотека для этого просто найди туториал для телеграм бота

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

    Hi Tim, thanks so much for putting the tutorial out there. I noticed that when I typed in executable_path, it gave me an error message (unresolved reference) for some reason?

    • @doug8487
      @doug8487 7 месяцев назад

      Did you put chromedriver.exe in the same folder as your .py file?

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

    Excellent lesson thanks for explaining each step

  • @EzraKoenigsberg-hn9pk
    @EzraKoenigsberg-hn9pk 4 месяца назад

    Great video! Been looking for something that explains this process for a while.

  • @KuzeyÖZÇEVİK-v3w
    @KuzeyÖZÇEVİK-v3w 8 месяцев назад

    You started to go faster and i losted you in 33:30