Python Selenium Tutorial #4 - ActionChains & Automating Cookie Clicker!

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

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

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

    Dude is someone still watching these videos? this guy is real good!

  • @seatownrocks
    @seatownrocks Год назад +8

    I believe the explanation of implicit wait at 5:44 is incorrect. You say the line will not be passed for 5 seconds but I believe what is actually happening is you are setting a global setting to wait up to 5 seconds whenever anything you are are looking for does not yet exist. Great videos, thanks for making them!

    • @Henry-sv3wv
      @Henry-sv3wv Год назад

      Yes, he set driver to find stuff within 5 seconds or throw an exception.

  • @alixaprodev
    @alixaprodev 4 года назад +18

    Thanks man for such an amazing tutorials. your style of teaching is just like Corey Schafer one of my best teacher ever.

  • @rafaelboisel5609
    @rafaelboisel5609 4 года назад +23

    I literally made the same project 2 weeks ago, it’s a fun little one. Great job nonetheless !

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

    Tim a little tip When you Don't find the element 4:25 aprox. Try to go the arrow on the top left of the inspect window. It should work

  • @smitamaheshwari1377
    @smitamaheshwari1377 4 года назад +57

    The pyautogui module can be used in order to not get banned by websites.

    • @Sk_-vu6dv
      @Sk_-vu6dv 4 года назад

      Pls tell how

    • @smitamaheshwari1377
      @smitamaheshwari1377 4 года назад +13

      @@Sk_-vu6dv Let's imagine you are playing a click game on a website (the most number of kills win), if you use selenium you will get banned because the website can detect a use of bot. But pyautogui module sends key inputs, mouse presses making it seem that there is no bot running but a normal user is sending those clicks. Thus, you will break the game.

    • @Sk_-vu6dv
      @Sk_-vu6dv 4 года назад

      @@smitamaheshwari1377 Oh okay , thats cool actually i didnt know what pyautogui exactly does , thanks for the info

    • @smitamaheshwari1377
      @smitamaheshwari1377 4 года назад +2

      @Blessed People! I don't really think so. I have never experienced speed problems with pyautogui however pyautogui can be messy sometimes.

    • @thaprophet9617
      @thaprophet9617 4 года назад +8

      Yes pyautogui works really well. If you are trying to make a bot that runs on your computer, then pyautogui is definitely the way to go. I use selenium for off computer navigating where you want it to run on a server.

  • @baltazarkun
    @baltazarkun 3 года назад +43

    "if we have a 100 cookies, I'd like to do grandma"

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

      When Tim said that, I immediately got in comments to check if someone noticed that xD

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

      @@ante1708 just what I did too. 😄

  • @a.yashwanth
    @a.yashwanth 4 года назад +4

    Use clipboard history built into windows win+v instead of struggling to copy and paste multiple items. It's so useful.

    • @ktcnoletterc
      @ktcnoletterc 4 года назад

      could you explain more? Thank you!

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

    that was pretty straight forward for you to say "For any of my tut, i simply go through the docs itself" ik you meant the brush up before every tut but still. Anyway I really liked your tuts -simple, easy and precise.

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

    you don't need the sentence move_to_element, if you say directly upgrade_actions.click(item) it works just fine... And you have another mistake, when checking if the cookie_count value es greater than some upgrade, as it loops over the two items it buys the cheapest always and never gets to the most expensive, regardless the position in the list, but as you said, this tutorial was not about making a perfect cookie clicker script, it was to show us the functioning of the ActionChains, and that I must say you did indeed sir, great video

  • @khushaalnandwani3372
    @khushaalnandwani3372 3 года назад +5

    you explain so well! and all the things you taught I can implement in my project which i find rare (me being a beginner), thanks a lot man. Respect.

  • @andrewv8548
    @andrewv8548 4 года назад +31

    Hey Tim, I think the glitch was caused by the ',' in the price of the item: "1,100" instead of just "1100"

    • @barbadose
      @barbadose 4 года назад +13

      ye, just add a cookie_count.replace(",", "")

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

      @@barbadose but it is saying web element has no attribute replace

    • @KING-zz6qt
      @KING-zz6qt 3 года назад +4

      @@sudhanshudey758 you need to say cookie_count.text.replace(",", "")

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

      totally right

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

    Thanks for making me the best player at this game!

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

    Just am in love with your style of teaching and materials!!! Amazing!!! Wow...!!!

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

    Very nice tutorial. Useful thing would be to add some random sleep (0.1-0.3 sec) between clicks against detection.

  • @universezone
    @universezone 4 года назад

    I tried and double_click instead of click, it works perfectly

  • @ZbigniewLoboda
    @ZbigniewLoboda 14 дней назад


    An excellent and highly informative tutorial.

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

    Can't wait for more tutorials :) Great job!

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

    HI, Sir. I run the same code, but it raises staleelementreferenceexception for the actions.perform( ) command, and sometimes it just click the cookie once. What is the reason? Thanks

  • @ChocolateMilkCultLeader
    @ChocolateMilkCultLeader 3 года назад +15

    Funny that Tim shows his hands off the mouse, but never his feet. He's definitely just using feet mouse

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

    Sitting through your Ads, cos you deserve it!!

  • @karimeino3949
    @karimeino3949 2 года назад +34

    Thanks a lot Tim for the easy way, i have something really weird, when I use this part of the code
    actions = ActionChains(browser)
    actions.click(cookie)
    for i in range(1000):
    actions.perform()
    it perform only 1 click
    when i change it to
    for i in range(1000):
    actions = ActionChains(browser)
    actions.click(cookie)
    actions.perform()
    it works great, dose any one can help in that?

  • @salmaofinlandes6793
    @salmaofinlandes6793 4 года назад +1

    The video was really good as always. Just a suggestion: don't use implicitly wait. Instead you can use explicitly wait which allows the browser to wait until a certain condition occurs (selenium-python.readthedocs.io/waits.html). Sorry for the bad english.

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

    Hi Tim, i just realized that using an opened browser from command line(using a .bat file) makes selenium much faster on low end computers like mine. i would like to share some videos later just like you

  • @mrpancakes
    @mrpancakes 4 года назад +2

    I hope you will make a playlist for this. I’ll watch this series once it’s complete

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

    Hey man not sure if you read the comments but just from these 4 videos I automated checking a website if someone had cancelled their appointment and to text me if that appointment is sooner than the existing available date.

  • @a.yashwanth
    @a.yashwanth 4 года назад +3

    you could've created and stored the actions in a list beforehand(as there are only a few) and just call them in the "for I in range(5000)" instead of creating them over and over again.

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

    help, when I try item.text the program give me this error: AttributeError: 'list' object has no attribute 'text'
    how can I fix it????

  • @kahpeproductions1221
    @kahpeproductions1221 4 года назад

    Man wish this came out 2013 when Cookie clicker was LIFE

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

    Hey Tim, Thank you so much for the tutorial!

  • @y66-s3m
    @y66-s3m 4 года назад +2

    im in love with your voice!!🤩🤩🤩 you could easily voice for an animation

  • @nataliiasorokina4485
    @nataliiasorokina4485 4 года назад

    Thanks! Please continue!

  • @casualcasual1234
    @casualcasual1234 4 года назад +2

    At 11:25, why need to first move to element then click? Can't I just click(item)? Thanks

  • @KaueS.Hoffmann-Ethos
    @KaueS.Hoffmann-Ethos 9 месяцев назад

    I had to start laughing when my coworkers saw me with cookie cliker in the screen, and questioned me about playing games in worktime.

  • @ramizquliyev394
    @ramizquliyev394 4 года назад

    Thanks for one more great Tutorial

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

    Is the try block and implicitly_wait function the same? can we just alternate between them?

  • @johni7609
    @johni7609 4 года назад

    Thank u so much bro im making 9 billion cookies a second now

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

    Hopefully you will come back to this series one day :/

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

    Super! It's a kind of magic...

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

    I have a question, so as you said i may get IP banned. Can I use a proxy to avoid that?
    Also, let's say I live Europe and I wanna bot a website that's based in the US. Do I need to use a server to speed up the process, (with the proxy to change my ip) for example AWS or Google cloud or whatever? Or is the proxy sufficient?

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

    How do other websites detect bots?
    How easily can other websites detect a bot?
    Just discovered your channel, BIG thumbs up!

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

    Tim, you're awesome!

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

    Thanks for the great vids.

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

    got hooked onto the game instead 🤣

  • @nowyouknow2249
    @nowyouknow2249 4 года назад

    Nice one Tim!
    👍✌️

  • @danielmarx3106
    @danielmarx3106 4 года назад +2

    I use time.sleep() over driver.implicitly_wait(). Is one better to use then the other?

  • @deepanshuchg
    @deepanshuchg 4 года назад +7

    Another question- Why is `.move_to_element` required? Can't we simply use .click function like you were doing in earlier tutorials?

    • @a.yashwanth
      @a.yashwanth 4 года назад +1

      how does the program know where to click without telling it?

    • @zeranderman4170
      @zeranderman4170 4 года назад

      @@a.yashwanth it was already said when he type the id from where to click in ...=driver.find_element_by_id(id) for example

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

    to remove glitch just do cookie_count.text.split(" ")[0].replace(" , " , "")

  • @pillowrabbit8324
    @pillowrabbit8324 4 года назад

    the voice of yours is so charming

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

    Line 14, i'm getting an error 'no such element: unable to locate element'. I typed "productPrice" as Tim did. The actual element ID is 'product price 0' but why isn't it typed as such?

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

    what's the difference between waiting with implicite wait or time.sleep() ? in both cases we won't pass that line until that duration we specified is over and the website is opened

  • @shouryagupta7624
    @shouryagupta7624 4 года назад

    Waitiingg for your series on data structures and algorithms. When will it going to start??

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

    I am trying to follow this, but when my browser opens the page I have to select a language, got that sorted, but now I can't figure out how to have it start clicking on the cookie. Any ideas?

  • @akshatsingh7286
    @akshatsingh7286 4 года назад

    In the next vid pls briefly explain div and other html tags required

  • @gloryness
    @gloryness 4 года назад +1

    Thank you tim for these great videos >:)

  • @andrewwoan
    @andrewwoan 4 года назад

    woahh thats awesome

  • @youvanced6593
    @youvanced6593 4 года назад +4

    Hi Tim, great video. I don't understand the purpose of action chains, how is using them different from writing a regular function with all the things i want the web element to do?

  • @tp890
    @tp890 4 года назад +1

    How do I make it upgrade the further upgrades as well? If I change the "for i in range(1,-1,-1) to (2,-1,-1) it gives me an invalid int error.

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

      Idk if you still need it but what he put should upgrade the farther ones as well. It’s just counting backwards from the highest number until it gets to the beginning. So when a new higher one is unlocked it counts that as well

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

    Thank you! I wonder how can I speed up the clicking? Like clicking 100 times a second

  • @טוביהיגלניק
    @טוביהיגלניק 3 года назад

    You are good, bro

  • @casualcasual1234
    @casualcasual1234 4 года назад

    hello, if there are different ID instead of producePrice0, 1, 2..., what should I type if I want the automation to behave as the video shows? (from the highest possible cost of items)

  • @redaakherfi3826
    @redaakherfi3826 4 года назад

    thank you for this videos , there are extremely helpful and professional can you do a video of how you began programming and what did you learn from the start ?

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

    that's cool bro

  • @josippardon8933
    @josippardon8933 2 года назад +4

    ActionChains clicking is acctualy very slow. Much faster clicking is achieved without it:
    for i in range(5000):
    cookie.click()
    count = int(cookie_count.text.split(" ")[0])
    print(count)
    for item in items:
    value = int(item.text)
    if value

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

      I noticed the same result. Not using Action Chain has better performance.

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

    if in driver.get('link' ) , link is not working then how can we go on other link(web page)

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

    I couldn't understand why we need to upgrade_actions.move_to_element ?

  • @kevinsusan3345
    @kevinsusan3345 4 года назад

    What if i wanted to upload a file to the website ? What should i do then coz it as soon as hit the browse button driver has no access to the window

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

    what if the website requires to be logged in , is this gonna work in selenium , or u can perform login with selenium for a web page

  • @alenjose3903
    @alenjose3903 4 года назад

    inside the loop cookie_count is called, will it go back and do the driver.find , is that how the value changes. ?

  • @RajaM-cz7js
    @RajaM-cz7js 4 года назад

    Tim again a great video!
    I'm learning machine learning right now and looking to move to deep learning later. Is it necessary for me to learn reinforcement learning, NLP and computer vision to get a good ml job?

  • @shotaarchemashvili9303
    @shotaarchemashvili9303 4 года назад

    hello Tim, which plugin do you use for intellisenses ??

  • @Jasper-fu3ql
    @Jasper-fu3ql 3 года назад +2

    Is it also possible to interact with a chrome tab that already has opened, because everytime it opens a new tab?

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

      Not sure why

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

      use driver.close() it will close the tab after the operation

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

    I didn't understand the use of ActionChains here. Can't you just do 'cookie.click()' instead of 'actions.click(cookie)'?

    • @bloo4315
      @bloo4315 4 года назад

      I just found this video but hopefully this will help future people.
      actions.click() lets you also add on more actions like another actions.click() which will all be done when you call actions.perform().

  • @dhruvnation1884
    @dhruvnation1884 4 года назад

    nice tim kepp it up.

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

    Hey Tim - thanks for the great lesson.Learnt a new method which is helping me a lot. Here's a question for you : how do I close out a currently running instance of Actionchains and start a new instance of Actionchains? The reason I am asking this is I have a code whereby, the Actionchains running on current commands, are repeating themselves, everytime I run actionchains on a new command (e.g. it types out the username everytime I am using the current instance of Actionchains).
    I have found a workaround in which I am calling the perform() action right after all actionchains are executed - but I wanted to check anyway, if it is possible to have another solution, which involves a new instance, thus cancelling the earlier/current instance (I have also found another command which is reset, but that does not seem to work for me)

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

    what will be the css_selector for

  • @nazeeruddinmohammed990
    @nazeeruddinmohammed990 4 года назад

    can you do a live stream tim, it would be nice.

  • @TechWithAashubro
    @TechWithAashubro 4 года назад +4

    I want to make a Jarvis like Ai as my project but I need a help.

    • @Fahadkhan_313
      @Fahadkhan_313 4 года назад +1

      Go to code with Harry RUclips channel and in his playlist section you will find python tutorials and at last of his playlist you will get full source code with explanation .

  • @PrideEnchantaVagale
    @PrideEnchantaVagale 4 года назад

    Hi Tim. Thanks for the video. I need an help in a project. Do you have made any video on how to handle input textbox read-only with list drop-down?

  • @Amitbidermoon
    @Amitbidermoon 4 года назад

    Hey Tim! what about Selenium web plugin? Is it recommended?

  • @kanavsingl28
    @kanavsingl28 4 года назад

    Who wants a video on how to run selenium on aws ec2 so we can run auto daily

  • @seanhewes5391
    @seanhewes5391 4 года назад +1

    Getting this error:
    Traceback (most recent call last):
    File "C:/Users/user/PycharmProjects/Selenium_Tutorial/tutorial_4.py", line 27, in
    count = int(cookie_count.text.split(" ")[0])
    AttributeError: 'list' object has no attribute 'text'

    • @ktcnoletterc
      @ktcnoletterc 4 года назад +1

      maybe you got sth wrong in the line :cookie_count=driver.find_element_by_id("cookies") ?

  • @PositronQ
    @PositronQ 4 года назад +1

    I do This proyect but with AI libraries
    The proyect do clicks in the publishing

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

    I have a problem. Command perform() just ignores the for i in range(5000). It runes chain just one time. MacBook.

    • @robbie8545
      @robbie8545 2 года назад +6

      I had the same problem. The way to fix it is to put the whole action chain in the for loop. So your code should look something like this
      for i in range(5000):
      actions = ActionChains(driver).click(cookie).perform()

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

      @@robbie8545 logged into my main acct to thank you for this!

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

      @@robbie8545 thank you!

  • @brolord1288
    @brolord1288 4 года назад

    Why I get :
    ValueError: invalid literal for int() with base 10:
    for line 21. I just copy the same code as yours?

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

    "like to do Grandma!!!"
    -Tim
    LOL!!!!!

  • @CSSuccessGamer
    @CSSuccessGamer 4 года назад

    my script is not buying the upgrades. I wrote the same code though.

  • @chrisc.4144
    @chrisc.4144 3 года назад

    Damn. I wanted to use Selenium to automate a survey I have to fill out every morning before entering work. But your comment about being banned put me off, lol.

  • @madhav3444
    @madhav3444 4 года назад

    How can we inspect some very secured pages which do not have any Inspect element options ?? Anybody knows ??

  • @ЕкатеринаМорозова-ю9я

    Why we should do move_to_element ?

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

    Hey, im trying this out and i want to make the price list become longer as more items are unlocked anybody got a hint for this

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

    Hey Tim, I'm struggling on how to automatically get rid of the cookie acceptance popups every time...how can we solve that with Selenium? Thx

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

      Very simple, just watch the videos before and you will know how to do it :)

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

    Need help copy data from excel and search into site and then again copy search results from sote and then copy and paste back to excel in perticular column

  • @mr.mikaeel6264
    @mr.mikaeel6264 4 года назад +1

    Diddnt you want to make it do grandma first? Now it's just doing the hand thing. Anyway good fun! Mail scripts and timers are fun too. Ofcourse strictly for automating job interviews ^^
    cookie grandma's aside, automated messages could be rly good for demented ppl. Help them remind things.

    • @brendan3966
      @brendan3966 4 года назад +1

      Just let it run. The prices go up as you advance and eventually the cursor costs more than grandmas and you start them.

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

    Bro pliss help when i run i got error cann't import name Action Chains

  • @KhalilYasser
    @KhalilYasser 4 года назад

    Thanks a lot for great tutorials. I have installed Sublime Text and I have saved the file with .py extension. But I didn't get IntelliSense when typing the code. How can I activate such feature?

    • @bipulharsh4059
      @bipulharsh4059 4 года назад

      I don't use sublime but vscode and there you can very easily get the python intelligence and I found it even more powerfull than sublime. So try it also

  • @johnstonejibin
    @johnstonejibin 4 года назад

    May I ask, can i stick with only one programming language (e.g Python)? for my career startup in programming?

    • @lucasphillips2177
      @lucasphillips2177 4 года назад +1

      I'm only in 9th grade, but I am doing what you are, getting really good with one, but I would learn a few more. no need to be an expert, just pretty fluent

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

    i got *AttributeError(“move_to requires a WebElement”) AttributeError: move_to requires a WebElement* error when i run this code. I could fix it with a lil help from stackoverflow but why you didnt get this error?

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

      Just ran into this myself. In my case it was because I used "find_elementS_by_id" whereas Tim used "find_element_by_id" - likely that you did the same thing since it's an error caused by "find_elements_by_id" returning a list of web elements according to the same stack overflow thread you probably found.

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

    Aren't action chains basically performing the same role as declaring a function?

  • @Juniorduke1
    @Juniorduke1 4 года назад

    How can we press the down arrow key in selenium