在量角器中从命令行传递基本URL [英] passing base url from command line in protractor

查看:141
本文介绍了在量角器中从命令行传递基本URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用量角器测试我的angularjs应用程序。
我的conf.js看起来像这样

i am trying to test my angularjs app using protractor. my conf.js looks like this

exports.config = {
seleniumAddress: 'http://localhost:4444/wd/hub',

capabilities: {
    'browserName': 'chrome'
},
specs: ['HomePageCtrl_spec.js'],
chromeOnly: true,
jasmineNodeOpts: {
    onComplete: null,
    isVerbose: false,
    showColors: true,
    includeStackTrace: true
},
onPrepare: function() {
    browser.manage().window().setSize(1600, 1000);
},
params : {
    url : 'test'
}};

我在命令提示符下运行此命令

and i am runnig this command on command prompt

protractor Conf.js --params.url='https://XXXXX/YYY'

在我的spec文件中,在beforeEach函数中,我能够获得传递的url( console.log((browser.params.url))来了正确),但当我做 browser.get(browser.params.url) ..它无法正常工作

in my spec file, in beforeEach function i am able to get the passed url (console.log((browser.params.url)) is coming correctly), but when i do browser.get(browser.params.url).. it is not working

任何人都知道为什么会失败?

anyone has idea why this is failing?

推荐答案

量角器默认提供它。您只需要声明正确的变量。

Protractor provides it by default. You just have to declare the correct variable.

exports.config = {
seleniumAddress: 'http://localhost:4444/wd/hub',

capabilities: {
    'browserName': 'chrome'
},
specs: ['HomePageCtrl_spec.js'],
chromeOnly: true,
jasmineNodeOpts: {
    onComplete: null,
    isVerbose: false,
    showColors: true,
    includeStackTrace: true
},
onPrepare: function() {
    browser.manage().window().setSize(1600, 1000);
},
  baseUrl: 'test'
};

然后,你运行测试:

protractor Conf.js --baseUrl="https://XXXXX/YYY"

要在测试中使用此网址:

To use this url within your tests:

browser.get(browser.baseUrl)

这篇关于在量角器中从命令行传递基本URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