无头Google Chrome-更改时区

Jam*_*ell 6 google-chrome google-chrome-headless

是否可以启动无头Google Chrome并以编程方式设置时区进行测试?它似乎不作为shell开关存在

我希望能够以不同的时区运行测试,以确认前端是否正确处理了时区转换。

Jam*_*ell 5

我最近遇到了解决这个问题的脚本。它支持一些配置选项。从代码来看:

# 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"
Run Code Online (Sandbox Code Playgroud)

有趣的是,该TZ变量不是脚本的一部分。也许 ChromeTZ在启动时会读取环境变量?我不确定,但这目前有效。