0

This code works fine but when it goes to the second looping this error happens:

ERROR: StaleElementReferenceException: Message: stale element reference: element is not attached to the page document

from selenium import webdriver
from tqdm import tqdm
from tqdm.notebook import trange, tqdm

from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.chrome.service import Service

from selenium.webdriver.support.select import Select
from selenium.webdriver.common.by import By
import time

servico = Service(ChromeDriverManager().install())
navegador = webdriver.Chrome(service=servico)

dropdownField = navegador.find_element(By.NAME,('customer_id'))
select = Select(dropdownField)
all_options=select.options

for option in tqdm (all_options):
    if (option.text!=""):
        option.click()
        time.sleep(3)
        navegador.find_element(By.ID,'email').click()
        time.sleep(1)
        navegador.find_element(By.ID,'email').send_keys(email)
        time.sleep(1)
        navegador.find_element(By.ID,'button_find').click()
        time.sleep(2)
print("Test ok")`

0 Answers0