本文整理汇总了Python中marionette.Marionette.set_search_timeout方法的典型用法代码示例。如果您正苦于以下问题:Python Marionette.set_search_timeout方法的具体用法?Python Marionette.set_search_timeout怎么用?Python Marionette.set_search_timeout使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类marionette.Marionette
的用法示例。
在下文中一共展示了Marionette.set_search_timeout方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: dual_driving
# 需要导入模块: from marionette import Marionette [as 别名]
# 或者: from marionette.Marionette import set_search_timeout [as 别名]
def dual_driving():
mm = Marionette(host='localhost', port=2829)
mm.start_session()
md = Marionette(host='localhost', port=2828)
md.start_session()
md.set_search_timeout(1000) # especially required for webcompat.com JS-driven loading
ignored_bugs = []
buglist = []
for line in open(ignore_file, 'r'):
if line[0] == '#':
continue
ignored_bugs.append(line.strip())
if start_url:
print 'Starting from bug search %s' % start_url
md.navigate(start_url)
buglist = extract_buglist(md)
else:
buglist = extract_buglist_from_file(filename)
i = 1
for item in buglist:
if len(item) <= 1:
print 'Warning: we expect data format ID Summary URL, something is missing'
continue
if '://' not in item[0]: # assuming this is Bugzilla data from a tab-separated file - in other words a plain bug number
md.navigate('https://bugzilla.mozilla.org/show_bug.cgi?id=%s' % item[0])
else: # we've got a bug tracker URL (right?)
md.navigate(item[0])
if len(item) == 2: # URL is not in the data - let's load the bug first and try to get it from there
url = get_url_from_bugpage(md)
else:
url = item[2]
if not url:
i+=1
continue
if i<start_at or url.strip() == '':
i+=1
continue
if '://' not in url:
url = 'http://%s' % url
url = url.strip().rstrip('\r\n')
location = urlparse.urlparse(url)
hostname = location.hostname.rstrip('\r\n')
print str(i) + ' : ' + url
reset_spoof(mm)
mm.navigate(url)
print 'READY to analyze %s, \n%s' % (item[0], item[1])
options_menu(mm, url, md)
mm.delete_session()
md.delete_session()
示例2: current_frame
# 需要导入模块: from marionette import Marionette [as 别名]
# 或者: from marionette.Marionette import set_search_timeout [as 别名]
class current_frame():
def main(self, p_snippet, p_frame_array=False):
#
# p_el is an array for the element.
# p_frame_array is a list of iframes to iterate through (optional).
#
self.marionette = Marionette(host='localhost', port=2828)
self.marionette.start_session()
self.marionette.set_search_timeout(1000)
self.actions = Actions(self.marionette)
#
# Switch to the correct iframe (unless it's "()").
#
self.marionette.switch_to_frame()
first_iframe = True
for x in p_frame_array:
# (just to make it look nice ;)
typ_str = "'" + x[0] + "'"
if first_iframe:
first_iframe = False
print ""
print "Switching to iframe with " + typ_str.rjust(10) + " = '" + x[1] + "'"
else:
print "... then to iframe with " + typ_str.rjust(10) + " = '" + x[1] + "'"
my_iframe = self.marionette.find_element("xpath", "//iframe[@" + x[0] + "='" + x[1] + "']")
self.marionette.switch_to_frame(my_iframe)
if first_iframe:
print ""
print "Using 'top level' iframe () ..."
# Run the code snippet.
print ""
print "Running code snippet from this location ..."
print ""
execfile(p_snippet)
示例3: current_frame
# 需要导入模块: from marionette import Marionette [as 别名]
# 或者: from marionette.Marionette import set_search_timeout [as 别名]
class current_frame():
def main(self, LOGDIR, p_el, p_frame_array=False):
#
# p_el is an array for the element.
# p_frame_array is a list of iframes to iterate through (optional).
#
self.marionette = Marionette(host='localhost', port=2828)
self.marionette.start_session()
self.marionette.set_search_timeout(1000)
#
# Switch to the correct iframe (unless it's "()").
#
self.marionette.switch_to_frame()
first_iframe = True
for x in p_frame_array:
# (just to make it look nice ;)
typ_str = "'" + x[0] + "'"
if first_iframe:
first_iframe = False
print ""
print "Switching to iframe with " + typ_str.rjust(10) + " = '" + x[1] + "'"
else:
print "... then to iframe with " + typ_str.rjust(10) + " = '" + x[1] + "'"
my_iframe = self.marionette.find_element("xpath", "//iframe[@" + x[0] + "='" + x[1] + "']")
self.marionette.switch_to_frame(my_iframe)
if first_iframe:
print ""
print "Using 'top level' iframe () ..."
#
# Grab a screenshot and html dump of this frame.
#
p_sfnam = LOGDIR + "screenshot.png"
p_hfnam = LOGDIR + "html_dump.html"
print ""
print "Screenshot of this frame saved to: " + p_sfnam
screenshot = self.marionette.screenshot()[22:]
with open(p_sfnam, 'w') as f:
f.write(base64.decodestring(screenshot))
f.close()
print "HTML dump of this frame saved to : " + p_hfnam
f = open(p_hfnam, 'w')
f.write(self.marionette.page_source.encode('ascii', 'ignore') )
f.close()
#
# Test to see if the element is present / displayed / etc...
#
print ""
print "Checking for element: " + str(p_el)
b_present = False
b_displayed = False
b_enabled = False
try:
x = self.marionette.find_element(*p_el)
if x:
b_present = True
if x.is_displayed():
b_displayed = True
if x.is_enabled():
b_enabled = True
except:
pass
print ""
print "Present : " + str(b_present)
print "Displayed: " + str(b_displayed)
print "Enabled : " + str(b_enabled)
print ""
示例4: Marionette
# 需要导入模块: from marionette import Marionette [as 别名]
# 或者: from marionette.Marionette import set_search_timeout [as 别名]
thread.daemon = True
thread.start()
# run some trivial unit tests which just verify the protocol
m = Marionette(host='localhost', port=2626)
assert(m.status()['os']['arch'] == 'x86')
assert(m.start_session())
assert(m.get_session_capabilities()['javascriptEnabled'] == True)
assert(m.get_window() == server.TEST_CURRENT_WINDOW)
assert(m.window == server.TEST_CURRENT_WINDOW)
assert(m.get_windows() == server.TEST_WINDOW_LIST)
assert(m.switch_to_window('window2'))
assert(m.window == 'window2')
assert(m.close_window('window2'))
assert(m.set_script_timeout(1000))
assert(m.set_search_timeout(500))
assert(m.get_url() == server.TEST_URL)
assert(m.navigate(server.TEST_URL))
assert(m.go_back())
assert(m.go_forward())
assert(m.refresh())
assert(m.execute_script(server.TEST_EXECUTE_SCRIPT))
assert(m.execute_js_script(server.TEST_EXECUTE_SCRIPT))
assert(m.execute_js_script(server.TEST_EXECUTE_SCRIPT, server.TEST_EXECUTE_SCRIPT_ARGS))
assert(m.execute_script(server.TEST_EXECUTE_SCRIPT, server.TEST_EXECUTE_SCRIPT_ARGS))
assert(m.execute_async_script(server.TEST_EXECUTE_SCRIPT))
assert(m.execute_async_script(server.TEST_EXECUTE_SCRIPT, server.TEST_EXECUTE_SCRIPT_ARGS))
assert(str(m.find_element(HTMLElement.CLASS, 'heading')) == server.TEST_FIND_ELEMENT)
assert([str(x) for x in m.find_elements(HTMLElement.TAG, 'p')] == server.TEST_FIND_ELEMENTS)
assert(str(m.find_element(HTMLElement.CLASS, 'heading').find_element(HTMLElement.TAG, 'h1')) == server.TEST_FIND_ELEMENT)
assert([str(x) for x in m.find_element(HTMLElement.ID, 'div1').find_elements(HTMLElement.SELECTOR, '.main')] == \
示例5: dual_driving
# 需要导入模块: from marionette import Marionette [as 别名]
# 或者: from marionette.Marionette import set_search_timeout [as 别名]
def dual_driving():
try:
print('Will connect to mobile..')
mm = Marionette(host='localhost', port=2829)
mm.start_session()
if disable_ua_overrides_by_default:
set_mozilla_pref(mm, 'general.useragent.site_specific_overrides', False)
set_mozilla_pref(mm, 'general.useragent.updates.enabled', False)
print('Will connect to desktop...')
md = Marionette(host='localhost', port=2828)
md.start_session()
md.set_search_timeout(1000) # especially required for webcompat.com JS-driven loading
ignored_bugs = []
buglist = []
device_map = get_device_map()
for line in open(ignore_file, 'r'):
if line[0] == '#':
continue
ignored_bugs.append(line.strip())
if start_url:
print 'Starting from bug search %s' % start_url
md.navigate(start_url)
buglist = extract_buglist(md)
else:
buglist = extract_buglist_from_file(filename)
i = 1
#print(len(buglist))
for item in buglist:
if len(item) <= 1:
print 'Warning: we expect data format ID Summary URL, something is missing'
continue
if i<start_at:
i+=1
continue
buglink = ''
if '://' not in item[0]: # assuming this is Bugzilla data from a tab-separated file - in other words a plain bug number
# TODO: will we ever process lists of webcompat.com "plain numbers"??
buglink = 'https://bugzilla.mozilla.org/show_bug.cgi?id=%s' % item[0]
else: # we've got a bug tracker URL (right?)
buglink = item[0]
# users who have bugzilla's "load next bug in search" don't need an extra navigate() call
if buglink not in md.get_url():
print('Item %s, Loading bug %s'%(i,item[0]))
md.navigate(item[0])
if len(item) == 2: # URL is not in the data - let's load the bug first and try to get it from there
url = get_url_from_bugpage(md)
else:
url = item[2]
if not url:
i+=1
continue
if url.strip() == '':
i+=1
continue
if '://' not in url:
url = 'http://%s' % url
url = url.strip().rstrip('\r\n')
location = urlparse.urlparse(url)
hostname = location.hostname.rstrip('\r\n')
print str(i) + ' : ' + url
reset_spoof(mm)
try:
mm.navigate(url)
try_to_launch_url_in_android(device_map, url)
print 'READY to analyze %s, \n%s' % (item[0], item[1])
except:
print('could not load %s, try again by pressing u\n\n' % url)
options_menu(mm, url, md, device_map)
mm.delete_session()
md.delete_session()
except Exception as err:
print err
try:
mm.delete_session()
except:
pass
try:
md.delete_session()
except:
pass
示例6: current_frame
# 需要导入模块: from marionette import Marionette [as 别名]
# 或者: from marionette.Marionette import set_search_timeout [as 别名]
class current_frame():
filename_screenshot = ""
filename_htmldump = ""
def main(self, LOGDIR):
#
# The first variable is the log directory.
#
ucount = 0
self.marionette = Marionette(host='localhost', port=2828)
self.marionette.start_session()
self.marionette.set_search_timeout(1000)
#
# Now loop through all the iframes, gathering details about each one.
#
print ""
print "Iframe for 'top level' () ..."
self.filename_screenshot = LOGDIR + "top_level" + ".png"
self.filename_htmldump = LOGDIR + "top_level" + ".html"
self.marionette.switch_to_frame()
self.record_frame()
frames = self.marionette.find_elements("tag name", "iframe")
for fnum in range (0, len(frames)):
#
# App name is usually in the "src" attribute, so it's worth a shot..
#
frame_src = frames[fnum].get_attribute("src")
if frame_src != "":
startpos = frame_src.index('/') + 2
stoppos = frame_src.index('.')
appname = frame_src[startpos:stoppos]
filename = appname
else:
ucount = ucount + 1
appname = "(unknown)"
filename = "unknown_" + str(ucount)
#
# Because we call this script sometimes when we hit a Marionette issue,
# these filenames may already exist (and we'd overwrite them!), so
# add 'DEBUG_' to the start of the filename.
#
filename = "DEBUG_" + filename
filename_details = LOGDIR + filename + "_iframe_details.txt"
self.filename_screenshot = LOGDIR + filename + ".png"
self.filename_htmldump = LOGDIR + filename + ".html"
#
# This iframe gives me problems sometimes, so I'm ignoring it for now.
#
if appname == "costcontrol":
continue
print ""
print "Iframe for app \"" + appname + "\" ..."
#
# Record the iframe details (pretty verbose, but 'execute_script'
# wasn't letting me use 'for' loops in js for some reason).
#
print " |_ iframe details saved to : " + filename_details
f = open(filename_details, 'w')
f.write("Attributes for this iframe ...\n")
num_attribs = self.marionette.execute_script("return document.getElementsByTagName('iframe')[" + str(fnum) + "].attributes.length;")
for i in range(0,num_attribs):
attrib_name = self.marionette.execute_script("return document.getElementsByTagName('iframe')[" + str(fnum) + "].attributes[" + str(i) + "].nodeName;")
attrib_value = self.marionette.execute_script("return document.getElementsByTagName('iframe')[" + str(fnum) + "].attributes[" + str(i) + "].nodeValue;")
f.write(" |_ " + attrib_name.ljust(20) + ": \"" + attrib_value + "\"\n")
f.close()
#
# Switch to this frame.
#
self.marionette.switch_to_frame(fnum)
self.record_frame()
self.marionette.switch_to_frame()
def record_frame(self):
#
# Take the screenshot and save it to the file.
#
print " |_ screenshot saved to : " + self.filename_screenshot
screenshot = self.marionette.screenshot()[22:]
with open(self.filename_screenshot, 'w') as f:
f.write(base64.decodestring(screenshot))
f.close()
#
# Take the html dump and save it to the file.
#
#.........这里部分代码省略.........
示例7: print
# 需要导入模块: from marionette import Marionette [as 别名]
# 或者: from marionette.Marionette import set_search_timeout [as 别名]
data[testdata_wk['uastring']]['gecko']['final_url'] = testdata_wk['final_url']
multiple_files = []
for filename in file_desc:
multiple_files.append(('screenshot',(os.path.basename(filename),open(file_desc[filename]['full_path'], 'rb'), 'image/png')))
del file_desc[filename]['full_path'] # don't leak local directory paths onto the internet..
post_data = {}
post_data['initial_url'] = url
post_data['data'] = json.dumps(data)
post_data['file_desc'] = json.dumps(file_desc)
print('about to send data to %s' % destination_url)
req = requests.post(destination_url, files=multiple_files, data=post_data)
print("Posted to DB server, response: %s" % req.text)
m = Marionette(host='localhost', port=2828)
m.start_session()
m.set_search_timeout(1000)
setup_console_logging(m)
file_index = []
i=0
has_bug_data = False
# If we don't start at 0, we must take care to not overwrite old results..
if start_at > 0 and os.path.exists(dirname+'comp'+os.path.sep+'idx.js'):
file_index = read_json_file(dirname+'comp'+os.path.sep+'idx.js')
# Get current test data..
all_data = read_json_file(dirname+'..'+os.path.sep+'data.js')
out_obj = read_json_file(dirname+'sitedata-automated.js')
out_missing = read_json_file(dirname+'sitedata-missing.js')
# This file is incompleread_json_filete in the Git repo - for obvious reasons.. Will have to be filled with user names and passwords
login_data = read_json_file(scriptdir+'..'+os.path.sep + "data" + os.path.sep +'logins.json')
# This file will contain per-site instructions for "special" named screenshots