Setting timezone in Protractor e2e tests

隐身守侯 提交于 2019-12-08 02:51:50

问题


I have some Protractor e2e tests in which I deal with timezone. On my local machine they pass, on Appveyor they don't.

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?


回答1:


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


来源:https://stackoverflow.com/questions/33608908/setting-timezone-in-protractor-e2e-tests

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!