From 1ab39e4b7e13e8a83bc2b8596082b515647d20ec Mon Sep 17 00:00:00 2001 From: Nico Schedel Date: Mon, 2 Dec 2019 13:14:00 +0100 Subject: [PATCH] TT#70901 selenium: more test fixes - check first if element is clickable when trying to logout - fix crash on speed dial test - add a 1 second delay to clicks in reminder. it happens very often that elements wont accept the click even though element_to_be_clickable() check has passed. Change-Id: I36bacabf79d2078530d7db6a60ff6cd17c682bab Change-Id: Ifaed458e3958341d3081555efdbcd43be5efc2af --- t/selenium/functions/Collections.py | 2 ++ t/selenium/testrun.py | 15 +++++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/t/selenium/functions/Collections.py b/t/selenium/functions/Collections.py index 43feef83..b46ac592 100644 --- a/t/selenium/functions/Collections.py +++ b/t/selenium/functions/Collections.py @@ -20,6 +20,8 @@ def login(driver, name, pwd): def logout(driver): + WebDriverWait(driver, 10).until(EC.element_to_be_clickable(( + By.XPATH, '//*[@id="csc-header-toolbar"]/div[1]/button'))) driver.find_element_by_xpath( '//*[@id="csc-header-toolbar"]/div[1]/button').click() driver.find_element_by_xpath( diff --git a/t/selenium/testrun.py b/t/selenium/testrun.py index d3c97217..55790f86 100644 --- a/t/selenium/testrun.py +++ b/t/selenium/testrun.py @@ -1,6 +1,7 @@ import unittest import os import nose2 +import time import functions.Collections as Collections from selenium import webdriver from selenium.webdriver.common.keys import Keys @@ -220,14 +221,16 @@ class testrun(unittest.TestCase): '//*[@id="main-menu"]//div[@class="q-item-label"]' '[contains(text(), "Reminder")]').click() WebDriverWait(driver, 10).until(EC.element_to_be_clickable(( - By.XPATH, '//*[@id="q-app"]//div[contains(@class, ' - '"q-input-target justify-start")]'))) + By.XPATH, '//*[@id="q-app"]//div[@tabindex="0"][contains(@class, ' + '"q-toggle")]//span[contains(text(), "Reminder")]'))) + time.sleep(1) driver.find_element_by_xpath( - '//*[@id="q-app"]//div[@tabindex="0"][contains(@class, ' - '"q-toggle")]').click() + '//*[@id="q-app"]//div[@tabindex="0"][contains(@class, "q-toggle"' + ')]//span[contains(text(), "Reminder")]').click() WebDriverWait(driver, 10).until(EC.element_to_be_clickable(( By.XPATH, '//*[@id="q-app"]//div[contains(@class, ' '"q-input-target justify-start")]'))) + time.sleep(1) driver.find_element_by_xpath( '//*[@id="q-app"]//div[contains' '(@class, "q-input-target justify-start")]').click() @@ -243,6 +246,7 @@ class testrun(unittest.TestCase): WebDriverWait(driver, 10).until(EC.element_to_be_clickable(( By.XPATH, '//*[@id="q-app"]//div[@tabindex="0"]/span' '[@class="q-option-label"][contains(text(), "Always")]'))) + time.sleep(1) driver.find_element_by_xpath( '//*[@id="q-app"]//div[@tabindex="0"]//span' '[contains(text(), "Always")]').click() @@ -274,6 +278,9 @@ class testrun(unittest.TestCase): driver.find_element_by_xpath( '//*[@id="main-menu"]//div[@class="q-item-label"]' '[contains(text(), "Speed Dial")]').click() + WebDriverWait(driver, 10).until(EC.element_to_be_clickable(( + By.XPATH, '//*[@id="q-app"]//div//button[contains' + '(@class, "q-btn-rectangle")]'))) driver.find_element_by_xpath( '//*[@id="q-app"]//div//button[contains' '(@class, "q-btn-rectangle")]').click()