Skip to content
Snippets Groups Projects
Verified Commit 7acf6e5f authored by Nik | Klampfradler's avatar Nik | Klampfradler
Browse files

[Selenium] Use WebDriverWait to find elements by xpath

parent efa65bfc
No related branches found
No related tags found
1 merge request!1056Resolve "Selenium forgot about `find_element_by_xpath`"
Pipeline #76205 canceled
......@@ -7,6 +7,8 @@ from django.test.selenium import SeleniumTestCase, SeleniumTestCaseBase
from django.urls import reverse
import pytest
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.wait import WebDriverWait
from aleksis.core.models import Person
......@@ -43,17 +45,25 @@ class SeleniumTests(SeleniumTestCase):
self._screenshot("login_default_superuser_blank.png")
# Find login form input fields and enter defined credentials
self.selenium.find_element_by_xpath(
'//label[contains(text(), "Username")]/../input'
WebDriverWait(self.selenium, 10).until(
EC.element_to_be_clickable(
(By.XPATH, '//label[contains(text(), "Username")]/../input'),
)
).send_keys(username)
self.selenium.find_element_by_xpath(
'//label[contains(text(), "Password")]/../input'
WebDriverWait(self.selenium, 10).until(
EC.element_to_be_clickable(
(By.XPATH, '//label[contains(text(), "Password")]/../input'),
)
).send_keys(password)
if with_screenshots:
self._screenshot("login_default_superuser_filled.png")
# Submit form by clicking django-two-factor-auth's Next button
self.selenium.find_element_by_xpath('//button[contains(text(), "Login")]').click()
WebDriverWait(self.selenium, 10).until(
EC.element_to_be_clickable(
(By.XPATH, '//button[contains(text(), "Login")]'),
)
).click()
if with_screenshots:
self._screenshot("login_default_superuser_submitted.png")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment