當前位置: 首頁>>代碼示例>>Python>>正文


Python events.EventFiringWebDriver類代碼示例

本文整理匯總了Python中selenium.webdriver.support.events.EventFiringWebDriver的典型用法代碼示例。如果您正苦於以下問題:Python EventFiringWebDriver類的具體用法?Python EventFiringWebDriver怎麽用?Python EventFiringWebDriver使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了EventFiringWebDriver類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_demo

    def test_demo(self):

        pjsdriver = webdriver.PhantomJS("phantomjs")
        d = EventFiringWebDriver(pjsdriver, ScreenshotListener())

        d.get("http://www.google.com")
        d.find_element_by_css_selector("div.that-does-not-exist")
開發者ID:ashisri18,項目名稱:Framework_Jabong,代碼行數:7,代碼來源:script_05.py

示例2: TestTacoTodos

class TestTacoTodos(object):

    def setup_method(self, method):
        self.driver = EventFiringWebDriver(remote_webdriver, MaListener())
        self.current_method_name = method.__name__

    def teardown_method(self, method):
        self.driver.close()
        self.driver.quit()

    def test_todo_counts(self):
        tacotodos = TacoTodoPage(self.driver).open()
        tacotodos.new_todo = 'Bean and egg taco \n'
        tacotodos.new_todo = 'Potato, egg & cheese \n'
        tacotodos.new_todo = 'Nopales y huevos\n'
        tacotodos.new_todo = 'Crispy taco\n'
        tacotodos.new_todo = 'Cruspy taco\n'
        tacotodos.new_todo = 'Crepes\n'
        assert 6 == tacotodos.todos_remaining
        tacotodos.complete_all_todos()
        assert 6 == tacotodos.todos_completed
        assert 6 == tacotodos.todos_listed
        assert 0 == tacotodos.todos_remaining
        tacotodos.clear_completed_todos()
        assert 0 == tacotodos.todos_listed
        assert 0 == tacotodos.todos_completed
開發者ID:Andrew-Yourn,項目名稱:page-object-examples,代碼行數:26,代碼來源:example_02_w_listener.py

示例3: test_should_unwrap_element_args_when_calling_scripts

 def test_should_unwrap_element_args_when_calling_scripts(self):
     ef_driver = EventFiringWebDriver(self.driver, AbstractEventListener())
     ef_driver.get(self._pageURL("javascriptPage"))
     button = ef_driver.find_element_by_id("plainButton")
     value = ef_driver.execute_script(
         "arguments[0]['flibble'] = arguments[0].getAttribute('id'); return arguments[0]['flibble']",
         button)
     self.assertEqual("plainButton", value)
開發者ID:Alsan,項目名稱:selenium,代碼行數:8,代碼來源:event_firing_webdriver_tests.py

示例4: test_should_unwrap_element_args_when_calling_scripts

 def test_should_unwrap_element_args_when_calling_scripts(self, driver, log, pages):
     ef_driver = EventFiringWebDriver(driver, AbstractEventListener())
     ef_driver.get(pages.url("javascriptPage.html"))
     button = ef_driver.find_element_by_id("plainButton")
     value = ef_driver.execute_script(
         "arguments[0]['flibble'] = arguments[0].getAttribute('id'); return arguments[0]['flibble']",
         button)
     assert "plainButton" == value
開發者ID:glib-briia,項目名稱:selenium,代碼行數:8,代碼來源:event_firing_webdriver_tests.py

示例5: test_should_fire_navigation_events

    def test_should_fire_navigation_events(self):
        log = self.log 
                
        class TestListener(AbstractEventListener):
            def before_navigate_to(self, url, driver):
                log.write(("before_navigate_to %s" % url.split("/")[-1]).encode())
            def after_navigate_to(self, url, driver):
                log.write(("after_navigate_to %s" % url.split("/")[-1]).encode())
            def before_navigate_back(self, driver):
                log.write(b"before_navigate_back")
            def after_navigate_back(self, driver):
                log.write(b"after_navigate_back")
            def before_navigate_forward(self, driver):
                log.write(b"before_navigate_forward")
            def after_navigate_forward(self, driver):
                log.write(b"after_navigate_forward")
            
        ef_driver = EventFiringWebDriver(self.driver, TestListener())            
        ef_driver.get(self._pageURL("formPage"))
        ef_driver.find_element(by=By.ID, value="imageButton").submit()
        self.assertEqual(ef_driver.title, "We Arrive Here")

        ef_driver.back()
        self.assertEqual(ef_driver.title, "We Leave From Here")

        ef_driver.forward()
        self.assertEqual(ef_driver.title, "We Arrive Here")        
       
        self.assertEqual(b"before_navigate_to formPage.html" \
                + b"after_navigate_to formPage.html" \
                + b"before_navigate_back" \
                + b"after_navigate_back" \
                + b"before_navigate_forward" \
                + b"after_navigate_forward", log.getvalue())
