简体   繁体   English

e2e测试:无头模式测试通过,常规模式失败

[英]e2e testing: Headless mode test passes, regular mode fails

I have an e2e Protractor test that passes in headless mode and fails in regular browser testing. 我有一个e2e量角器测试,该测试以无头模式通过,但在常规浏览器测试中失败。 What are the possible reasons it could be failing in regular browser testing? 常规浏览器测试失败的可能原因是什么?

Note: I'm using Chrome Version 68.0.3440.106 (Official Build) (64-bit) to run the test. 注意:我使用的是Chrome版本68.0.3440.106(正式版本)(64位)来运行测试。

Here's what I learned: 这是我学到的:

1. Non-headless mode needs to be told to scroll, whereas headless does fine without being told to scroll. 1.需要告知非无头模式滚动,而无头确实可以不通知滚动。

In non-headless, if you don't scroll to the element you're using, it throws a timeout error 'waiting for element' to appear. 在非无头模式中,如果不滚动到正在使用的元素,则会引发超时错误“等待元素”的出现。

My original code (which passes in headless mode but fails in non-headless) was something to the tune of: 我的原始代码(以无头模式通过,但以非无头模式失败)是以下几点:

 command to do something 

 command to click button

New code (passes in both headless and non-headless): 新代码(传入无头和非无头):

import import { browser, element } from 'protractor';
// assuming my protractor DOM element is called 'thing'

command to do something 

browser.executeScript('thing.scrollIntoView()', element.getWebElement());

command to click button

2. Non-headless mode needs more waiting between actions. 2.非无头模式需要在操作之间等待更多时间。

My original code (which passes in headless mode but fails in non-headless) was something to the tune of: 我的原始代码(以无头模式通过,但以非无头模式失败)是以下几点:

command to do something 

command to do something else

New code (passes in both headless and non-headless): 新代码(传入无头和非无头):

command to do something 

browser.waitForAngularEnabled(false);

command to do something else

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM