Fixed some tests for IE.

master
Pacman Ghost 6 years ago
parent 46ad8c948f
commit 2ad7379080
  1. 4
      vasl_templates/webapp/tests/test_ob.py
  2. 4
      vasl_templates/webapp/tests/test_snippets.py
  3. 4
      vasl_templates/webapp/tests/test_ssr.py
  4. 27
      vasl_templates/webapp/tests/utils.py

@ -8,7 +8,7 @@ from selenium.webdriver.support.ui import Select
from vasl_templates.webapp.tests.utils import \
get_nationalities, get_clipboard, get_stored_msg, set_stored_msg_marker, select_tab, find_child, find_children, \
add_simple_note, edit_simple_note, get_sortable_entry_count, drag_sortable_entry_to_trash, \
select_droplist_val, init_webapp, wait_for
select_droplist_val, init_webapp, wait_for, adjust_html
# ---------------------------------------------------------------------
@ -47,7 +47,7 @@ def _do_test_ob_entries( webapp, webdriver, ob_type ):
elems[entry_no].click()
if ob_type == "ob_notes":
expected = re.sub( r" \(col=.*?\)", "", expected )
assert get_clipboard() == expected
assert adjust_html( get_clipboard() ) == expected
select_tab( "ob1" )
check_snippet( sortable1, 0,
"[German] [{} #1] (col=[OBCOL:german/OBCOL2:german])".format( ob_type )

@ -4,7 +4,7 @@ from selenium.webdriver.common.keys import Keys
from vasl_templates.webapp.tests.utils import \
init_webapp, select_tab, set_template_params, get_clipboard, \
get_stored_msg, set_stored_msg_marker, find_child, wait_for, \
get_stored_msg, set_stored_msg_marker, find_child, wait_for, adjust_html, \
for_each_template, add_simple_note, edit_simple_note, \
get_sortable_entry_count, generate_sortable_entry_snippet, drag_sortable_entry_to_trash
@ -117,7 +117,7 @@ def test_scenario_notes_snippets( webapp, webdriver ):
sortable = find_child( "#scenario_notes-sortable" )
add_simple_note( sortable, "scenario <i>note</i> #1", None )
add_simple_note( sortable, "scenario note #2", "100px" )
assert generate_sortable_entry_snippet( sortable, 0 ) == "[scenario <i>note</i> #1]"
assert generate_sortable_entry_snippet( sortable, 0 ) == adjust_html( "[scenario <i>note</i> #1]" )
assert generate_sortable_entry_snippet( sortable, 1 ) == "[scenario note #2] (width=[100px])"
# delete a scenario note by dragging it into the trash

@ -3,7 +3,7 @@
import html
from vasl_templates.webapp.tests.utils import \
init_webapp, select_tab, find_child, get_clipboard, \
init_webapp, select_tab, find_child, get_clipboard, adjust_html, \
add_simple_note, edit_simple_note, drag_sortable_entry_to_trash, get_sortable_entry_count
# ---------------------------------------------------------------------
@ -35,7 +35,7 @@ def test_ssr( webapp, webdriver ):
val = "\n".join( "(*) [{}]".format(e) for e in expected )
if width:
val += "\nwidth = [{}]".format( width )
assert html.unescape( get_clipboard() ) == val
assert html.unescape( adjust_html( get_clipboard() ) ) == val
# add an SSR and generate the SSR snippet
add_ssr( "This is my first SSR." )

@ -103,7 +103,7 @@ def select_menu_option( menu_id ):
"""Select a menu option."""
elem = find_child( "#menu" )
elem.click()
elem = find_child( "a.PopMenu-Link[data-name='{}']".format( menu_id ) )
elem = wait_for_elem( 2, "a.PopMenu-Link[data-name='{}']".format( menu_id ) )
elem.click()
wait_for( 2, lambda: find_child("#menu .PopMenu-Container") is None ) # nb: wait for the menu to go away
if pytest.config.option.webdriver == "chrome": #pylint: disable=no-member
@ -382,3 +382,28 @@ def wait_for( timeout, func ):
break
assert time.time() - start_time < timeout
time.sleep( 0.1 )
def wait_for_elem( timeout, elem_id, parent=None ):
"""Wait for an element to appear ."""
args = { "elem": None }
def check_elem(): #pylint: disable=missing-docstring
args["elem"] = find_child( elem_id, parent )
return args["elem"] is not None
wait_for( timeout, check_elem )
return args["elem"]
# ---------------------------------------------------------------------
_IE_HTML_TAGS = [ "<i>" ]
def adjust_html( val ):
"""Adjust HTML content for IE."""
if pytest.config.option.webdriver != "ie": #pylint: disable=no-member
return val
# convert HTML tags to uppercase :-/
for tag in _IE_HTML_TAGS:
val = val.replace( tag, tag.upper() )
assert tag.startswith( "<" ) and tag.endswith( ">" )
close_tag = "</{}".format( tag[1:] )
val = val.replace( close_tag, close_tag.upper() )
return val

Loading…
Cancel
Save