本文整理汇总了Python中marionette_driver.Wait.get_attribute方法的典型用法代码示例。如果您正苦于以下问题:Python Wait.get_attribute方法的具体用法?Python Wait.get_attribute怎么用?Python Wait.get_attribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类marionette_driver.Wait
的用法示例。
在下文中一共展示了Wait.get_attribute方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _switch_to_fxa_iframe
# 需要导入模块: from marionette_driver import Wait [as 别名]
# 或者: from marionette_driver.Wait import get_attribute [as 别名]
def _switch_to_fxa_iframe(self):
self.marionette.switch_to_frame()
iframe = Wait(self.marionette, timeout=60).until(
expected.element_present(*self._fxa_iframe_locator))
Wait(self.marionette).until(expected.element_displayed(iframe))
Wait(self.marionette, timeout=60).until(lambda m: iframe.get_attribute('data-url') != 'about:blank')
self.marionette.switch_to_frame(iframe)
示例2: __init__
# 需要导入模块: from marionette_driver import Wait [as 别名]
# 或者: from marionette_driver.Wait import get_attribute [as 别名]
def __init__(self, marionette):
Base.__init__(self, marionette)
self.switch_to_frame()
# wait for the page to load
email = Wait(self.marionette).until(
expected.element_present(*self._email_locator))
Wait(self.marionette).until(lambda m: email.get_attribute('value') != '')
示例3: tap_next
# 需要导入模块: from marionette_driver import Wait [as 别名]
# 或者: from marionette_driver.Wait import get_attribute [as 别名]
def tap_next(self):
next = Wait(self.marionette).until(expected.element_present(*self._next_locator))
Wait(self.marionette).until(lambda m: next.get_attribute('disabled') != 'true')
next.tap()
account = Wait(self.marionette).until(
expected.element_present(*self._account_prefs_section_locator))
Wait(self.marionette).until(lambda m: account.location['x'] == 0)
Wait(self.marionette, timeout=120).until(expected.element_displayed(
Wait(self.marionette, timeout=120).until(expected.element_present(
*self._account_prefs_next_locator))))
示例4: __init__
# 需要导入模块: from marionette_driver import Wait [as 别名]
# 或者: from marionette_driver.Wait import get_attribute [as 别名]
def __init__(self, marionette):
Base.__init__(self, marionette)
self.marionette.switch_to_frame()
# wait for the pop up screen to open
view = Wait(self.marionette, timeout=60).until(
expected.element_present(*self._iframe_locator))
Wait(self.marionette).until(expected.element_displayed(view))
# Change the app to make use of the Facebook developer appId
Wait(self.marionette, timeout=60).until(lambda m: view.get_attribute('data-url') != 'about:blank')
# Desktop b2g uses this
str = view.get_attribute('data-url').replace('123456', '323630664378726')
# Device uses this
str = str.replace('395559767228801', '323630664378726')
self.marionette.switch_to_frame(view)
# Wait until the original page has loaded a bit, because sometimes,
# trying to load the 2nd page directly after the first, causes a blank page
Wait(self.marionette, timeout=60).until(expected.element_present(*self._div_locator))
self.marionette.navigate(str)
Wait(self.marionette, timeout=60).until(expected.element_present(*self._email_locator))
示例5: enter_email
# 需要导入模块: from marionette_driver import Wait [as 别名]
# 或者: from marionette_driver.Wait import get_attribute [as 别名]
def enter_email(self, email=None):
self.marionette.switch_to_frame()
iframe = Wait(self.marionette, timeout=60).until(
expected.element_present(*self._iframe_locator))
Wait(self.marionette).until(expected.element_displayed(iframe))
Wait(self.marionette, timeout=60).until(lambda m: iframe.get_attribute('data-url') != 'about:blank')
self.marionette.switch_to_frame(iframe)
input = Wait(self.marionette, timeout=60).until(
expected.element_present(*self._input_locator))
Wait(self.marionette).until(expected.element_displayed(input))
input.send_keys(email)
# Wait until the keyboard is completely displayed, otherwise tapping
# the next button is unreliable
self.marionette.switch_to_frame()
Wait(self.marionette).until(lambda m: self.keyboard.is_keyboard_displayed)
self.marionette.switch_to_frame(iframe)
self.marionette.find_element(*self._next_locator).tap()
示例6: wait_for_radio_off
# 需要导入模块: from marionette_driver import Wait [as 别名]
# 或者: from marionette_driver.Wait import get_attribute [as 别名]
def wait_for_radio_off(self):
power = Wait(self.marionette).until(
expected.element_present(*self._power_button_locator))
Wait(self.marionette).until(
lambda m: not power.get_attribute('data-enabled') == 'true')
示例7: launch
# 需要导入模块: from marionette_driver import Wait [as 别名]
# 或者: from marionette_driver.Wait import get_attribute [as 别名]
def launch(self, airplane_mode=False):
Base.launch(self)
power = Wait(self.marionette).until(
expected.element_present(*self._power_button_locator))
if not airplane_mode:
Wait(self.marionette).until(lambda m: power.get_attribute('data-enabled') == 'true')
示例8: HTML5Player
# 需要导入模块: from marionette_driver import Wait [as 别名]
# 或者: from marionette_driver.Wait import get_attribute [as 别名]
class HTML5Player(PageRegion):
"""Represents HTML5 Player.
Reference:
http://www.w3.org/TR/2012/WD-html5-20121025/media-elements.html#media-element
"""
_video_element_locator = (By.TAG_NAME, 'video')
def __init__(self, marionette):
Base.__init__(self, marionette)
self.root_element = Wait(self.marionette).until(
expected.element_present(*self._video_element_locator))
Wait(self.marionette).until(
expected.element_displayed(self.root_element))
def wait_for_video_loaded(self):
# Wait long enough to make sure enough of the video has been loaded
Wait(self.marionette, timeout=60).until(
lambda m: int(self.root_element.get_attribute('readyState')) == 4)
@property
def is_fullscreen(self):
return self.marionette.execute_script("""return document.mozFullScreenElement ==
document.getElementsByTagName("video")[0]""")
@property
def is_playing(self):
return self.root_element.get_attribute('paused') != 'true'
@property
def is_muted(self):
return self.root_element.get_attribute('muted') == 'true'
@property
def is_ended(self):
return self.root_element.get_attribute('ended') == 'true'
@property
def controls_visible(self):
return (int(self.get_location('playButton')[0]) > 0)
def invoke_controls(self):
Wait(self.marionette).until(lambda m: not self.controls_visible)
self.root_element.tap()
Wait(self.marionette).until(lambda m: self.controls_visible)
def show_controls(self):
Wait(self.marionette).until(lambda m: not self.controls_visible)
self.marionette.execute_script("""
var a = Components.classes["@mozilla.org/inspector/dom-utils;1"]
.getService(Components.interfaces.inIDOMUtils)
.getChildrenForNode(document.getElementsByTagName('video')[0], true);
var x = a[1].ownerDocument.getAnonymousElementByAttribute(a[1],'class', 'controlBar');
x.removeAttribute('hidden');
""", sandbox='system')
Wait(self.marionette).until(lambda m: self.controls_visible)
def get_location(self, class_name):
return self.marionette.execute_script("""
var a = Components.classes["@mozilla.org/inspector/dom-utils;1"]
.getService(Components.interfaces.inIDOMUtils)
.getChildrenForNode(document.getElementsByTagName('video')[0], true);
var x1 = document.getElementsByTagName('video')[0].getBoundingClientRect().left;
var x2 = a[1].ownerDocument
.getAnonymousElementByAttribute(a[1],'class', '%s')
.getBoundingClientRect().left;
var y1 = document.getElementsByTagName('video')[0]
.getBoundingClientRect().top;
var y2 = a[1].ownerDocument.getAnonymousElementByAttribute(a[1],'class', '%s')
.getBoundingClientRect().top;
return (Math.floor(x2-x1) + ',' + Math.floor(y2-y1));
""" % (class_name, class_name), sandbox='system').split(',')
def tap_video_control(self, class_name):
location = self.get_location(class_name)
if location[0] <= 0 or location[1] <= 0:
print 'x=%d, y=%d' % (location[0], location[1])
self.assertTrue(False)
self.root_element.tap(x=int(location[0]) + 5, y=int(location[1]) + 5)
def tap_play(self):
self.tap_video_control('playButton')
Wait(self.marionette).until(lambda m: self.is_playing)
# Tapping the play button makes the controls disappear, wait for that to happen
Wait(self.marionette).until(lambda m: not self.controls_visible)
def tap_pause(self):
self.tap_video_control('playButton')
Wait(self.marionette).until(lambda m: not self.is_playing)
def tap_mute(self):
self.tap_video_control('muteButton')
Wait(self.marionette).until(lambda m: self.is_muted)
def tap_unmute(self):
self.tap_video_control('muteButton')
Wait(self.marionette).until(lambda m: not self.is_muted)
def tap_full_screen(self):
#.........这里部分代码省略.........
示例9: wallpaper_preview_src
# 需要导入模块: from marionette_driver import Wait [as 别名]
# 或者: from marionette_driver.Wait import get_attribute [as 别名]
def wallpaper_preview_src(self):
element = Wait(self.marionette).until(
expected.element_present(*self._wallpaper_preview_locator))
Wait(self.marionette).until(expected.element_displayed(element))
return element.get_attribute('src')
示例10: tap_portrait_crop
# 需要导入模块: from marionette_driver import Wait [as 别名]
# 或者: from marionette_driver.Wait import get_attribute [as 别名]
def tap_portrait_crop(self):
element = Wait(self.marionette).until(
expected.element_present(*self._crop_portrait_locator))
Wait(self.marionette).until(expected.element_displayed(element))
element.tap()
Wait(self.marionette).until(lambda m: 'selected' in element.get_attribute('class'))