当前位置: 首页>>代码示例>>Python>>正文


Python Marionette.set_pref方法代码示例

本文整理汇总了Python中marionette.Marionette.set_pref方法的典型用法代码示例。如果您正苦于以下问题:Python Marionette.set_pref方法的具体用法?Python Marionette.set_pref怎么用?Python Marionette.set_pref使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在marionette.Marionette的用法示例。


在下文中一共展示了Marionette.set_pref方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: TestConsoleLogCapture

# 需要导入模块: from marionette import Marionette [as 别名]
# 或者: from marionette.Marionette import set_pref [as 别名]
class TestConsoleLogCapture():
    def setup(self):
        try:
            self.client = Marionette(host='localhost', port=2828)
            self.client.start_session()
            self.client.set_pref('general.warnOnAboutConfig', False)
        except:
            sys.exit("Could not find Firefox browser running")

    def test_push_notification_received(self):
        self.client.navigate("https://people.mozilla.org/~ewong2/push-notification-test/")

        unregister_button = self.client.find_element(By.ID, "unreg_btn")
        if unregister_button.is_displayed() == True:
            unregister_button.click()
            Wait(self.client, timeout=5, interval=1).until(expected.element_not_displayed(By.ID, "unreg_btn"))

        Wait(self.client).until(expected.element_displayed(By.ID, "reg_btn"))
        self.client.find_element(By.ID, "reg_btn").click()
        Wait(self.client).until(expected.element_displayed(By.ID, "subscribe_btn"))
        self.client.find_element(By.ID, "subscribe_btn").click()
        Wait(self.client).until(expected.element_displayed(By.ID, "doXhr_btn"))
        self.client.find_element(By.ID, "doXhr_btn").click()

        result = self.web_console_filter_for_string("Received a push message")
        assert result == 1

    def web_console_filter_for_string(self, console_string=None):
        self.client.set_context(self.client.CONTEXT_CHROME)

        handles = self.client.window_handles
        chrome_handles = self.client.chrome_window_handles
        browser_handle = self.client.current_chrome_window_handle
        notifications = 0
        for handle in chrome_handles:
            if handle != browser_handle:
                console_handle = handle
                self.client.switch_to_window(console_handle)
                time.sleep(1)
                results = self.client.find_elements(By.CLASS_NAME, "console-string")
                for result in results:
                    if console_string in result.text:
                        notifications = notifications + 1
        self.client.find_element(By.CLASS_NAME, "webconsole-clear-console-button").click()
        return notifications


    def tear_down(self):
        self.client.close()
开发者ID:stuartphilp,项目名称:marionnette_webconsole,代码行数:51,代码来源:marionnette_webconsole_example.py


注:本文中的marionette.Marionette.set_pref方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。