This happens to me with this function, if I use a time.sllep () it works correctly but from what I understand it is quite inefficient to use it.
def visible_en_tienda(driver):
time.sleep(2)
xpath = "/html/body/div[1]/main/div[2]/section/div[5]/div/div/label/span"
visible = driver.find_element_by_xpath(xpath)
visible.click()
xpath = "/html/body/div[1]/main/div[2]/section/div[13]/div[2]/div/div/div[1]/div[1]/div/div/label/span"
visible = driver.find_element_by_xpath(xpath)
visible.click()
Then I tried to use the implicitly_wait () but it is as if it did not exist
def visible_en_tienda(driver):
driver.implicitly_wait(10)
xpath = "/html/body/div[1]/main/div[2]/section/div[5]/div/div/label/span"
visible = driver.find_element_by_xpath(xpath)
visible.click()
driver.implicitly_wait(10)
xpath = "/html/body/div[1]/main/div[2]/section/div[13]/div[2]/div/div/div[1]/div[1]/div/div/label/span"
visible = driver.find_element_by_xpath(xpath)
visible.click()
And I get this error, apparently there is another element on top of loading ...
selenium.common.exceptions.ElementClickInterceptedException:
Message: Element <span class="control__indicator"> is not clickable
at point (374,322.5) because another element <div class="bg">
obscures it
So I try to use the explicit wait in this way but it still gives me the same error.
def visible_en_tienda(driver):
wait = WebDriverWait(driver, 10)
xpath = "/html/body/div[1]/main/div[2]/section/div[5]/div/div/label/span"
visible = wait.until(EC.element_to_be_clickable((By.XPATH, xpath)))
visible.click()
xpath = "/html/body/div[1]/main/div[2]/section/div[13]/div[2]/div/div/div[1]/div[1]/div/div/label/span"
visible = wait.until(EC.element_to_be_clickable((By.XPATH, xpath)))
visible.click()
Then I'm not sure if the waits do not work or I'm using them badly. And if I'm using them badly, what am I doing wrong?