丢失的UI共享上下文错误-在无头Chrome中运行量角器测试 [英] Lost UI Shared Context Error - Running protractor tests in headless chrome
问题描述
我正在尝试使用chrome在本地运行量角器测试,但是在无头模式下,我看到了解决方案
如上所述,您正在Linux Jenkins节点上使用 Chrome无头模式,您需要考虑以下因素:
-disable-gpu
Google团队将 Headless Chrome 作为 GA(通用)首次发布时,文章 Getting Started with Headless Chrome
提到:
--disable-gpu \ # Temporarily needed if running on Windows.
注释添加为:
现在,如果您在Windows上运行,则还希望包含
--disable-gpu
标志.
根据讨论> Headless: make --disable-gpu flag unnecessary
> 很明显:
在 Linux 或 Mac OSX 上不再需要
--disable-gpu
标志.错误SwiftShader fails an assert on Windows in headless mode
是固定的.
您可以在讨论视口.
为了利用最大可能的视口,您必须通过以下参数以 maximized 模式初始化 Chrome浏览器: >
角度
从角度角度来看,您可以使用适当的expected_conditions
来避免超时 .您可以在 WebDriverWait无法按预期运行
-无头
最后,我不确定您在中的含义是什么......当我尝试使用无头选项且未设置chrome选项时,我的测试无法运行... .也许只能通过 chromeOptions
调用参数'-headless',而不能使用其他选择.
I am attempting to run protractor tests locally using chrome but in headless mode, I have seen the docs and added the appropriate options to my config file:
capabilities: {
browserName: 'chrome',
shardTestFiles: true,
chromeOptions: {
args: [ '--headless', '--disable-gpu', '--window-size=800,600' ]
}
}
Upon running, I encounter the following error:
[1009/122000.081:ERROR:gpu_process_transport_factory.cc(1007)] Lost UI shared context.
I tried removing the --disable-gpu
flag as I read this may not be needed in future version of Chrome. I currently have latest Chrome installed (69.0.3497.100) and am using windows 7.
What do I need to do in order to get the tests running in headless mode? My intention is to check I can run in headless mode fine locally and then I want to get it running also in Chrome headless mode on a linux Jenkins node, where we are currently using XVFB but its proving to be too flaky with timeouts in tests for example.
Thanks
EDIT
With regards to others marking this as a duplicate - I should have said that my tests fail to run when I attempt to use the headless option, without the chrome options set, Chrome launches as expected and the test run and pass successfully.
My tests fail with no such element found type errors and if I view the screenshots taken on the failures, I just see a white square inside a black background (probably as per the --window-size option I was setting)
As you mentioned you are using Chrome headless mode on a linux Jenkins node you need consider a few factors as follows:
--disable-gpu
When Headless Chrome was first released as GA (General Availability) by Google Team the article Getting Started with Headless Chrome
mentioned that :
--disable-gpu \ # Temporarily needed if running on Windows.
A note was added as :
Right now, you'll also want to include the
--disable-gpu
flag if you're running on Windows.
As per the discussion Headless: make --disable-gpu flag unnecessary
it was clear that :
The
--disable-gpu
flag is no longer necessary on Linux or Mac OSX. It will also become unnecessary on Windows as soon as the bugSwiftShader fails an assert on Windows in headless mode
is fixed.
You can find a detailed discussion on What happened under the hood in the discussion ChromeDriver showing Lost UI Shared Context
So as a first step you need to remove the argument: '--disable-gpu'
flaky tests
You seem to be executing your tests with the argument --window-size=800,600
which implies a reduced Viewport.
In order to utilize the maximum possible Viewport you must initialize the Chrome Browser in maximized mode through the argument: 'start-maximized'
angular
From Angular perspective, you can avoid timeouts by using the proper expected_conditions
. You can find a detailed discussion about different expected_conditions in WebDriverWait not working as expected
--headless
Finally, I am not sure what exactly you meant as in ...my tests fail to run when I attempt to use the headless option, without the chrome options set.... Perhaps the argument '--headless' can be invoked only through chromeOptions
and no other alternative.
这篇关于丢失的UI共享上下文错误-在无头Chrome中运行量角器测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!