I have made a simple Selenium script which visits a webpage and clicks the cookie. But I have only managed to get it to click once even though I have put it in a loop. Can anyone tell me where I am going wrong?
http://orteil.dashnet.org/cookieclicker/
from selenium import webdriver
import os
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.action_chains import ActionChains
import time
os.environ['PATH'] = r"C:\Users\Ruibin\Desktop\Python\chromedriver_win32"
driver = webdriver.Chrome()
driver.get('https://orteil.dashnet.org/cookieclicker/')
try:
WebDriverWait(driver, 5).until(
EC.presence_of_element_located(
(By.ID, 'langSelect-EN')
)
)
driver.find_element(By.ID, 'langSelect-EN').click()
finally:
driver.implicitly_wait(10)
cookies = driver.find_element(By.ID, 'bigCookie')
cookie_count = driver.find_element(By.ID, 'cookies')
actions = ActionChains(driver)
actions.click(cookies)
for i in range(10):
actions.perform()