開發者ID:AnnikaXiao,項目名稱:selenium,代碼行數:34,代碼來源:event_firing_webdriver_tests.py

示例6: test_missing_attributes_raise_error

def test_missing_attributes_raise_error(driver, pages):
    ef_driver = EventFiringWebDriver(driver, AbstractEventListener())

    with pytest.raises(AttributeError):
        ef_driver.attribute_should_not_exist

    ef_driver.get(pages.url("readOnlyPage.html"))
    element = ef_driver.find_element_by_id("writableTextInput")

    with pytest.raises(AttributeError):
        element.attribute_should_not_exist
開發者ID:Allariya,項目名稱:selenium,代碼行數:11,代碼來源:event_firing_webdriver_tests.py

示例7: test_should_call_listener_when_an_exception_is_thrown

    def test_should_call_listener_when_an_exception_is_thrown(self, driver, log, pages):
        class TestListener(AbstractEventListener):
            def on_exception(self, exception, driver):
                if isinstance(exception, NoSuchElementException):
                    log.write(b"NoSuchElementException is thrown")

        ef_driver = EventFiringWebDriver(driver, TestListener())
        ef_driver.get(pages.url("simpleTest.html"))
        with pytest.raises(NoSuchElementException):
            ef_driver.find_element(By.ID, "foo")
        assert b"NoSuchElementException is thrown" == log.getvalue()
開發者ID:zhjwpku,項目名稱:selenium,代碼行數:11,代碼來源:event_firing_webdriver_tests.py

示例8: test_should_be_able_to_access_wrapped_instance_from_event_calls

    def test_should_be_able_to_access_wrapped_instance_from_event_calls(self):
        driver = self.driver

        class TestListener(AbstractEventListener):
            def before_navigate_to(self, url, d):
                assert driver is d

        ef_driver = EventFiringWebDriver(driver, TestListener())
        wrapped_driver = ef_driver.wrapped_driver
        assert driver is wrapped_driver

        ef_driver.get(self._pageURL("simpleTest"))
開發者ID:Alsan,項目名稱:selenium,代碼行數:12,代碼來源:event_firing_webdriver_tests.py

示例9: test_should_fire_find_event

    def test_should_fire_find_event(self, driver, log, pages):

        class TestListener(AbstractEventListener):

            def before_find(self, by, value, driver):
                log.write(("before_find by %s %s" % (by, value)).encode())

            def after_find(self, by, value, driver):
                log.write(("after_find by %s %s" % (by, value)).encode())

        ef_driver = EventFiringWebDriver(driver, TestListener())
        ef_driver.get(pages.url("simpleTest.html"))
        e = ef_driver.find_element_by_id("oneline")
        assert "A single line of text" == e.text

        e = ef_driver.find_element_by_xpath("/html/body/p[1]")
        assert "A single line of text" == e.text

        ef_driver.get(pages.url("frameset.html"))
        elements = ef_driver.find_elements_by_css_selector("frame#sixth")
        assert 1 == len(elements)
        assert "frame" == elements[0].tag_name.lower()
        assert "sixth" == elements[0].get_attribute("id")

        assert (b"before_find by id oneline"
                b"after_find by id oneline"
                b"before_find by xpath /html/body/p[1]"
                b"after_find by xpath /html/body/p[1]"
                b"before_find by css selector frame#sixth"
                b"after_find by css selector frame#sixth") == log.getvalue()
開發者ID:glib-briia,項目名稱:selenium,代碼行數:30,代碼來源:event_firing_webdriver_tests.py

示例10: test_should_fire_click_event

    def test_should_fire_click_event(self, driver, log, pages):
        class TestListener(AbstractEventListener):
            def before_click(self, element, driver):
                log.write(b"before_click")

            def after_click(self, element, driver):
                log.write(b"after_click")

        ef_driver = EventFiringWebDriver(driver, TestListener())
        ef_driver.get(pages.url("clicks.html"))
        ef_driver.find_element(By.ID, "overflowLink").click()
        assert ef_driver.title == "XHTML Test Page"

        assert b"before_click" + b"after_click" == log.getvalue()
開發者ID:zhjwpku,項目名稱:selenium,代碼行數:14,代碼來源:event_firing_webdriver_tests.py

