本文介绍了在无头模式下,元素不可单击.但是,当我们从protractor.conf.js中删除无头时,它工作正常.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

element(by.className('cuppa-dropdown')).element(by.className('dropdown-list')).element(by.className('list-area')).element(by.tagName('li')).click();

实际上此元素处于弹出状态.并且在 headless 模式下还可以正常工作.但是,由于我们需要通过内置vsts来自动化测试用例,因此我们需要以无头模式执行测试

actually this element is in pop up. ANd it is woring fine in headless mode. But as we need to automate the test cases by build in vsts we need to execute test in headless mode

失败:未知错误:元素在点(863,343)不可点击(会话信息:headless chrome = 63.0.3239.84)(驱动程序信息:chromedriver = 2.34.522940(1a76f96f66e3ca7b8e57d503b4dd3bccfba87af1),platform = Windows NT 10.0.16299 x86_64)

Failed: unknown error: Element is not clickable at point (863, 343) (Session info: headless chrome=63.0.3239.84) (Driver info: chromedriver=2.34.522940 (1a76f96f66e3ca7b8e57d503b4dd3bccfba87af1),platform=Windows NT 10.0.16299 x86_64)

推荐答案

如上所述,尝试将窗口大小设置为chrome的参数

As answered above try to set window size as argument for chrome

chromeOptions: {
                args: [
                    '--window-size=1920,1080'],

setTimeout(function() {
                browser.driver.executeScript(function() {
                    return {
                        width: window.screen.availWidth,
                        height: window.screen.availHeight
                    };
                }).then(function(result) {
                    browser.driver.manage().window().setPosition(0,0);
                    browser.driver.manage().window().setSize(result.width, result.height);
                });
            }); 

这篇关于在无头模式下,元素不可单击.但是,当我们从protractor.conf.js中删除无头时,它工作正常.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-14 01:28