From 32d608bbc832581c260f9f81f6fbfed7a11226f5 Mon Sep 17 00:00:00 2001 From: Nico Schedel Date: Wed, 19 Feb 2020 10:01:49 +0100 Subject: [PATCH] TT#70901 selenium: reset cursor when launching move_and_click - reset cursor position before cursor gets moved to prevent mouse curser not triggering invisible buttons, because cursor is already on set position - remove second element argument, it isnt needed anymore - adjust function calls Change-Id: I2b53a42cd0972ba9a7f8c7f5df92b63f56dc8dd8 --- t/selenium/functions/Collections.py | 19 +++++++++---------- t/selenium/functions/Functions.py | 12 +++++------- 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/t/selenium/functions/Collections.py b/t/selenium/functions/Collections.py index 80cd6d5b..04100992 100644 --- a/t/selenium/functions/Collections.py +++ b/t/selenium/functions/Collections.py @@ -85,8 +85,8 @@ def delete_customer(driver, name): By.XPATH, '//*[@id="Customer_table"]//tr[1]//td' '[text()="%s"]' % name))) Functions.move_and_click( - driver, '//*[@id="Customer_table"]//tr[1]', '//*[@id="Customer_table"]' - '//tr[1]//td//a[contains(text(), "Terminate")]') + driver, '//*[@id="Customer_table"]//tr[1]//td//a[contains(text(),' + ' "Terminate")]') driver.find_element_by_xpath('//*[@id="dataConfirmOK"]').click() @@ -105,8 +105,8 @@ def create_subscriber(driver, customername, domainname): By.XPATH, '//*[@id="Customer_table"]//tr[1]//td' '[text()="%s"]' % customername))) Functions.move_and_click( - driver, '//*[@id="Customer_table"]//tr[1]', '//*[@id="Customer_table"]' - '//tr[1]//td//a[contains(text(), "Details")]') + driver, '//*[@id="Customer_table"]//tr[1]//td//a[contains(text(),' + ' "Details")]') driver.find_element_by_link_text('Expand Groups').click() Functions.scroll_to_element(driver, 'Subscribers') driver.find_element_by_link_text("Create Subscriber").click() @@ -150,13 +150,12 @@ def delete_subscriber(driver, customername): By.XPATH, '//*[@id="Customer_table"]//tr[1]//td' '[text()="%s"]' % customername))) Functions.move_and_click( - driver, '//*[@id="Customer_table"]//tr[1]', '//*[@id="Customer_table"]' - '//tr[1]//td//a[contains(text(), "Details")]') + driver, '//*[@id="Customer_table"]//tr[1]//td//a[contains(text(),' + ' "Details")]') driver.find_element_by_link_text('Expand Groups').click() Functions.scroll_to_element(driver, 'Subscribers') Functions.move_and_click( - driver, '//*[@id="subscribers_table"]//tr[1]', - '//*[@id="subscribers_table"]//tr[1]//td//a[contains(text(), ' + driver, '//*[@id="subscribers_table"]//tr[1]//td//a[contains(text(), ' '"Terminate")]') driver.find_element_by_xpath('//*[@id="dataConfirmOK"]').click() @@ -191,6 +190,6 @@ def delete_domain(driver, name): WebDriverWait(driver, 10).until(EC.element_to_be_clickable(( By.XPATH, '//*[@id="Domain_table"]//tr[1]//td[text()="%s"]' % name))) Functions.move_and_click( - driver, '//*[@id="Domain_table"]//tr[1]', '//*[@id="Domain_table"]' - '//tr[1]//td//a[contains(text(), "Delete")]') + driver, '//*[@id="Domain_table"]//tr[1]//td//a[contains(text(),' + ' "Delete")]') driver.find_element_by_xpath('//*[@id="dataConfirmOK"]').click() diff --git a/t/selenium/functions/Functions.py b/t/selenium/functions/Functions.py index 92d52512..5ecd644f 100644 --- a/t/selenium/functions/Functions.py +++ b/t/selenium/functions/Functions.py @@ -23,15 +23,13 @@ def scroll_to_element(driver, element): driver.execute_script("arguments[0].scrollIntoView();", webelem) -def move_and_click(driver, element, clickelement=None): - hoverclick = ActionChains(driver) +def move_and_click(driver, element): webelement = driver.find_element_by_xpath(element) + hoverclick = ActionChains(driver) + hoverclick.move_to_element_with_offset( + driver.find_element_by_xpath('/html/body'), 100, 100) hoverclick.move_to_element(webelement) - if clickelement: - webelementclick = driver.find_element_by_xpath(clickelement) - hoverclick.click(webelementclick) - else: - hoverclick.click() + hoverclick.click() hoverclick.perform()