so I am creating a testing framework for a webapp but first I have to login to the site in order to begin the tests. My problem is that the login is in two parts, first page where you enter your email and then click an access button. The webapp checks the email against a database and sends you forward to a new page to enter your password and to finish the login procedure. The problem I am getting is the Stale element reference exception, but no matter what I do I can not get around it. I have tried explicit waits and implicit waits, a for loop and a while loop both with and without try/excepts.
This is my code as it stands right now, it gets me to the password page but then I get the Stale element reference exception no matter how long I set the wait time or how I get the element (by xpath/css etc).
# Methods
def click(driver, locator):
WebDriverWait(driver, 10).until(
EC.presence_of_element_located(locator)).click()
def send_Keys(driver, locator, value):
WebDriverWait(driver, 10).until(
EC.presence_of_element_located(locator)).clear()
WebDriverWait(driver, 10).until(
EC.presence_of_element_located(locator)).send_keys(value)
# Setting up Driver
s = Service('C:\Program Files (x86)\Google\Chrome\Application\chromedriver.exe')
driver = webdriver.Chrome(service=s)
url = 'http://localhost:8501/'
driver.get(url)
driver.maximize_window()
# Entering Email
send_Keys(driver, (By.XPATH, "//div/input"), username)
# Clicking Access Button
click(driver, (By.XPATH, "//div/button[@kind]"))
# Entering Password -- Getting error STALE ELEMENT
wait = WebDriverWait(driver, 60)
wait.until(EC.element_to_be_clickable(
(By.XPATH, "//input[@inputmode='text']")))
time.sleep(2)
wait.until(EC.element_to_be_clickable(
(By.XPATH, "//input[@inputmode='text']"))).send_keys(password)
# Clicking Access Button
click(driver, (By.XPATH, "//div/button[@kind]"))
Any help would be appreciated.