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


Python wait.Wait类代码示例

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


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

示例1: set_bt_enabled

    def set_bt_enabled(self, enable):
        self.get_default_bt_adapter()

        if enable:
            self.marionette.execute_async_script("""
                window.wrappedJSObject.bt_adapter.enable();
                marionetteScriptFinished(1);
            """)
        else:
            self.marionette.execute_async_script("""
                window.wrappedJSObject.bt_adapter.disable();
                marionetteScriptFinished(1);
            """)


        # 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.bt_adapter.state == 'enabled';"))
            else:
                wait.until(lambda m: m.execute_script("return window.wrappedJSObject.bt_adapter.state == 'disabled';"))
        except:
            if enable:
                self.fail("Failed to enable bluetooth")
            else:
                self.fail("Failed to disable bluetooth")
开发者ID:JJTC-PX,项目名称:fxos-certsuite,代码行数:27,代码来源:bluetooth_test.py

示例2: 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:JJTC-PX,项目名称:fxos-certsuite,代码行数:35,代码来源:geolocation_test.py

示例3: hold_active_call

    def hold_active_call(self, user_initiate_hold=True):
        self.marionette.execute_async_script("""
        let active = window.wrappedJSObject.active_call;
        var user_initiate_hold = arguments[0];

        window.wrappedJSObject.received_statechange = false;
        active.onstatechange = function onstatechange(event) {
        console.log("Received TelephonyCall 'onstatechange' event.");
          if (event.call.state == "held") {
            window.wrappedJSObject.received_statechange = true;
          };
        };

        window.wrappedJSObject.onheld_call_ok = false;
        active.onheld = function ondisconnected(event) {
          console.log("Received 'onheld' call event.");
          if (event.call.state == "held") {
            window.wrappedJSObject.onheld_call_ok = true;
          };
        };
        if (user_initiate_hold) {
          active.hold();
        }
        marionetteScriptFinished(1);
        """, script_args=[user_initiate_hold])

        if user_initiate_hold == True:
            # should have received both events associated with a call on hold
            wait = Wait(self.marionette, timeout=90, interval=0.5)
            try:
                wait.until(lambda x: x.execute_script("return window.wrappedJSObject.onheld_call_ok"))
                wait.until(lambda x: x.execute_script("return window.wrappedJSObject.received_statechange"))
            except:
                # failed to hold
                self.fail("Failed to put call on hold initiated by user")
开发者ID:JJTC-PX,项目名称:fxos-certsuite,代码行数:35,代码来源:telephony_test.py

