Skip to content

Commit 01aceff

Browse files
committed
Fix tests using action chains in custom SeleniumLibrary extension
1 parent ff513be commit 01aceff

File tree

2 files changed

+24
-4
lines changed

2 files changed

+24
-4
lines changed

atest/05_Features/Hover.robot

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Test Setup Setup Hover Test
44
Test Teardown Clean Up After Working With File Hover.ipynb
55
Force Tags feature:hover
66
Resource ../Keywords.robot
7+
Library ../mouse_over_with_modifier.py
78

89
*** Variables ***
910
${HOVER_BOX} css:.lsp-hover
@@ -42,15 +43,16 @@ Hover works in foreign code (javascript)
4243
Hover Over
4344
[Arguments] ${symbol}
4445
${sel} = Set Variable If "${symbol}".startswith(("xpath", "css")) ${symbol} xpath:(//span[@role="presentation"][contains(., "${symbol}")])[last()]
45-
Wait Until Keyword Succeeds 2x 0.1 s Trigger Tooltip ${sel}
46+
Wait Until Keyword Succeeds 3x 0.1 s Trigger Tooltip ${sel}
4647

4748
Trigger Tooltip
4849
[Arguments] ${sel}
50+
# bring the cursor to the element
4951
Mouse Over ${sel}
52+
# move it back and forth (wiggle) while hodling the ctrl modifier
53+
Mouse Over With Control ${sel} x_wiggle=5
5054
Wait Until Page Contains Element ${HOVER_SIGNAL}
51-
Click Element ${sel}
52-
Press Keys ${sel} CTRL
53-
Wait Until Keyword Succeeds 2x 0.1s Page Should Contain Element ${HOVER_BOX}
55+
Wait Until Keyword Succeeds 3x 0.1s Page Should Contain Element ${HOVER_BOX}
5456

5557
Setup Hover Test
5658
Setup Notebook Python Hover.ipynb

atest/mouse_over_with_modifier.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
from robot.api import logger
2+
from robot.libraries.BuiltIn import BuiltIn
3+
from selenium.webdriver import ActionChains
4+
from selenium.webdriver.common.keys import Keys
5+
from SeleniumLibrary import SeleniumLibrary
6+
7+
8+
def mouse_over_with_control(locator, x_wiggle=0):
9+
logger.info("Getting currently open browser desired capabilities")
10+
sl: SeleniumLibrary = BuiltIn().get_library_instance("SeleniumLibrary")
11+
action_chains = ActionChains(sl.driver)
12+
action_chains.key_down(Keys.CONTROL)
13+
action_chains.move_to_element(sl.find_element(locator))
14+
if x_wiggle:
15+
action_chains.move_by_offset(xoffset=x_wiggle, yoffset=0)
16+
action_chains.move_by_offset(xoffset=-x_wiggle, yoffset=0)
17+
action_chains.key_up(Keys.CONTROL)
18+
return action_chains.perform()

0 commit comments

Comments
 (0)