Create attractive VASL scenarios, with loads of useful information embedded to assist with game play. https://vasl-templates.org
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
vasl-templates/vasl_templates/webapp/tests/utils.py

49 lines
1.4 KiB

""" Helper utilities. """
import urllib.request
import json
from PyQt5.QtWidgets import QApplication
from selenium.common.exceptions import NoSuchElementException
_webdriver = None
# ---------------------------------------------------------------------
def get_nationalities( webapp ):
"""Get the nationalities table."""
url = webapp.url_for( "get_nationalities" )
return json.load( urllib.request.urlopen( url ) )
# ---------------------------------------------------------------------
def get_stored_msg( msg_id ):
"""Get a message stored for us by the front-end."""
elem = find_child( _webdriver, "#"+msg_id )
if not elem:
return None
return elem.text
# ---------------------------------------------------------------------
def get_clipboard() :
"""Get the contents of the clipboard."""
app = QApplication( [] ) #pylint: disable=unused-variable
clipboard = QApplication.clipboard()
return clipboard.text()
# ---------------------------------------------------------------------
def find_child( elem, sel ):
"""Find a single child element."""
try:
return elem.find_element_by_css_selector( sel )
except NoSuchElementException:
return None
def find_children( elem, sel ):
"""Find child elements."""
try:
return elem.find_elements_by_css_selector( sel )
except NoSuchElementException:
return None