gpt4 book ai didi

angularjs - 如何在 Protractor 测试运行之前设置浏览器大小?

转载 作者:行者123 更新时间:2023-12-01 02:00:23 24 4
gpt4 key购买 nike

我有下面列出的 Protractor 测试。它运行良好。但是我需要添加一些将浏览器打开到全屏的代码,因为我的测试对网格图块的像素位置很敏感。如何才能做到这一点?

describe('DragAndDrop Test', function () {
require('protractor');
require('jasmine-expect');


beforeAll(function () {
context = new Context();
context.get();
browser.waitForAngular();
browser.driver.manage().window().maximize();

});

it('should drag and drop Application Experience tile', function () {

//a = angular.element(document).find('h3')[1]
//target is where we are dragging the box to. Box is the Box
var target = { x: 300, y: 50 };
var box = element(by.cssContainingText('h3', 'Application Experience'));
var infoSpot = element(by.cssContainingText('h3', 'Application Experience'));


//scope is going to hold the scope variables that tell us where the box is located
//get the standardItems Scope


box.evaluate('dashboards').then(function(scope) {
//make sure the box we are using is initially set in column 0 and Row 0
expect(scope['1'].widgets[0].col).toEqual(0);
expect(scope['1'].widgets[0].row).toEqual(0);
});

//drag and drop the box somewhere else.
browser.actions().dragAndDrop(box, target).perform();
browser.waitForAngular();
browser.driver.sleep(5000);

//get the updated scope
box.evaluate('dashboards').then(function(scope) {
//test to see that the box was actually moved to column 1 and row 0
expect(scope['1'].widgets[0].col).toEqual(1);
expect(scope['1'].widgets[0].row).toEqual(0);
});
});
});

var Context = function () {
this.ignoreSynchronization = true;
//load the website
this.get = function () {
browser.get('http://127.0.0.1:57828/index.html#/dashboard');
};
};

最佳答案

我认为更好的做法是在您的配置中执行此操作。

onPrepare: function() {
browser.manage().window().setSize(1600, 1000);
}

or

onPrepare: function() {
browser.manage().window().maximize();
}

关于angularjs - 如何在 Protractor 测试运行之前设置浏览器大小?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37040158/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com