示例4: 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) {
        console.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) {
          console.log("Received 'onresuming' call event.");
          if (event.call.state == "resuming") {
            window.wrappedJSObject.onresuming_call_ok = true;
          };
        };

        active.resume();
        marionetteScriptFinished(1);
        """)

        # 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:JJTC-PX,项目名称:fxos-certsuite,代码行数:32,代码来源:telephony_test.py

示例5: 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:JJTC-PX,项目名称:fxos-certsuite,代码行数:7,代码来源:fm_radio_test.py

示例6: assert_message_sent

    def assert_message_sent(self):
        """
        After sending an SMS/MMS, call this method to wait for the message to be sent.
        Verify that a mobile message was sent by checking if the expected events were triggered.
        Once verified, set the out_msg attribute to point to the message that has been sent.
        """
        wait = Wait(self.marionette, timeout=90, interval=0.5)
        try:
            wait.until(lambda m: self.marionette.execute_script("return window.wrappedJSObject.rcvd_req_success"))
        except errors.TimeoutException:
            # msg wasn't sent; either the api is broken or mobile network signal is insufficient
            self.fail(
                "Failed to send message. The API is broken -or- "
                "perhaps there is no mobile network signal. Please try again"
            )

        # verify the remaining msg send events
        rcvd_failed = self.marionette.execute_script("return window.wrappedJSObject.rcvd_on_failed")
        self.assertFalse(rcvd_failed, "Failed to send message; received mozMobileMessage.onfailed event")
        rcvd_sending = self.marionette.execute_script("return window.wrappedJSObject.rcvd_on_sending")
        self.assertTrue(rcvd_sending, "Failed to send message; mozMobileMessage.onsending event not received")
        rcvd_sent = self.marionette.execute_script("return window.wrappedJSObject.rcvd_on_sent")
        self.assertTrue(rcvd_sent, "Failed to send message; mozMobileMessage.onsent event not received")

        # get message event
        self.out_msg = self.marionette.execute_script("return window.wrappedJSObject.out_msg")
开发者ID:pombredanne,项目名称:fxos-certsuite,代码行数:26,代码来源:mobile_message_test.py

示例7: set_bt_discoverable_mode

    def set_bt_discoverable_mode(self, set_discoverable):
        self.set_bt_enabled(True)

        if set_discoverable:
            self.marionette.execute_async_script("""
                window.wrappedJSObject.bt_adapter.setDiscoverable(true);
                marionetteScriptFinished(1);
            """)
        else:
            self.marionette.execute_async_script("""
                window.wrappedJSObject.bt_adapter.disable(false);
                marionetteScriptFinished(1);
            """)

        # wait for enabled/disabled event
        wait = Wait(self.marionette, timeout=30, interval=0.5)
        try:
            if set_discoverable:
                wait.until(lambda m: m.execute_script("return window.wrappedJSObject.bt_adapter.discoverable == true;"))
            else:
                wait.until(lambda m: m.execute_script("return window.wrappedJSObject.bt_adapter.discoverable == false;"))
        except:
            if set_discoverable:
                self.fail("Failed to enable bluetooth discoverable")
            else:
                self.fail("Failed to disable bluetooth discoverable")
开发者ID:JJTC-PX,项目名称:fxos-certsuite,代码行数:26,代码来源:bluetooth_test.py

示例8: 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:JJTC-PX,项目名称:fxos-certsuite,代码行数:28,代码来源:test_telephony_outgoing_busy.py

示例9: tap_songs_tab

 def tap_songs_tab(self):
     element = Wait(self.marionette).until(expected.element_present(*self._songs_tab_locator))
     Wait(self.marionette).until(expected.element_displayed(element))
     element.tap()
     if self.marionette.find_element(*self._top_bannder_locator).text != "Songs":
         return Mtbf_ListView(self.marionette)
     else:
         return Mtbf_ListView(self.marionette, bolScrollingCheck=False)
开发者ID:mwargers,项目名称:MTBF-Driver,代码行数:8,代码来源:app.py

示例10: 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:JJTC-PX,项目名称:fxos-certsuite,代码行数:55,代码来源:wifi_test.py

示例11: 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.received_statechange = false;
        call_to_answer.onstatechange = function onstatechange(event) {
        console.log("Received TelephonyCall 'onstatechange' event.");
          if (event.call.state == "connected") {
            window.wrappedJSObject.received_statechange = true;
          };    
        };

        window.wrappedJSObject.connected_call_ok = false;
        call_to_answer.onconnected = function onconnected(event) {
          console.log("Received 'onconnected' call event.");
          if (event.call.state == "connected") {
            window.wrappedJSObject.active_call = window.navigator.mozTelephony.active;
            window.wrappedJSObject.returnable_active_call = {
                state: window.navigator.mozTelephony.active.state,
                number: window.navigator.mozTelephony.active.number
            };
            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])

        # 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:
            wait.until(lambda x: x.execute_script("return window.wrappedJSObject.connected_call_ok"))
            wait.until(lambda x: x.execute_script("return window.wrappedJSObject.received_statechange"))
        except:
            self.fail("Failed to answer call")

        # append new call to the active call list
        self.active_call_list.append(self.marionette.execute_script("return window.wrappedJSObject.returnable_active_call"))
开发者ID:JJTC-PX,项目名称:fxos-certsuite,代码行数:54,代码来源:telephony_test.py

示例12: bt_discovery

    def bt_discovery(self, set_discovering):
        self.set_bt_enabled(True)

        if set_discovering:
            self.marionette.execute_async_script("""
            window.wrappedJSObject.found_device_count = 0;
            var discoveryHandle;

            window.wrappedJSObject.bt_adapter.startDiscovery().then ( function onResolve(handle) {
              console.log("Resolved with discoveryHandle");

              // Keep reference to handle in order to listen to ondevicefound event handler 
              discoveryHandle = handle;
              discoveryHandle.ondevicefound = function onDeviceFound(evt) {
                var device = evt.device;
                console.log("Discovered remote device. Address:", device.address);
                window.wrappedJSObject.found_device_count++;
              };
            }, function onReject(aReason) {
              console.log("Rejected with this reason: " + aReason);
            });

            marionetteScriptFinished(1);
            """)
        else:
            self.marionette.execute_async_script("""
            window.wrappedJSObject.bt_adapter.stopDiscovery().then ( function onResolve() {
              console.log("Resolved with void value");
            }, function onReject(aReason) {
              console.log("Rejected with this reason: " + aReason);
            });

            marionetteScriptFinished(1);
            """)

        # wait for request success
        wait = Wait(self.marionette, timeout=30, interval=0.5)
        try:
            if set_discovering:
                wait.until(lambda m: m.execute_script("return window.wrappedJSObject.bt_adapter.discovering == true;"))
            else:
                wait.until(lambda m: m.execute_script("return window.wrappedJSObject.bt_adapter.discovering == false;"))
        except:
            if set_discovering:
                self.fail("Failed to enable bluetooth discovering")
            else:
                self.fail("Failed to disable bluetooth discovering")
开发者ID:JJTC-PX,项目名称:fxos-certsuite,代码行数:47,代码来源:bluetooth_test.py

示例13: 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) {
          console.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) {
          console.log("Received Telephony 'oncallschanged' event.");
          window.wrappedJSObject.received_callschanged = true;
        };

        window.wrappedJSObject.received_ready = false;
        telephony.ready.then(
          function() {
            console.log("Telephony got ready");
            window.wrappedJSObject.received_ready = true;
          },
          function() {
            console.log("Telephony not ready");
            window.wrappedJSObject.received_ready = false;
         }
        );

        marionetteScriptFinished(1);
        """)

        wait = Wait(self.marionette, timeout=90, interval=0.5)
        try:
            wait.until(lambda x: x.execute_script("return window.wrappedJSObject.received_ready"))
        except:
            self.fail("Telephony.oncallschanged event not found, but should have been "
                      "since initiated incoming call to firefox OS device")
