Setting timezone in Protractor e2e tests(在 Protractor e2e 测试中设置时区)
问题描述
我有一些处理时区的 Protractor e2e 测试.在我的本地机器上它们通过了,在 Appveyor 上它们没有.
I have some Protractor e2e tests in which I deal with timezone. On my local machine they pass, on Appveyor they don't.
我发现这是一个时区设置问题(Appveyor 上的不同设置).
I found out it's a timezone setting issue (different settings on Appveyor).
有没有办法在测试套件开始时设置时区并在结束时将其恢复为旧时区?
Is there a way to set the timezone at the start of the test suite and bring it back the old one at the end?
我尝试了这个解决方案(所以请不要将其标记为重复):在量角器测试中设置浏览器时区
I tried this solution (so please don't mark this as duplicate): Set browser timezone in a Protractor test
我发现这是一个非常丑陋的解决方法.有更漂亮的吗?
which I found to be a very ugly workaround. Anything prettier?
推荐答案
您可以使用 PowerShell 更新时区并在之后重置.这可以使用 AppVeyor 环境变量、Get-TimeZone &设置时区.这是一个 appveyor.yml
示例:
You could use PowerShell to update the timezone and reset it after. This can be achieved using AppVeyor environment variables, Get-TimeZone & Set-TimeZone. Here is an appveyor.yml
sample:
init:
- ps: $env:ORIGIONAL_TZ = Get-TimeZone
- ps: Set-TimeZone -Name "Pacific Standard Time"
on_finish:
- ps: Set-TimeZone -Name $env:ORIGIONAL_TZ
这篇关于在 Protractor e2e 测试中设置时区的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在 Protractor e2e 测试中设置时区


基础教程推荐
- npm start 错误与 create-react-app 2022-01-01
- Bootstrap 模态出现在背景下 2022-01-01
- 原生拖动事件后如何获取 mouseup 事件? 2022-01-01
- Fabric JS绘制具有活动形状的多边形 2022-01-01
- 如何添加到目前为止的天数? 2022-01-01
- 在 contenteditable 中精确拖放 2022-01-01
- 即使用户允许,Gmail 也会隐藏外部电子邮件图片 2022-01-01
- fetch 是否支持原生多文件上传? 2022-01-01
- Bokeh Div文本对齐 2022-01-01
- 检查 HTML5 拖放文件类型 2022-01-01