使量角器测试占据整个屏幕 [英] Make protractor test occupy the entire screen

查看:29
本文介绍了使量角器测试占据整个屏幕的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在网上看到了几个与这个问题相关的问题(如何在 Protractor/WebdriverJS 中设置默认浏览器窗口大小)但它们没有解决我的问题.

I have seen a couple questions online related to this issue (How to set default browser window size in Protractor/WebdriverJS) but they don't address my issue.

我有一些测试,希望能够在笔记本电脑屏幕或蚂蚁大小的台式机屏幕上成功运行.我已经尝试了以下所有这些方法,但都没有成功.

I have the tests that I want to be able to run successfully on a laptop screen or desktop screen of ant size. I had tried all of these methods below but unsuccesfully.

这个问题是我必须硬编码宽度和高度.我想自动检测屏幕尺寸

The issue with this one is that I have to hardcode a width and height. I want to detect the screen size automatically

browser.driver.manage().window().setSize(width, height);

这个问题是它似乎只最大化高度而不是宽度.

The issue with this one is that it only seems to maximize the height and not the width.

browser.driver.manage().window().maximize();

我希望能够获取屏幕的高度和宽度并将它们插入到 .setSize() 函数中.但是当我尝试这个

I want to be able to get the screen's height and width and plug those in for the .setSize() function. But when I try this

browser.driver.manage().window().setSize(screen.width, screen.height);

我得到 ReferenceError: screen is not defined

如果我尝试 console.log($(window)); 然后窗口也没有定义

If I try console.log($(window)); then window is not defined either

那么最好的方法是什么?

So what the best way to do this?

推荐答案

对于 Mac OS X 上的 Chrome,以下没有使我的浏览器最大化:

In case of Chrome on Mac OS X, the following didn't make the browser maximized for me:

browser.driver.manage().window().maximize();

在这种情况下,您需要切换到 Firefox,或者使用 --start-maximized:

In this case, you need to either switch to Firefox, or start Chrome with --start-maximized:

capabilities: {
    browserName: 'chrome',
    chromeOptions: {
        args: [
            '--start-maximized'
        ]
    }
}

这篇关于使量角器测试占据整个屏幕的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