开发者ID:JJTC-PX,项目名称:fxos-certsuite,代码行数:45,代码来源:telephony_test.py

示例14: mark_message_status

    def mark_message_status(self, msg_id, is_read=False):
        self.marionette.execute_async_script(
            """
        var msg_id = arguments[0];
        var is_read = arguments[1];
        var requestRet = null;

        var mm = window.navigator.mozMobileMessage;
        // Bug 952875
        mm.getThreads();

        requestRet = mm.markMessageRead(msg_id, is_read);
        window.wrappedJSObject.rcvd_req_success_read = false;
        window.wrappedJSObject.rcvd_req_success_unread = false;
        requestRet.onsuccess = function(event) {
            log("Received 'onsuccess' event.");
            if (event.target.result) {
                window.wrappedJSObject.rcvd_req_success_read = true;
            } else {
                window.wrappedJSObject.rcvd_req_success_unread = true;
                log("request returned false for manager.markMessageRead");
            }
        }

        requestRet.onerror = function() {
            log("Failed to mark message read status, received error: %s" % requestRet.error.name);
        };
        marionetteScriptFinished(1);
        """,
            script_args=[msg_id, is_read],
        )

        wait = Wait(self.marionette, timeout=15, interval=0.5)
        try:
            if is_read is True:
                wait.until(
                    lambda m: self.marionette.execute_script("return window.wrappedJSObject.rcvd_req_success_read")
                )
            else:
                wait.until(
                    lambda m: self.marionette.execute_script("return window.wrappedJSObject.rcvd_req_success_unread")
                )
        except errors.TimeoutException:
            # msg read status wasn't marked
            self.fail("Failed to update the read status of message.")
开发者ID:pombredanne,项目名称:fxos-certsuite,代码行数:45,代码来源:mobile_message_test.py

示例15: test_on_install

    def test_on_install(self):
        # FIXME: Issue #728;   [Restartlessness] RP should not cause
        #        JavaScript errors on shutdown while requests are being called.
        time.sleep(0.2)

        self.rp_addon.uninstall()

        self.prefs.set_pref(PREF_WELCOME_WIN_SHOWN, False)

        self.rp_addon.install()

        setup_tab = Wait(self.marionette).until(
            lambda m: self._get_setup_tab(),
            message="RequestPolicy has opened its Setup page.")
        self.assertTrue(self.prefs.get_pref(PREF_WELCOME_WIN_SHOWN),
                        msg=("The 'welcome window shown' pref has "
                             "been set to `true`."))
        self.assertTrue(setup_tab.selected,
                        msg="The setup tab is selected.")
        setup_tab.close()
开发者ID:RequestPolicyContinued,项目名称:requestpolicy,代码行数:20,代码来源:test_setup_page.py


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