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


Python wait.Wait类代码示例

本文整理汇总了Python中marionette.wait.Wait的典型用法代码示例。如果您正苦于以下问题:Python Wait类的具体用法?Python Wait怎么用?Python Wait使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: tap_call_button

 def tap_call_button(self, switch_to_call_screen=True):
     element = Wait(self.marionette).until(
         expected.element_present(*self._call_bar_locator))
     Wait(self.marionette).until(expected.element_enabled(element))
     element.tap()
     if switch_to_call_screen:
         return CallScreen(self.marionette)
开发者ID:bebef1987,项目名称:gaia,代码行数:7,代码来源:keypad.py

示例2: delete_message

    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")
开发者ID:armenzg,项目名称:fxos-certsuite,代码行数:33,代码来源:mobile_message_test.py

示例3: tap_new_alarm

 def tap_new_alarm(self):
     new_alarm = Wait(self.marionette).until(
         expected.element_present(*self._alarm_create_new_locator))
     Wait(self.marionette).until(expected.element_displayed(new_alarm))
     new_alarm.tap()
     from gaiatest.apps.clock.regions.alarm import NewAlarm
     return NewAlarm(self.marionette)
开发者ID:6a68,项目名称:gaia,代码行数:7,代码来源:app.py

示例4: get_message

    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")
开发者ID:armenzg,项目名称:fxos-certsuite,代码行数:34,代码来源:mobile_message_test.py

示例5: create_notification

    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")
开发者ID:jonallengriffin,项目名称:fxos-certsuite,代码行数:27,代码来源:notification_test.py

示例6: set_geolocation_enabled

    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")
开发者ID:Mozilla-TWQA,项目名称:fxos-certsuite,代码行数:35,代码来源:geolocation_test.py

示例7: setup_incoming_call

    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")
开发者ID:Mozilla-TWQA,项目名称:fxos-certsuite,代码行数:33,代码来源:telephony_test.py

示例8: stop_bt_discovery

    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")
开发者ID:armenzg,项目名称:fxos-certsuite,代码行数:35,代码来源:bluetooth_test.py

示例9: wait_for_antenna_change

 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")
开发者ID:jonallengriffin,项目名称:fxos-certsuite,代码行数:7,代码来源:fm_radio_test.py

示例10: resume_held_call

    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")
开发者ID:Predator-Design-Studios,项目名称:fxos-certsuite,代码行数:32,代码来源:telephony_test.py

示例11: test_telephony_outgoing_busy

    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")
开发者ID:Predator-Design-Studios,项目名称:fxos-certsuite,代码行数:28,代码来源:test_telephony_outgoing_busy.py

示例12: answer_call

    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)
开发者ID:gnaneswar,项目名称:fxos-certsuite,代码行数:59,代码来源:telephony_test.py

示例13: set_wifi_enabled

    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")
开发者ID:jonallengriffin,项目名称:fxos-certsuite,代码行数:58,代码来源:wifi_test.py

示例14: hangup_call

    def hangup_call(self, call_type="Active", remote_hangup=False):
        # hangup the active/incoming call, verify
        self.marionette.execute_async_script("""
        var call_type = arguments[0];
        var remote_hangup = arguments[1];
        if (call_type == "Incoming") {
          var call_to_hangup = window.wrappedJSObject.incoming_call;
        } else if (call_type == "Outgoing") {
          var call_to_hangup = window.wrappedJSObject.outgoing_call;
        } else {
          var call_to_hangup = window.wrappedJSObject.active_call;
        };

        window.wrappedJSObject.disconnecting_call_ok = false;
        call_to_hangup.ondisconnecting = function ondisconnecting(event) {
          log("Received 'ondisconnecting' call event.");
          if (event.call.state == "disconnecting") {
            window.wrappedJSObject.disconnecting_call_ok = true;
          };
        };

        window.wrappedJSObject.disconnected_call_ok = false;
        call_to_hangup.ondisconnected = function ondisconnected(event) {
          log("Received 'ondisconnected' call event.");
          if (event.call.state == "disconnected") {
            window.wrappedJSObject.disconnected_call_ok = true;
          };
        };

        if (!remote_hangup) {
          call_to_hangup.hangUp();
        }

        marionetteScriptFinished(1);
        """, script_args=[call_type, remote_hangup], special_powers=True)

        if remote_hangup == False:
            # should have received both events associated with a active call hangup
            wait = Wait(self.marionette, timeout=90, interval=0.5)
            try:
                wait.until(lambda x: x.execute_script("return window.wrappedJSObject.disconnecting_call_ok"))
                wait.until(lambda x: x.execute_script("return window.wrappedJSObject.disconnected_call_ok"))
            except:
                # failed to hangup
                self.fail("Failed to hangup call")
        else:
            self.instruct("Hangup the call from secondary phone and press 'OK'")
            # should have received only disconnected event associated with a active call hangup
            wait = Wait(self.marionette, timeout=90, interval=0.5)
            try:
                wait.until(lambda x: x.execute_script("return window.wrappedJSObject.disconnected_call_ok"))
            except:
                # failed to hangup
                self.fail("Failed to hangup call")

            #verify that the call disconnected from phone which is not the device under test
            disconnecting = self.marionette.execute_script("return window.wrappedJSObject.disconnecting_call_ok")
            self.assertFalse(disconnecting, "Telephony.ondisconnecting event found, but should not have been "
                            "since the call was terminated remotely")
开发者ID:armenzg,项目名称:fxos-certsuite,代码行数:59,代码来源:telephony_test.py

示例15: get_default_bt_adapter

    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
开发者ID:Predator-Design-Studios,项目名称:fxos-certsuite,代码行数:47,代码来源:bluetooth_test.py


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