【问题标题】:Element is not clickable at point in headless mode. But when we remove headless from protractor.conf.js it is working fine.在无头模式下,元素不可点击。但是当我们从 protractor.conf.js 中删除 headless 时,它工作正常。
【发布时间】:2018-05-26 09:12:35
【问题描述】:
element(by.className('cuppa-dropdown')).element(by.className('dropdown-list')).element(by.className('list-area')).element(by.tagName('li')).click();

实际上这个元素是在弹出的。并且它在 headless 模式下运行良好。但是由于我们需要通过内置 vsts 来自动化测试用例,所以我们需要在 headless 模式下执行测试

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

【问题讨论】:

  • 在开始测试之前尝试更改浏览器窗口大小并检查是否是问题所在。参考stackoverflow.com/questions/20023567/…
  • 我们在 beforeeach() browser.driver.manage().window().maximize() 中如何使用它;
  • 问题是由于无头模式,即 args: ["--headless", "--disable-gpu", "--window-size=800x600"],

标签: angular asp.net-core protractor e2e-testing angular-e2e


【解决方案1】:

更改配置文件中的 chrome 选项时工作正常
args: ["--headless", "--disable-gpu", "--window-size=1280x1024"] 

args: ["--headless", "--disable-gpu", "--window-size=1920,1080"] 

非常感谢您的帮助。

【讨论】:

  • 我们必须在哪里编辑这个??这个的配置文件在哪里??
  • @Rajan 在 e2e/protractor.conf.js: 配置 > 能力 > chromeOptions > args
【解决方案2】:

如上所述,尝试将窗口大小设置为 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);
                });
            }); 

【讨论】:

  • 在哪里使用 setTimeout() 函数
  • 我们在 beforeeach() 中使用 browser.driver.manage().window().maximize()
  • 在 onPrepare() 里面就像这里github.com/andriyze/proTR/blob/…
  • 以前我使用 args:[“--headless”、“--disable-gpu”、“--window-size=800x600”]。现在,正如您提到的 args:[“--headless”、“--disable-gpu”、“--window-size=1920,1080”],它工作正常。感谢您的帮助
  • 单独设置窗口大小解决了我的问题。谢谢!
猜你喜欢
  • 1970-01-01
  • 2022-01-08
  • 1970-01-01
  • 1970-01-01
  • 2014-05-25
  • 2022-01-23
  • 2016-03-12
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多