Ejemplo n.º 1
0
    def test_find_anonymous_element_by_attribute(self):
        el = Wait(self.marionette).until(element_present("id", "dia"))
        self.assertEquals(HTMLElement, type(el.find_element("anon attribute", {"anonid": "buttons"})))
        self.assertEquals(1, len(el.find_elements("anon attribute", {"anonid": "buttons"})))

        with self.assertRaises(NoSuchElementException):
            el.find_element("anon attribute", {"anonid": "nonexistent"})
        self.assertEquals([], el.find_elements("anon attribute", {"anonid": "nonexistent"}))
Ejemplo n.º 2
0
    def switch_into_test_container(self):
        self.marionette.set_context(self.marionette.CONTEXT_CONTENT)

        frame = Wait(self.marionette, timeout=10, interval=0.2).until(element_present(
            'css selector',
            'iframe[src*="app://test-container.gaiamobile.org/index.html"]'
        ))

        self.marionette.switch_to_frame(frame)
Ejemplo n.º 3
0
    def test_find_anonymous_children(self):
        el = Wait(self.marionette).until(element_present("id", "dia"))
        self.assertEquals(HTMLElement, type(el.find_element("anon", None)))
        self.assertEquals(2, len(el.find_elements("anon", None)))

        el = self.marionette.find_element("id", "framebox")
        with self.assertRaises(NoSuchElementException):
            el.find_element("anon", None)
        self.assertEquals([], el.find_elements("anon", None))
Ejemplo n.º 4
0
    def test_find_anonymous_children(self):
        el = Wait(self.marionette).until(element_present("id", "dia"))
        self.assertEquals(HTMLElement, type(el.find_element("anon", None)))
        self.assertEquals(2, len(el.find_elements("anon", None)))

        el = self.marionette.find_element("id", "framebox")
        with self.assertRaises(NoSuchElementException):
            el.find_element("anon", None)
        self.assertEquals([], el.find_elements("anon", None))
Ejemplo n.º 5
0
    def test_find_anonymous_element_by_attribute(self):
        el = Wait(self.marionette).until(element_present("id", "dia"))
        self.assertEquals(
            HTMLElement,
            type(el.find_element("anon attribute", {"anonid": "buttons"})))
        self.assertEquals(
            1, len(el.find_elements("anon attribute", {"anonid": "buttons"})))

        with self.assertRaises(NoSuchElementException):
            el.find_element("anon attribute", {"anonid": "nonexistent"})
        self.assertEquals([],
                          el.find_elements("anon attribute",
                                           {"anonid": "nonexistent"}))
Ejemplo n.º 6
0
    def switch_into_test_container(self):
        self.marionette.set_context("content")
        frame = None
        try:
            frame = self.marionette.find_element(
                'css selector',
                'iframe[src*="app://test-container.gaiamobile.org/index.html"]'
            )
        except NoSuchElementException:
            result = self.marionette.execute_async_script("""
if((navigator.mozSettings == undefined) || (navigator.mozSettings == null) || (navigator.mozApps == undefined) || (navigator.mozApps == null)) {
    marionetteScriptFinished(false);
    return;
}
let setReq = navigator.mozSettings.createLock().set({'lockscreen.enabled': false});
setReq.onsuccess = function() {
    let appsReq = navigator.mozApps.mgmt.getAll();
    appsReq.onsuccess = function() {
        let apps = appsReq.result;
        for (let i = 0; i < apps.length; i++) {
            let app = apps[i];
            if (app.manifest.name === 'Test Container') {
                app.launch();
                window.addEventListener('apploadtime', function apploadtime(){
                    window.removeEventListener('apploadtime', apploadtime);
                    marionetteScriptFinished(true);
                });
                return;
            }
        }
        marionetteScriptFinished(false);
    }
    appsReq.onerror = function() {
        marionetteScriptFinished(false);
    }
}
setReq.onerror = function() {
    marionetteScriptFinished(false);
}""",
                                                          script_timeout=60000)

            self.assertTrue(result)
            frame = Wait(self.marionette, timeout=10, interval=0.2).until(
                element_present(
                    'css selector',
                    'iframe[src*="app://test-container.gaiamobile.org/index.html"]'
                ))

        self.marionette.switch_to_frame(frame)
Ejemplo n.º 7
0
    def switch_into_test_container(self):
        self.marionette.set_context("content")
        frame = None
        try:
            frame = self.marionette.find_element(
                'css selector',
                'iframe[src*="app://test-container.gaiamobile.org/index.html"]'
            )
        except NoSuchElementException:
            result = self.marionette.execute_async_script("""
if((navigator.mozSettings == undefined) || (navigator.mozSettings == null) || (navigator.mozApps == undefined) || (navigator.mozApps == null)) {
    marionetteScriptFinished(false);
    return;
}
let setReq = navigator.mozSettings.createLock().set({'lockscreen.enabled': false});
setReq.onsuccess = function() {
    let appsReq = navigator.mozApps.mgmt.getAll();
    appsReq.onsuccess = function() {
        let apps = appsReq.result;
        for (let i = 0; i < apps.length; i++) {
            let app = apps[i];
            if (app.manifest.name === 'Test Container') {
                app.launch();
                window.addEventListener('apploadtime', function apploadtime(){
                    window.removeEventListener('apploadtime', apploadtime);
                    marionetteScriptFinished(true);
                });
                return;
            }
        }
        marionetteScriptFinished(false);
    }
    appsReq.onerror = function() {
        marionetteScriptFinished(false);
    }
}
setReq.onerror = function() {
    marionetteScriptFinished(false);
}""", script_timeout=60000)

            self.assertTrue(result)
            frame = Wait(self.marionette, timeout=10, interval=0.2).until(element_present(
                'css selector',
                'iframe[src*="app://test-container.gaiamobile.org/index.html"]'
            ))

        self.marionette.switch_to_frame(frame)
Ejemplo n.º 8
0
 def test_element_present_not_present(self):
     r = expected.element_present(no_such_element)(self.marionette)
     self.assertIsInstance(r, bool)
     self.assertFalse(r)
Ejemplo n.º 9
0
 def test_element_present_locator(self):
     self.marionette.navigate(static_element)
     el = expected.element_present(By.TAG_NAME, "p")(self.marionette)
     self.assertIsNotNone(el)
Ejemplo n.º 10
0
 def test_element_present_func(self):
     self.marionette.navigate(static_element)
     el = expected.element_present(p)(self.marionette)
     self.assertIsNotNone(el)
Ejemplo n.º 11
0
 def test_element_present_not_present(self):
     r = expected.element_present(no_such_element)(self.marionette)
     self.assertIsInstance(r, bool)
     self.assertFalse(r)
Ejemplo n.º 12
0
 def test_element_present_locator(self):
     self.marionette.navigate(static_element)
     el = expected.element_present(By.TAG_NAME, "p")(self.marionette)
     self.assertIsNotNone(el)
Ejemplo n.º 13
0
 def test_element_present_func(self):
     self.marionette.navigate(static_element)
     el = expected.element_present(p)(self.marionette)
     self.assertIsNotNone(el)