[Python] Action Chain in loop works only once(Selenium/Python)

Discussão em 'Python' iniciado por Stack, Janeiro 20, 2025.

  1. Stack

    Stack Membro Participativo

    I'm trying to implement a cookie clicker bot. Cookie clicker it's just a stupid simple game, where you can click on the cookie to earn more cookies. You can take a look at that masterpiece here. The bot should just open the page, and click on the cookie 4000 times, but it clicks only one time.

    import time

    from selenium import webdriver
    from selenium.webdriver.common.by import By
    from selenium.webdriver.support.ui import WebDriverWait
    from selenium.webdriver.common.action_chains import ActionChains

    PATH = "C:\Program Files (x86)\chromedriver.exe"
    driver = webdriver.Chrome(PATH)
    driver.get("https://orteil.dashnet.org/cookieclicker/")

    driver.implicitly_wait(10)

    cookie = driver.find_element(By.ID, "bigCookie")

    actions = ActionChains(driver)
    actions.click(cookie)

    for i in range(4000):
    actions.perform()


    I see these messages in the console. What is wrong with me my code? [​IMG]

    Continue reading...

Compartilhe esta Página