是否可以启动 headless Google Chrome 并以编程方式设置时区进行测试?它似乎没有作为 shell switch 出现.
我希望能够运行不同时区的测试,以确认前端正确处理时区转换。
最佳答案
我最近遇到了 this script这解决了这个问题。它支持一些配置选项。从代码:
# Change this to the spoof a different timezone. Helpful for testing timezone specific client facing content.
export TZ="America/Los_Angeles"
# Permanent directory to store the user-data directory of your 'fresh'
# Chrome configuration.
fresh_dir="$HOME/.fresh-chrome"
# Temporary directory in which to create new user-data directories for
# temporary Chrome instances.
tmp_dir="/tmp"
有趣的是,
TZ
变量不是脚本的一部分。也许 Chrome 会读取 TZ
启动时的环境变量?我不确定,但这暂时有效。
关于google-chrome - Headless Google Chrome - 更改时区,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44463925/