Changed how the PopMenu hack works in the test suite.

master
Pacman Ghost 4 years ago
parent ada2801020
commit f746b95408
  1. 2
      vasl_templates/webapp/templates/testing.html
  2. 25
      vasl_templates/webapp/tests/utils.py

@ -7,4 +7,4 @@
<textarea id="_scenario-persistence_" style="display:none;"></textarea>
<textarea id="_vsav-persistence_" style="display:none;"></textarea>
<textarea id="_snippet-image-persistence_" style="display:none;"></textarea>
<button id="popmenu-hack" style="display:none;">
<button id="popmenu-hack" style="display:none;position:absolute;top:0;left:0;">

@ -186,6 +186,7 @@ def get_tab_for_elem( elem ):
def select_menu_option( menu_id, webdriver=None ):
"""Select a menu option."""
if not webdriver:
webdriver = _webdriver
elem = find_child( "#menu", webdriver )
@ -193,18 +194,26 @@ def select_menu_option( menu_id, webdriver=None ):
elem = wait_for_elem( 2, "a.PopMenu-Link[data-name='{}']".format( menu_id ), webdriver )
elem.click()
wait_for( 2, lambda: find_child("#menu .PopMenu-Container",webdriver) is None ) # nb: wait for the menu to go away
# FUDGE! The delay above is not enough, I suspect because Selenium is deciding that the PopMenu container
# is hidden if it has a very low opacity, but it's still blocking any clicks we want to do after we return.
# We work around this by trying to click on a dummy button, until it works :-/
btn = find_child( "button#popmenu-hack" )
for i in range(0,10): #pylint: disable=unused-variable
try:
btn.click()
return
except WebDriverException:
time.sleep( 0.25 )
if find_child( "#ask" ):
class PopMenuHack:
"""Enable/disable the button we use to detect if PopMenu is still on-screen."""
def __enter__( self ):
webdriver.execute_script( "document.getElementById('popmenu-hack').style.display = 'block'" )
def __exit__( self, *args ):
webdriver.execute_script( "document.getElementById('popmenu-hack').style.display = 'none'" )
btn = find_child( "button#popmenu-hack", webdriver )
with PopMenuHack():
for i in range(0,10): #pylint: disable=unused-variable
try:
btn.click()
return
except WebDriverException:
time.sleep( 0.25 )
if find_child( ".ui-dialog", webdriver ):
return
assert False
def new_scenario():

Loading…
Cancel
Save