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


Python Remote.get_window_size方法代码示例

本文整理汇总了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)
开发者ID:2gis,项目名称:dali,代码行数:83,代码来源:resize_test.py


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