From 6a6b9531cf6dd3a86853f3d8b111635195a7ecf0 Mon Sep 17 00:00:00 2001 From: Nico Schedel Date: Wed, 21 Jul 2021 11:41:39 +0200 Subject: [PATCH] TT#70901 selenium: add new checked_if_unchecked functions checked_if_unchecked checks first if a checkbox is checked, if not then check it Change-Id: I689825bf2dd46d4fc6149afb4cf57c95da5afcff --- t/selenium/functions/Collections.py | 6 +++++- t/selenium/functions/Functions.py | 6 ++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/t/selenium/functions/Collections.py b/t/selenium/functions/Collections.py index 3a2acf0e..9a45d1fe 100644 --- a/t/selenium/functions/Collections.py +++ b/t/selenium/functions/Collections.py @@ -6,6 +6,7 @@ from selenium.webdriver.common.by import By from functions.Functions import fill_element from functions.Functions import scroll_to_element from functions.Functions import click_js +from functions.Functions import check_if_unchecked def login_csc(driver, name, pwd): @@ -59,6 +60,7 @@ def create_customer(driver, name=None): scroll_to_element(driver, '//*[@id="external_id"]') fill_element(driver, '//*[@id="external_id"]', name) driver.find_element_by_xpath('//*[@id="save"]').click() + WebDriverWait(driver, 10).until(EC.visibility_of_element_located((By.XPATH, '//*[@id="content"]//div[@class="alert alert-info"]'))) return name @@ -91,7 +93,7 @@ def create_subscriber(driver, customername, domainname): driver.find_element_by_css_selector('#domainidtable tr > td.dataTables_empty') fill_element(driver, '//*[@id="domainidtable_filter"]//input', domainname) WebDriverWait(driver, 10).until(EC.visibility_of_element_located((By.XPATH, '//*[@id="domainidtable"]//tr[1]//td[text()="%s"]' % domainname))) - click_js(driver, '//*[@id="domainidtable"]/tbody/tr[1]/td[4]/input') + check_if_unchecked(driver, '//*[@id="domainidtable"]/tbody/tr[1]/td[4]/input') driver.find_element_by_xpath('//*[@id="webusername"]').send_keys('testuser') driver.find_element_by_xpath('//*[@id="webpassword"]').send_keys('testpasswd') driver.find_element_by_xpath('//*[@id="username"]').send_keys('testuser') @@ -99,6 +101,7 @@ def create_subscriber(driver, customername, domainname): scroll_to_element(driver, '//*[@id="administrative"]') driver.find_element_by_xpath('//*[@id="administrative"]').click() driver.find_element_by_xpath('//*[@id="save"]').click() + WebDriverWait(driver, 10).until(EC.visibility_of_element_located((By.XPATH, '//*[@id="content"]//div[@class="alert alert-info"]'))) def delete_subscriber(driver, customername): @@ -127,6 +130,7 @@ def create_domain(driver, name=None): driver.find_element_by_xpath('//*[@id="reselleridtable"]//tr[1]/td[5]/input').click() fill_element(driver, '//*[@id="domain"]', name) driver.find_element_by_xpath('//*[@id="save"]').click() + WebDriverWait(driver, 10).until(EC.visibility_of_element_located((By.XPATH, '//*[@id="content"]//div[@class="alert alert-info"]'))) return name diff --git a/t/selenium/functions/Functions.py b/t/selenium/functions/Functions.py index 036e4c4a..f1dcbf19 100644 --- a/t/selenium/functions/Functions.py +++ b/t/selenium/functions/Functions.py @@ -55,3 +55,9 @@ def wait_for_invisibility(driver, xpath): driver.implicitly_wait(2) WebDriverWait(driver, 10).until(EC.invisibility_of_element_located((By.XPATH, xpath))) driver.implicitly_wait(10) + + +def check_if_unchecked(driver, element): + checkmark = driver.find_element_by_xpath(element) + if not checkmark.is_selected(): + click_js(driver, element)