简体   繁体   English

在Nightwatchjs中为每个环境定义多个Globals文件

[英]Define Multiple Globals files per environment in Nightwatchjs

I am trying to define multiple globals files on an environment bases in NightwatchJS, but cannot seem to get it done correctly. 我试图在NightwatchJS的环境基础上定义多个全局文件,但似乎无法正确完成。

The documentation here http://nightwatchjs.org/guide#external-globals indicates this is a possibility, but I can only get a globals file picked up at the top level of the config file. http://nightwatchjs.org/guide#external-globals此处的文档指出了这种可能性,但是我只能在配置文件的顶层获取一个globals文件。 If I try to embed them inside the environment nodes, they are ignored. 如果我尝试将它们嵌入环境节点中,则会将其忽略。

"chromeTR" : { "persist_globals": true, "globals": { "Report":true }, "desiredCapabilities": { "browserName": "chrome", "test_card" : "4111111111111111", "test_alt_card" : "0000405060708090", "chromeOptions": { "args" : ["--no-sandbox"] }, "cli_args" : { "webdriver.gecko.driver" : "drivers/chromedriver" } } },

This needs to be in place because I am defining a custom before function depending on environment. 这需要在地方,因为我定义自定义before根据环境功能。

Also, because this is the before function, I am unable to use a globals variable defined in the environment to trigger a switch within the function itself, since the before function does not have insight to the browser object. 另外,由于这是before函数,因此我无法使用环境中定义的globals变量来触发函数本身内的切换,因为before函数无法洞察浏览器对象。

I believe you can use 我相信你可以用

this.client.globals.Report

or 要么

this.client.globals.test_settings.globals.Report

within the before function to access your environment-specific global variables - is that not working? 在before函数中访问您的环境特定的全局变量-这不起作用吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM