本文整理汇总了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()