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.
39 lines
1.1 KiB
39 lines
1.1 KiB
""" Helper utilities. """
|
|
|
|
from PyQt5.QtWidgets import QApplication
|
|
from selenium.common.exceptions import NoSuchElementException
|
|
|
|
_webdriver = None
|
|
|
|
# ---------------------------------------------------------------------
|
|
|
|
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
|
|
|