From cfffccccd21131bc79076f0f92ce5acb0cbadf4f Mon Sep 17 00:00:00 2001 From: Nico Schedel Date: Tue, 21 Jan 2020 11:05:18 +0100 Subject: [PATCH] TT#70901 selenium: add click_js - this function will click an element using javascript instead of the normal click command. selenium refuses to click some parts of the website even though they are clearly visible and clickable (i.e language settings) Change-Id: I4c2b821359a0f6bb0a58e22a28e48ba4fbc9af7b --- t/selenium/functions/Functions.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/t/selenium/functions/Functions.py b/t/selenium/functions/Functions.py index c9c66a8f..1b92017a 100644 --- a/t/selenium/functions/Functions.py +++ b/t/selenium/functions/Functions.py @@ -33,3 +33,11 @@ def move_and_click(driver, element, clickelement=None): else: hoverclick.click() hoverclick.perform() + + +def click_js(driver, element): + if element[:2] == "//": + webelement = driver.find_element_by_xpath(element) + else: + webelement = driver.find_element_by_link_text(element) + driver.execute_script("arguments[0].click();", webelement)