让量角器测试占据整个屏幕 [英] Make protractor test occupy the entire screen
问题描述
我看到一对夫妇的问题,在网上与此相关的问题(<一个href=\"http://stackoverflow.com/questions/20023567/how-to-set-default-browser-window-size-in-protractor-webdriverjs\">How设置在量角器/ 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.
我有我希望能够到蚂蚁大小的笔记本电脑屏幕或桌面屏幕上成功运行测试。我已经尝试了所有的下面这些方法,但unsuccesfully。
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.
这一个问题是,我必须努力code的宽度和高度。我想自动检测屏幕大小
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:没有定义屏幕
如果我尝试的console.log($(窗口));
则是没有定义的窗口或者
If I try console.log($(window));
then window is not defined either
那么,最好的方式做到这一点?
So what the best way to do this?
推荐答案
我们设置浏览器的大小上prepare
块protractor.conf.js:
We set browser size in onPrepare
block in protractor.conf.js:
onPrepare: function() {
browser.driver.manage().window().maximize();
},
不知道这是否可以帮助你与你的第二个问题..?
not sure if this helps you with your second issue ..?
这篇关于让量角器测试占据整个屏幕的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!