mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
Improve setting up Sizzle for Selenium tests.
Something releated to AMD broke our way of injecting Sizzle into Galaxy for Selenium tests. This is a much better way that seems to work - just use jQuery ($) as Sizzle if it is available. Avoids an external dependency and another page fetch per test as well as fixing the problem. Add a test case that just tests the sizzle stuff works on its own. It will be a clear indiciation what is broken if there are related regressions in the future.
This commit is contained in:
@@ -95,12 +95,18 @@ def find_elements_by_sizzle(driver, sizzle_selector):
|
||||
|
||||
def _inject_sizzle(driver, sizzle_url, timeout):
|
||||
script = """
|
||||
var _s = document.createElement("script");
|
||||
_s.type = "text/javascript";
|
||||
_s.src = "{src}";
|
||||
var _h = document.getElementsByTagName("head")[0];
|
||||
_h.appendChild(_s);
|
||||
""".format(src=sizzle_url)
|
||||
if(typeof(window.$) != "undefined") {
|
||||
// Just reuse jQuery if it is available, avoids potential amd problems
|
||||
// that have cropped up with Galaxy for instance.
|
||||
window.Sizzle = window.$;
|
||||
} else {
|
||||
var _s = document.createElement("script");
|
||||
_s.type = "text/javascript";
|
||||
_s.src = "%s";
|
||||
var _h = document.getElementsByTagName("head")[0];
|
||||
_h.appendChild(_s);
|
||||
}
|
||||
""" % sizzle_url
|
||||
driver.execute_script(script)
|
||||
wait = WebDriverWait(driver, timeout)
|
||||
wait.until(lambda d: _is_sizzle_loaded(d),
|
||||
@@ -121,8 +127,8 @@ def _make_sizzle_string(sizzle_selector):
|
||||
|
||||
|
||||
__all__ = (
|
||||
"sizzle_selector_clickable",
|
||||
"sizzle_presence_of_selector",
|
||||
"find_element_by_sizzle",
|
||||
"find_elements_by_sizzle",
|
||||
"sizzle_selector_clickable",
|
||||
"sizzle_presence_of_selector",
|
||||
)
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
from .framework import SeleniumTestCase
|
||||
from .framework import selenium_test
|
||||
|
||||
|
||||
class SizzleLoadingTestCase(SeleniumTestCase):
|
||||
|
||||
@selenium_test
|
||||
def test_sizzle_loads(self):
|
||||
self.home()
|
||||
self.wait_for_sizzle_selector_clickable("div")
|
||||
Reference in New Issue
Block a user