I have started developing a test suite for our system. I had no problem testing the two screen that did not require user sign on, or the welcome/sign on screen, but as soon as I try to process user sign on, for which we use 3rd party AWS Cognito things are failing.
Basically the code below allows sign on to our application, but when the Cognito window opens I can find any element on the screen and assert its value (all those lines in the code are working).
However any attempt to use send_keys or click to interact with the same elements fails, showing the error trace listed at the end.
The elements are not in an iframe or a separate window, are not hidden from view, and are not locked/disabled or any other reason that a human operator could not access them at any time..
Seems very odd to me that I can see and read elelements from the screen, but when I try to interact with the same ones I get an error that they are not reachable.
import pytest
import os
from selenium import webdriver
from
selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.common.action_chains import ActionChains
from utils.base_page import BasePage
from utils.element_selectors import WelcomeScreen, CognitoLoginForm
from utils.config import Config
class Test_998():
def setup_method(self, firefox_driver):
self.driver = firefox_driver
self.base_page = BasePage(self.driver)
def test_998_homepage(self):
driver = webdriver.Firefox()
driver.get('
https://staging.nmcaydence.com')
'''
Click the Caydence login button
'''
login_button = self.base_page.wait_for_element(
driver,
WelcomeScreen.LOGIN_BUTTON,
EC.visibility_of_element_located
)
login_button.click()
'''
Wait for sign on window
'''
#### message = self.base_page.wait_for_element(
#### driver,
#### CognitoLoginForm.USERNAME_INPUT,
#### EC.element_to_be_clickable
#### )
driver.implicitly_wait(10)
'''
Check various elements on the screen
'''
cognito_form = driver.find_element(By.XPATH, "//form[@class='cognito-asf']")
cognito_username = cognito_form.find_element(By.XPATH, "//input[@name='username']")
cognito_password = cognito_form.find_element(By.XPATH, "//input[@name='password']")
cognito_submit = cognito_form.find_element(By.XPATH, "//input[@name='signInSubmitButton']")
cognito_label_1 = driver.find_element(By.CLASS_NAME, 'textDescription-customizable')
cognito_forgot = cognito_form.find_element(By.CLASS_NAME, 'redirect-customizable')
cognito_label_1_text = cognito_label_1.get_attribute('textContent')
assert cognito_label_1_text == 'Sign in with your username and password'
cognito_forgot_text = cognito_forgot.get_attribute("textContent")
assert cognito_forgot_text == 'Forgot your password?'
username_placeholder = cognito_username.get_attribute('placeholder')
assert username_placeholder == 'Username'
cognito_username_value = cognito_username.get_attribute("textContent")
assert cognito_username_value == ''
'''
Enter user details and submit
'''
# Update username input
cognito_username.send_keys("
aa...@hotmail.com")
cognito_password.send_keys("not-my-real-password")
cognito_submit.click()
driver.quit()
Errors reported
raise exception_class(message, screen, stacktrace) E selenium.common.exceptions.ElementNotInteractableException: Message: Element is not reachable by keyboard
E Stacktrace:
E RemoteError@chrome://remote/content/shared/RemoteError.sys.mjs:8:8
E WebDriverError@chrome://remote/content/shared/webdriver/Errors.sys.mjs:199:5
E ElementNotInteractableError@chrome://remote/content/shared/webdriver/Errors.sys.mjs:368:5
E webdriverSendKeysToElement@chrome://remote/content/marionette/interaction.sys.mjs:667:13
E interaction.sendKeysToElement@chrome://remote/content/marionette/interaction.sys.mjs:639:11
E sendKeysToElement@chrome://remote/content/marionette/actors/MarionetteCommandsChild.sys.mjs:609:29
E receiveMessage@chrome://remote/content/marionette/actors/MarionetteCommandsChild.sys.mjs:269:31