本文整理汇总了Python中marionette.wait.Wait.until方法的典型用法代码示例。如果您正苦于以下问题:Python Wait.until方法的具体用法?Python Wait.until怎么用?Python Wait.until使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类marionette.wait.Wait
的用法示例。
在下文中一共展示了Wait.until方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_notification
# 需要导入模块: from marionette.wait import Wait [as 别名]
# 或者: from marionette.wait.Wait import until [as 别名]
def create_notification(self, text):
self.marionette.execute_async_script(
"""
window.wrappedJSObject.rcvd_onshow = false;
var text = arguments[0];
console.log("Creating new notification");
var notification = new Notification(text);
// setup callback
notification.onshow = function() {
console.log("Received Notification.onshow event");
window.wrappedJSObject.rcvd_onshow = true;
}
marionetteScriptFinished(1);
""",
script_args=[text])
# wait for notification to be displayed
wait = Wait(self.marionette, timeout=30, interval=0.5)
try:
wait.until(
lambda x: x.execute_script("return window.wrappedJSObject.rcvd_onshow")
)
except:
self.fail("Did not receive the Notification.onshow event")
示例2: setup_incoming_call
# 需要导入模块: from marionette.wait import Wait [as 别名]
# 或者: from marionette.wait.Wait import until [as 别名]
def setup_incoming_call(self):
self.marionette.execute_script(self.returnable_calls)
# listen for and answer incoming call
self.marionette.execute_async_script("""
var telephony = window.navigator.mozTelephony;
window.wrappedJSObject.received_incoming = false;
telephony.onincoming = function onincoming(event) {
log("Received 'incoming' call event.");
window.wrappedJSObject.received_incoming = true;
window.wrappedJSObject.incoming_call = event.call;
window.wrappedJSObject.returnable_incoming_call = {
number: event.call.number,
state: event.call.state
};
window.wrappedJSObject.calls = telephony.calls;
};
window.wrappedJSObject.received_callschanged = false;
telephony.oncallschanged = function oncallschanged(event) {
log("Received Telephony 'oncallschanged' event.");
window.wrappedJSObject.received_callschanged = true;
};
marionetteScriptFinished(1);
""", special_powers=True)
wait = Wait(self.marionette, timeout=90, interval=0.5)
try:
wait.until(lambda x: x.execute_script("return window.wrappedJSObject.received_callschanged"))
except:
self.fail("Telephony.oncallschanged event not found, but should have been "
"since initiated incoming call to firefox OS device")
示例3: get_message
# 需要导入模块: from marionette.wait import Wait [as 别名]
# 或者: from marionette.wait.Wait import until [as 别名]
def get_message(self, msg_id):
""" Get the sms or mms for the given id. Return the message, or none if it doesn't exist"""
self.marionette.execute_async_script("""
var mm = window.navigator.mozMobileMessage;
window.wrappedJSObject.event_sms = null;
window.wrappedJSObject.rcvd_event = false;
// Bug 952875
mm.getThreads();
let requestRet = mm.getMessage(arguments[0]);
requestRet.onsuccess = function(event) {
if(event.target.result){
window.wrappedJSObject.rcvd_event = true;
window.wrappedJSObject.event_sms = event.target.result;
}
};
requestRet.onerror = function() {
window.wrappedJSObject.rcvd_event = true;
log("Get message returned error: %s" % requestRet.error.name);
};
marionetteScriptFinished(1);
""", script_args=[msg_id], special_powers=True)
# wait for a result
wait = Wait(self.marionette, timeout=30, interval=0.5)
try:
wait.until(lambda m: m.execute_script("return window.wrappedJSObject.rcvd_event"))
except errors.TimeoutException:
self.fail("mozMobileMessage.getMessage() failed")
# return the message if it was found, otherwise none
return self.marionette.execute_script("return window.wrappedJSObject.event_sms")
示例4: delete_message
# 需要导入模块: from marionette.wait import Wait [as 别名]
# 或者: from marionette.wait.Wait import until [as 别名]
def delete_message(self, msg_id):
self.marionette.execute_async_script("""
var mm = window.navigator.mozMobileMessage;
window.wrappedJSObject.msg_deleted = false;
window.wrappedJSObject.rcvd_error = false;
// Bug 952875
mm.getThreads();
let requestRet = mm.delete(arguments[0]);
requestRet.onsuccess = function(event) {
if (event.target.result) {
window.wrappedJSObject.msg_deleted = true;
} else {
window.wrappedJSObject.msg_deleted = false;
}
};
requestRet.onerror = function() {
window.wrappedJSObject.rcvd_error = true;
log("Delete message returned error: %s" % requestRet.error.name);
};
marionetteScriptFinished(1);
""", script_args=[msg_id], special_powers=True)
# wait for request.onsuccess
wait = Wait(self.marionette, timeout=30, interval=0.5)
try:
wait.until(lambda m: m.execute_script("return window.wrappedJSObject.msg_deleted"))
except errors.TimeoutException:
if self.marionette.execute_script("return window.wrappedJSObject.rcvd_error;"):
self.fail("Error received while deleting message")
else:
self.fail("Failed to delete message")
示例5: wait_for_antenna_change
# 需要导入模块: from marionette.wait import Wait [as 别名]
# 或者: from marionette.wait.Wait import until [as 别名]
def wait_for_antenna_change(self):
# wait for radio to change state
wait = Wait(self.marionette, timeout=10, interval=0.5)
try:
wait.until(lambda x: x.execute_script("return window.wrappedJSObject.antenna_change"))
except:
self.fail("Failed to receive mozFMRadio.onantennaavailablechange event")
示例6: stop_bt_discovery
# 需要导入模块: from marionette.wait import Wait [as 别名]
# 或者: from marionette.wait.Wait import until [as 别名]
def stop_bt_discovery(self):
self.assertTrue(self.have_adapter, "Must get default bluetooth adapter first")
self.marionette.execute_async_script("""
window.wrappedJSObject.rcvd_success = false;
window.wrappedJSObject.rcvd_error = false;
var mozBtAdapter = window.wrappedJSObject.bt_adapter;
console.log("Stopping bluetooth discovery");
var request = mozBtAdapter.stopDiscovery();
request.onsuccess = function() {
console.log("BluetoothAdapter.stopDiscovery request success");
window.wrappedJSObject.rcvd_success = true;
};
request.onerror = function() {
console.log("BluetoothAdapter.stopDiscovery returned error");
window.wrappedJSObject.rcvd_error = true;
};
marionetteScriptFinished(1);
""")
# wait for request success
wait = Wait(self.marionette, timeout=30, interval=0.5)
try:
wait.until(lambda x: x.execute_script("return window.wrappedJSObject.rcvd_success"))
except:
if self.marionette.execute_script("return window.wrappedJSObject.rcvd_error"):
self.fail("BluetoothAdapter.stopDiscovery returned error")
else:
self.fail("BluetoothAdapter.stopDiscovery failed")
# verify no longer discovering
self.assertFalse(self.get_bt_discovering(), "Failed to stop bluetooth discovery")
示例7: set_geolocation_enabled
# 需要导入模块: from marionette.wait import Wait [as 别名]
# 或者: from marionette.wait.Wait import until [as 别名]
def set_geolocation_enabled(self, enable):
# turn on geolocation via the device settings
self.marionette.execute_async_script("""
var enable = arguments[0];
window.wrappedJSObject.rcvd_success = false;
window.wrappedJSObject.rcvd_error = false;
if (enable) {
console.log("Enabling geolocation via settings");
} else {
console.log("Disabling geolocation via settings");
}
var lock = window.navigator.mozSettings.createLock();
var result = lock.set({
'geolocation.enabled': enable
});
result.onsuccess = function() {
console.log("Success changing geolocation.enabled setting");
window.wrappedJSObject.rcvd_success = true;
};
result.onerror = function(error) {
console.log("Failed to change geolocation.enabled setting " + error);
window.wrappedJSObject.rcvd_error = true;
};
marionetteScriptFinished(1);
""", script_args=[enable])
# wait for enabled/disabled event
wait = Wait(self.marionette, timeout=30, interval=0.5)
try:
wait.until(lambda m: m.execute_script("return window.wrappedJSObject.rcvd_success"))
except:
if self.marionette.execute_script("return window.wrappedJSObject.rcvd_error;"):
self.fail("Error received while changing the geolocation enabled setting")
else:
self.fail("Failed to change the geolocation.enabled setting")
示例8: resume_held_call
# 需要导入模块: from marionette.wait import Wait [as 别名]
# 或者: from marionette.wait.Wait import until [as 别名]
def resume_held_call(self):
self.marionette.execute_async_script("""
let active = window.wrappedJSObject.active_call;
window.wrappedJSObject.received_statechange = false;
active.onstatechange = function onstatechange(event) {
log("Received TelephonyCall 'onstatechange' event.");
if (event.call.state == "resuming") {
window.wrappedJSObject.received_statechange = true;
};
};
window.wrappedJSObject.onresuming_call_ok = false;
active.onresuming = function onresuming(event) {
log("Received 'onresuming' call event.");
if (event.call.state == "resuming") {
window.wrappedJSObject.onresuming_call_ok = true;
};
};
active.resume();
marionetteScriptFinished(1);
""", special_powers=True)
# should have received event associated with a resumed call
wait = Wait(self.marionette, timeout=90, interval=0.5)
try:
wait.until(lambda x: x.execute_script("return window.wrappedJSObject.onresuming_call_ok"))
wait.until(lambda x: x.execute_script("return window.wrappedJSObject.received_statechange"))
except:
# failed to resume
self.fail("Failed to resume the held call")
示例9: test_active_state
# 需要导入模块: from marionette.wait import Wait [as 别名]
# 或者: from marionette.wait.Wait import until [as 别名]
def test_active_state(self):
self.instruct("About to test active state. Please click OK and then watch the screen")
self.marionette.execute_script("""
window.wrappedJSObject.testActiveObserver = {
time : 5,
onidle : function() {
window.navigator.mozPower.screenBrightness = 0.1;
window.wrappedJSObject.rcvd_idle = true;
},
onactive : function() {
window.navigator.mozPower.screenBrightness = 0.5;
window.wrappedJSObject.rcvd_active = true;
}
};
navigator.addIdleObserver(window.wrappedJSObject.testActiveObserver);
""")
wait = Wait(self.marionette, timeout=10, interval=0.5)
try:
wait.until(lambda m: m.execute_script("return window.wrappedJSObject.rcvd_idle;"))
except:
self.fail("Failed to attain idle state")
self.confirm("Did you notice decrease in brightness?")
self.instruct("Touch on the screen to wake up the device")
wait = Wait(self.marionette, timeout=10, interval=0.5)
try:
wait.until(lambda m: m.execute_script("return window.wrappedJSObject.rcvd_active;"))
except:
self.fail("Failed to attain active state")
self.confirm("Did you notice increase in brightness?")
示例10: test_telephony_outgoing_busy
# 需要导入模块: from marionette.wait import Wait [as 别名]
# 或者: from marionette.wait.Wait import until [as 别名]
def test_telephony_outgoing_busy(self):
self.instruct("Make a call to second non firefox OS phone from third non firefox "
"OS phone, answer the call on second phone and press OK")
# keep a short delay before making an outgoing call to second phone
time.sleep(2)
# use the webapi to make an outgoing call to user-specified number
self.user_guided_outgoing_call()
# verify one outgoing call
self.calls = self.marionette.execute_script("return window.wrappedJSObject.get_returnable_calls()")
self.assertEqual(self.calls['length'], 1, "There should be 1 call")
self.assertEqual(self.calls['0'], self.outgoing_call)
# should have received busy event associated with an outgoing call
wait = Wait(self.marionette, timeout=30, interval=0.5)
try:
wait.until(lambda x: x.execute_script("return window.wrappedJSObject.received_busy"))
except:
self.fail("Busy event is not found, but should have been, since the outgoing call "
"is initiated to busy line")
# keep call ringing for a while
time.sleep(1)
# disconnect the outgoing call
self.hangup_call(call_type="Outgoing")
self.calls = self.marionette.execute_script("return window.wrappedJSObject.get_returnable_calls()")
self.assertEqual(self.calls['length'], 0, "There should be 0 calls")
示例11: answer_call
# 需要导入模块: from marionette.wait import Wait [as 别名]
# 或者: from marionette.wait.Wait import until [as 别名]
def answer_call(self, incoming=True):
# answer incoming call via the webapi; have user answer outgoing call on target
self.marionette.execute_async_script("""
let incoming = arguments[0];
if (incoming) {
var call_to_answer = window.wrappedJSObject.incoming_call;
} else {
var call_to_answer = window.wrappedJSObject.outgoing_call;
};
window.wrappedJSObject.connecting_call_ok = false;
call_to_answer.onconnecting = function onconnecting(event) {
log("Received 'onconnecting' call event.");
if (event.call.state == "connecting") {
window.wrappedJSObject.connecting_call_ok = true;
};
};
window.wrappedJSObject.connected_call_ok = false;
call_to_answer.onconnected = function onconnected(event) {
log("Received 'onconnected' call event.");
if (event.call.state == "connected") {
window.wrappedJSObject.active_call = window.navigator.mozTelephony.active;
window.wrappedJSObject.connected_call_ok = true;
};
};
// answer incoming call via webapi; outgoing will be by user interaction
if (incoming) {
call_to_answer.answer();
};
marionetteScriptFinished(1);
""", script_args=[incoming], special_powers=True)
# answer outgoing call via user answering on target
if not incoming:
self.instruct("Please answer the call on the target phone, then click 'OK'")
# should have received both events associated with answering a call
wait = Wait(self.marionette, timeout=90, interval=0.5)
try:
if incoming: # only receive 'onconnecting' for incoming call
wait.until(lambda x: x.execute_script("return window.wrappedJSObject.connecting_call_ok"))
wait.until(lambda x: x.execute_script("return window.wrappedJSObject.connected_call_ok"))
except:
self.fail("Failed to answer call")
# verify the active call
self.active_call = self.marionette.execute_script("return window.wrappedJSObject.active_call")
self.assertTrue(self.active_call['state'], "connected")
if incoming:
self.assertEqual(self.active_call['number'], self.incoming_call['number'])
else:
self.assertEqual(self.active_call['number'], self.outgoing_call['number'])
self.calls = self.marionette.execute_script("return window.wrappedJSObject.calls")
self.assertEqual(self.calls['length'], 1, "There should be 1 active call" )
self.assertEqual(self.calls['0'], self.active_call)
示例12: set_wifi_enabled
# 需要导入模块: from marionette.wait import Wait [as 别名]
# 或者: from marionette.wait.Wait import until [as 别名]
def set_wifi_enabled(self, enable):
self.marionette.execute_async_script(
"""
var enable = arguments[0];
window.wrappedJSObject.rcvd_enabled_event = false;
window.wrappedJSObject.rcvd_disabled_event = false;
window.wrappedJSObject.rcvd_error = false;
var mozWifi = window.navigator.mozWifiManager;
mozWifi.onenabled = function() {
console.log("Received mozWifiManager.onenabled event");
window.wrappedJSObject.rcvd_enabled_event = true;
};
mozWifi.ondisabled = function() {
console.log("Received mozWifiManager.ondisabled event");
window.wrappedJSObject.rcvd_disabled_event = true;
};
if (enable) {
console.log("Turning on Wifi via settings");
} else {
console.log("Turning off Wifi via settings");
}
var lock = window.navigator.mozSettings.createLock();
var result = lock.set({
'wifi.enabled': enable
});
result.onerror = function() {
if (enable) {
console.log("Failed to changed Wifi setting to ON");
} else {
console.log("Failed to changed Wifi setting to OFF");
}
window.wrappedJSObject.rcvd_error = true;
};
marionetteScriptFinished(1);
""",
script_args=[enable],
)
# wait for enabled/disabled event
wait = Wait(self.marionette, timeout=30, interval=0.5)
try:
if enable:
wait.until(lambda m: m.execute_script("return window.wrappedJSObject.rcvd_enabled_event;"))
else:
wait.until(lambda m: m.execute_script("return window.wrappedJSObject.rcvd_disabled_event;"))
except:
if self.marionette.execute_script("return window.wrappedJSObject.rcvd_error;"):
self.fail("Error received while changing the wifi enabled setting")
else:
if enable:
self.fail("Failed to enable wifi via mozSettings")
else:
self.fail("Failed to disable wifi via mozSettings")
示例13: get_default_bt_adapter
# 需要导入模块: from marionette.wait import Wait [as 别名]
# 或者: from marionette.wait.Wait import until [as 别名]
def get_default_bt_adapter(self):
self.marionette.execute_async_script("""
window.wrappedJSObject.rcvd_success = false;
window.wrappedJSObject.rcvd_error = false;
window.wrappedJSObject.bt_adapter = null;
var mozBt = window.navigator.mozBluetooth;
console.log("Getting default bluetooth adaptor");
var request = mozBt.getDefaultAdapter();
request.onsuccess = function() {
console.log("mozBluetooth.getDefaultAdapter request success");
window.wrappedJSObject.rcvd_success = true;
window.wrappedJSObject.bt_adapter = request.result;
};
request.onerror = function() {
console.log("mozBluetooth.getDefaultAdapter request returned error");
window.wrappedJSObject.rcvd_error = true;
};
marionetteScriptFinished(1);
""")
# wait for adapter to be found
wait = Wait(self.marionette, timeout=30, interval=0.5)
try:
wait.until(lambda x: x.execute_script("return window.wrappedJSObject.rcvd_success"))
except:
if self.marionette.execute_script("return window.wrappedJSObject.rcvd_error"):
self.fail("mozBluetooth.getDefaultAdapter returned error")
else:
self.fail("mozBluetooth.getDefaultAdapter failed")
# https://developer.mozilla.org/en-US/docs/Web/API/BluetoothAdapter
# TODO: work around until bug https://bugzilla.mozilla.org/show_bug.cgi?id=1138331 is fixed
adapter = {}
adapter['name'] = self.marionette.execute_script("return window.wrappedJSObject.bt_adapter.name")
adapter['class'] = self.marionette.execute_script("return window.wrappedJSObject.bt_adapter.class")
adapter['address'] = self.marionette.execute_script("return window.wrappedJSObject.bt_adapter.address")
adapter['discoverable'] = self.marionette.execute_script("return window.wrappedJSObject.bt_adapter.discoverable")
adapter['discoverableTimeout'] = self.marionette.execute_script("return window.wrappedJSObject.bt_adapter.discoverableTimeout")
adapter['discovering'] = self.marionette.execute_script("return window.wrappedJSObject.bt_adapter.discovering")
adapter['devices'] = self.marionette.execute_script("return window.wrappedJSObject.bt_adapter.devices")
adapter['uuids'] = self.marionette.execute_script("return window.wrappedJSObject.bt_adapter.uuids")
self.assertIsNotNone(adapter, "mozBluetooth.getDefaultAdapter returned none")
self.have_adapter = True
return adapter
示例14: set_bt_discoverable_mode
# 需要导入模块: from marionette.wait import Wait [as 别名]
# 或者: from marionette.wait.Wait import until [as 别名]
def set_bt_discoverable_mode(self, set_discoverable):
self.assertTrue(self.have_adapter, "Must get default bluetooth adapter first")
self.marionette.execute_async_script("""
window.wrappedJSObject.rcvd_success = false;
window.wrappedJSObject.rcvd_error = false;
var mozBtAdapter = window.wrappedJSObject.bt_adapter;
var set_discoverable = arguments[0];
if (set_discoverable == true){
console.log("Turning on bluetooth discoverable mode");
} else {
console.log("Turning off bluetooth discoverable mode");
}
var request = mozBtAdapter.setDiscoverable(set_discoverable);
request.onsuccess = function() {
console.log("BluetoothAdapter.setDiscoverable request success");
window.wrappedJSObject.rcvd_success = true;
};
request.onerror = function() {
console.log("BluetoothAdapter.setDiscoverable returned error");
window.wrappedJSObject.rcvd_error = true;
};
marionetteScriptFinished(1);
""", script_args=[set_discoverable])
# wait for request success
wait = Wait(self.marionette, timeout=30, interval=0.5)
try:
wait.until(lambda x: x.execute_script("return window.wrappedJSObject.rcvd_success"))
except:
if self.marionette.execute_script("return window.wrappedJSObject.rcvd_error"):
self.fail("BluetoothAdapter.setDiscoverable returned error")
else:
self.fail("BluetoothAdapter.setDiscoverable failed")
discoverable_setting = self.marionette.execute_script("return window.wrappedJSObject.bt_adapter.discoverable")
if set_discoverable:
self.assertTrue(discoverable_setting, "Firefox OS BluetoothAdapter.discoverable should be TRUE")
else:
self.assertFalse(discoverable_setting, "Firefox OS BluetoothAdapter.discoverable should be FALSE")
示例15: start_bt_discovery
# 需要导入模块: from marionette.wait import Wait [as 别名]
# 或者: from marionette.wait.Wait import until [as 别名]
def start_bt_discovery(self):
self.assertTrue(self.have_adapter, "Must get default bluetooth adapter first")
self.marionette.execute_async_script("""
window.wrappedJSObject.found_device_count = 0;
window.wrappedJSObject.rcvd_success = false;
window.wrappedJSObject.rcvd_error = false;
var mozBtAdapter = window.wrappedJSObject.bt_adapter;
// Setup callback for when a bt device is found
mozBtAdapter.ondevicefound = function () {
console.log("Discovery found a bluetooth device nearby");
window.wrappedJSObject.found_device_count++;
};
// Begin discovery and verify request success
console.log("Starting bluetooth discovery");
var request = mozBtAdapter.startDiscovery();
request.onsuccess = function() {
console.log("BluetoothAdapter.startDiscovery request success");
window.wrappedJSObject.rcvd_success = true;
};
request.onerror = function() {
console.log("BluetoothAdapter.startDiscovery returned error");
window.wrappedJSObject.rcvd_error = true;
};
marionetteScriptFinished(1);
""")
# wait for request success
wait = Wait(self.marionette, timeout=30, interval=0.5)
try:
wait.until(lambda x: x.execute_script("return window.wrappedJSObject.rcvd_success"))
except:
if self.marionette.execute_script("return window.wrappedJSObject.rcvd_error"):
self.fail("BluetoothAdapter.startDiscovery returned error")
else:
self.fail("BluetoothAdapter.startDiscovery failed")
# verify in discovering mode
self.assertTrue(self.get_bt_discovering(), "Failed to start bluetooth discovery")