屏幕分辨率设置不正确

Resolution of the screen is not setting properly

我正在尝试将我的浏览器屏幕设置为 (360,640) 的分辨率,但是当我阅读时,它的值发生了变化,并且设置值和获取值存在差异

 resolution(){
        browser.manage().window().setSize(360,640);
        browser.manage().window().getSize().then((getSize) => {
              console.log('Value of Height', getSize.height);
              console.log('Value of width', getSize.width);
        });
    }
NOTE :: tried with different resolution and their result as below:
1.Width :: 360 and Height :: 640  
Result is coming as Width:: 516 and Height :: 640

2.Width ::768  and Height :: 1024
Result is coming as Width :: 768 and Height :: 788

Using Protractor Version :: Version 5.4.3
      npm :: 6.14.5


Please help me out to solve this problem

您能否尝试设置功能的分辨率而不是为其创建分辨率函数。像这样:

capabilities: {
        'browserName': 'chrome',
        chromeOptions: {
            args: [ "--headless", "--disable-gpu", "--window-size=1440,960"]
        },
    }

另外,您也可以像这样在 onPrepare 函数中添加 browser.window setSize:

onPrepare: async() => {
        browser.baseUrl = 'https://app.thegaas.com';
        await browser.driver.manage().window().setPosition(0,0);
        await browser.driver.manage().window().setSize(1440,960);
        let getSize = await browser.driver.manage().window().getSize();
        console.log('Value of Height', getSize.height);
        console.log('Value of width', getSize.width);
    }

您可以删除 async await 并改用 .then 解决承诺。