示例11: test_should_fire_find_event

    def test_should_fire_find_event(self):
        log = self.log

        class TestListener(AbstractEventListener):

            def before_find(self, by, value, driver):
                log.write(("before_find by %s %s" % (by, value)).encode())

            def after_find(self, by, value, driver):
                log.write(("after_find by %s %s" % (by, value)).encode())

        ef_driver = EventFiringWebDriver(self.driver, TestListener())
        ef_driver.get(self._pageURL("simpleTest"))
        e = ef_driver.find_element_by_id("oneline")
        self.assertEqual("A single line of text", e.text)

        e = ef_driver.find_element_by_xpath("/html/body/p[1]")
        self.assertEqual("A single line of text", e.text)

        ef_driver.get(self._pageURL("frameset"))
        elements = ef_driver.find_elements_by_css_selector("frame#sixth")
        self.assertEqual(1, len(elements))
        self.assertEqual("frame", elements[0].tag_name.lower())
        self.assertEqual("sixth", elements[0].get_attribute("id"))

        self.assertEqual(
            b"before_find by id oneline"
            b"after_find by id oneline"
            b"before_find by xpath /html/body/p[1]"
            b"after_find by xpath /html/body/p[1]"
            b"before_find by css selector frame#sixth"
            b"after_find by css selector frame#sixth", log.getvalue())
開發者ID:Alsan,項目名稱:selenium,代碼行數:32,代碼來源:event_firing_webdriver_tests.py

示例12: test_should_fire_click_event

 def test_should_fire_click_event(self):
     log = self.log
     
     class TestListener(AbstractEventListener):            
         def before_click(self, element, driver):
             log.write(b"before_click")
         def after_click(self, element, driver):
             log.write(b"after_click")
         
     ef_driver = EventFiringWebDriver(self.driver, TestListener())            
     ef_driver.get(self._pageURL("clicks"))        
     ef_driver.find_element(By.ID, "overflowLink").click() 
     self.assertEqual(ef_driver.title, "XHTML Test Page")
     
     self.assertEqual(b"before_click" + b"after_click", log.getvalue())
開發者ID:AnnikaXiao,項目名稱:selenium,代碼行數:15,代碼來源:event_firing_webdriver_tests.py

示例13: test_should_call_listener_when_an_exception_is_thrown

    def test_should_call_listener_when_an_exception_is_thrown(self):
        log = self.log

        class TestListener(AbstractEventListener):
            def on_exception(self, exception, driver):
                if isinstance(exception, NoSuchElementException):
                    log.write(b"NoSuchElementException is thrown")

        ef_driver = EventFiringWebDriver(self.driver, TestListener())
        ef_driver.get(self._pageURL("simpleTest"))
        try:
            ef_driver.find_element(By.ID, "foo")
            self.fail("Expected exception to be propagated")
        except NoSuchElementException:
            pass
        self.assertEqual(b"NoSuchElementException is thrown", log.getvalue())
開發者ID:Alsan,項目名稱:selenium,代碼行數:16,代碼來源:event_firing_webdriver_tests.py

示例14: test_should_fire_change_value_event

    def test_should_fire_change_value_event(self, driver, log, pages):

        class TestListener(AbstractEventListener):

            def before_change_value_of(self, element, driver):
                log.write(b"before_change_value_of")

            def after_change_value_of(self, element, driver):
                log.write(b"after_change_value_of")

        ef_driver = EventFiringWebDriver(driver, TestListener())
        ef_driver.get(pages.url("readOnlyPage.html"))
        element = ef_driver.find_element_by_id("writableTextInput")
        element.clear()
        assert "" == element.get_attribute("value")

        ef_driver.get(pages.url("javascriptPage.html"))
        keyReporter = ef_driver.find_element(by=By.ID, value="keyReporter")
        keyReporter.send_keys("abc def")
        assert keyReporter.get_attribute("value") == "abc def"

        assert (b"before_change_value_of"
                b"after_change_value_of"
                b"before_change_value_of"
                b"after_change_value_of") == log.getvalue()
開發者ID:glib-briia,項目名稱:selenium,代碼行數:25,代碼來源:event_firing_webdriver_tests.py

示例15: test_should_fire_change_value_event

    def test_should_fire_change_value_event(self):
        log = self.log

        class TestListener(AbstractEventListener):

            def before_change_value_of(self, element, driver):
                log.write(b"before_change_value_of")

            def after_change_value_of(self, element, driver):
                log.write(b"after_change_value_of")

        ef_driver = EventFiringWebDriver(self.driver, TestListener())
        ef_driver.get(self._pageURL("readOnlyPage"))
        element = ef_driver.find_element_by_id("writableTextInput")
        element.clear()
        self.assertEqual("", element.get_attribute("value"))

        ef_driver.get(self._pageURL("javascriptPage"))
        keyReporter = ef_driver.find_element(by=By.ID, value="keyReporter")
        keyReporter.send_keys("abc def")
        self.assertEqual(keyReporter.get_attribute("value"), "abc def")

        self.assertEqual(
            b"before_change_value_of"
            b"after_change_value_of"
            b"before_change_value_of"
            b"after_change_value_of", log.getvalue())
開發者ID:Alsan,項目名稱:selenium,代碼行數:27,代碼來源:event_firing_webdriver_tests.py


注:本文中的selenium.webdriver.support.events.EventFiringWebDriver類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。