本文整理汇总了Python中selenium.webdriver.Remote.set_window_size方法的典型用法代码示例。如果您正苦于以下问题:Python Remote.set_window_size方法的具体用法?Python Remote.set_window_size怎么用?Python Remote.set_window_size使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类selenium.webdriver.Remote
的用法示例。
在下文中一共展示了Remote.set_window_size方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run
# 需要导入模块: from selenium.webdriver import Remote [as 别名]
# 或者: from selenium.webdriver.Remote import set_window_size [as 别名]
def run(self, test_list=None, shared_data=None):
global _current_test_case
if not self.configured:
raise Exception("TestRunner was not configured before run() was called")
if test_list:
for test_name in test_list:
ok = False
for test_case in self.test_cases:
if test_case.__class__.__name__ == test_name:
ok = True
break
if not ok:
sys.stderr.write("The test case '%s' does not exist\n" % test_name)
self._shutdown()
return 1
sys.stderr.write("Only testing the following cases: %s\n" % ', '.join(test_list))
# Big try block to make sure we shut down the server if anything goes
# wrong.
failed = 0
browser = None
try:
# Do some stuff
browser = Remote(
self.selenium_server_url.encode('ascii'),
desired_capabilities = {
'browserName': self.selenium_browser,
},
)
browser.set_window_size(1024, 650)
if shared_data is None:
shared_data = dict()
for test_case in self.test_cases:
if test_list:
# Only run the named tests, plus those on the "critical path"
skip = True
if test_case.critical_path:
skip = False
elif test_list:
for test_name in test_list:
if test_name == test_case.__class__.__name__:
skip = False
if skip:
continue
test_case.browser = browser
test_case.selenium_browser = self.selenium_browser
test_case.test_runner = self
if self.selenium_browser == 'firefox':
test_case.slowdown = .5
test_case.shared = shared_data
test_case.banner()
_current_test_case = test_case
if self.wait_after_exception:
from ipdb import launch_ipdb_on_exception
with launch_ipdb_on_exception():
test_case.run()
else:
test_case.run()
test_case.done()
_current_test_case = None
failed += test_case.failed
except KeyboardInterrupt:
print "interrupt"
failed += 1
except:
failed += 1
traceback.print_exc()
if browser:
browser.quit()
self._shutdown()
return failed
示例2: Browser
# 需要导入模块: from selenium.webdriver import Remote [as 别名]
# 或者: from selenium.webdriver.Remote import set_window_size [as 别名]
class Browser(object):
def __init__(self, harness, selenium_server_url, selenium_browser, width=1024, height=600):
self.harness = harness
self.selenium_server_url = selenium_server_url
self.selenium_browser = selenium_browser
self.width = width
self.height = height
self.selenium = Remote(
self.selenium_server_url.encode('ascii'),
desired_capabilities = {
'browserName': self.selenium_browser,
},
)
self.selenium.set_window_size(width, height)
def __enter__(self):
self.harness.browser_stack.append(self)
return self
def __exit__(self, type, value, traceback):
if self.harness.browser_stack[-1] != self:
raise Exception("Unexpected browser on the top of the stack")
self.harness.browser_stack.pop()
return
def shutdown(self):
self.selenium.quit()
def back(self):
self.selenium.back()
def refresh(self):
self.selenium.refresh()
def title(self):
return self.selenium.title
def source(self):
return self.selenium.page_source
def get(self, uri):
self.selenium.get(uri)
def find(self, selector):
return WebElementSet(self, elements=self.selenium).find(selector)
def add_cookie(self, cookie_dict):
self.selenium.add_cookie(cookie_dict)
def get_cookie(self, name):
return self.selenium.get_cookie(name)
def endpoint(self):
return self.find('html').attr('id').replace('endpoint-', '').replace('-', '.')
def endpoint_is(self, endpoint):
is_equal(self.endpoint(), endpoint, "Endpoint is correct")
def wait_for_bootstrap_modal(self):
last = [None]
def inner_wait(driver):
value = self.find('.modal')[-1].css('top')
if last[0] and last[0] == value:
return True
last[0] = value
return False
WebDriverWait(self.selenium, 3).until(inner_wait)
return self
def url(self):
return furl(self.selenium.current_url)
def execute_script(self, script):
return self.selenium.execute_script(script)
def wait_for_ajax(self):
WebDriverWait(self.selenium, 10).until_not(lambda x: x.execute_script('return jQuery.active'))
return self
def wait_for_jquery(self):
WebDriverWait(self.selenium, 10).until(lambda x: x.execute_script('return window.jQuery ? true : false'))
return self
def screenshot(self, message="Screenshot: "):
if 's3_access_key' not in app.settings.options('test'):
print "No screenshot S3 instance configured - skipping screenshot"
return
if not hasattr(self, 's3_connection'):
if 's3_host' in app.settings.options('test'):
self.s3_connection = boto.s3.connection.S3Connection(
app.settings.get('test', 's3_access_key'),
app.settings.get('test', 's3_secret_key'),
host = app.settings.get('test', 's3_host'),
)
else:
self.s3_connection = boto.s3.connection.S3Connection(
app.settings.get('test', 's3_access_key'),
#.........这里部分代码省略.........