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 测试中设置时区


- 如何调试 CSS/Javascript 悬停问题 2022-01-01
- 在不使用循环的情况下查找数字数组中的一项 2022-01-01
- 使用 iframe URL 的 jQuery UI 对话框 2022-01-01
- 为什么我的页面无法在 Github 上加载? 2022-01-01
- 我不能使用 json 使用 react 向我的 web api 发出 Post 请求 2022-01-01
- 为什么悬停在委托事件处理程序中不起作用? 2022-01-01
- 是否可以将标志传递给 Gulp 以使其以不同的方式 2022-01-01
- 如何向 ipc 渲染器发送添加回调 2022-01-01
- 从原点悬停时触发 translateY() 2022-01-01
- 如何显示带有换行符的文本标签? 2022-01-01