本文整理汇总了Python中selenium.webdriver.Remote.get_window_size方法的典型用法代码示例。如果您正苦于以下问题:Python Remote.get_window_size方法的具体用法?Python Remote.get_window_size怎么用?Python Remote.get_window_size使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类selenium.webdriver.Remote
的用法示例。
在下文中一共展示了Remote.get_window_size方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ResizeTestCase
# 需要导入模块: from selenium.webdriver import Remote [as 别名]
# 或者: from selenium.webdriver.Remote import get_window_size [as 别名]
class ResizeTestCase(unittest.TestCase):
def setUp(self):
# NOTE current_directory is used in webserver setup
self.current_directory = os.path.dirname(os.path.abspath(__file__))
def tearDown(self):
self.driver.quit()
def test_core_screenshot_resize_firefox(self):
# Dali setup
self.driver = Remote(
desired_capabilities=DesiredCapabilities.FIREFOX,
command_executor="http://{host}:{port}/wd/hub".format(host=Config.server, port=Config.port)
)
self.core = DaliCore()
self.core.init(self.driver.command_executor._url, json.dumps(self.driver.capabilities))
resolutions = ["800x600", "1024x768", "1280x1024", "1366x768"]
for resolution in resolutions:
self.core.resize(resolution)
size = self.driver.get_window_size()
width = size["width"]
height = size["height"]
actual_resolution = "{width}x{height}".format(width=width, height=height)
self.assertEqual(resolution, actual_resolution)
def test_core_screenshot_resize_chrome(self):
# Dali setup
self.driver = Remote(
desired_capabilities=DesiredCapabilities.CHROME,
command_executor="http://{host}:{port}/wd/hub".format(host=Config.server, port=Config.port)
)
self.core = DaliCore()
self.core.init(self.driver.command_executor._url, json.dumps(self.driver.capabilities))
resolutions = ["800x600", "1024x768", "1280x1024", "1366x768"]
for resolution in resolutions:
self.core.resize(resolution)
size = self.driver.get_window_size()
width = size["width"]
height = size["height"]
actual_resolution = "{width}x{height}".format(width=width, height=height)
self.assertEqual(resolution, actual_resolution)
@unittest.expectedFailure
def test_core_screenshot_resize_opera(self):
# Dali setup
self.driver = Remote(
desired_capabilities=DesiredCapabilities.OPERA,
command_executor="http://{host}:{port}/wd/hub".format(host=Config.server, port=Config.port)
)
self.core = DaliCore()
self.core.init(self.driver.command_executor._url, json.dumps(self.driver.capabilities))
resolutions = ["800x600", "1024x768", "1280x1024", "1366x768"]
for resolution in resolutions:
self.core.resize(resolution)
size = self.driver.get_window_size()
width = size["width"]
height = size["height"]
actual_resolution = "{width}x{height}".format(width=width, height=height)
self.assertEqual(resolution, actual_resolution)
def test_core_screenshot_resize_internetexplorer(self):
# Dali setup
self.driver = Remote(
desired_capabilities=DesiredCapabilities.INTERNETEXPLORER,
command_executor="http://{host}:{port}/wd/hub".format(host=Config.server, port=Config.port)
)
self.core = DaliCore()
self.core.init(self.driver.command_executor._url, json.dumps(self.driver.capabilities))
resolutions = ["800x600", "1024x768", "1280x1024", "1366x768"]
for resolution in resolutions:
self.core.resize(resolution)
size = self.driver.get_window_size()
width = size["width"]
height = size["height"]
actual_resolution = "{width}x{height}".format(width=width, height=height)
self.assertEqual(resolution, actual_resolution)