Home > Software engineering >  Selenium not checking box
Selenium not checking box

Time:07-04

Trying to get selenium to check a box with python but it seems to keep timing out.

Current code is

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait 
from selenium.webdriver.support import expected_conditions as EC

driver = webdriver.Chrome()
driver.get('https://grabagun.com/giveaway')

WebDriverWait(driver, 5).until(EC.element_to_be_clickable((By.XPATH, '//*[@id="terms_and_conditions"]'))).click()

Any suggestions?

CodePudding user response:

You could use action chains and the correct lookup:

from selenium.webdriver.common.action_chains import ActionChains

element = driver.find_element(By.ID, "terms_and_conditions")

ActionChains(driver).move_to_element(element).click().perform()
  • Related