如何动态地将URL添加到Protractor测试中?

Nil*_*esh 4 angularjs-e2e protractor

我正在尝试将量角器与Jenkins结合使用.在我的jenkins中,我需要动态生成URL.

因此,在运行量角器测试时,例如:

describe('angularjs homepage', function() {
  it('should greet the named user', function() {
    // Load the AngularJS homepage.
    browser.get('http://www.angularjs.org');

    element(by.model('yourName')).sendKeys('testUser');

  });
});
Run Code Online (Sandbox Code Playgroud)

在上面的例子中,我想动态地传递一个变量来代替" http://www.angularjs.org ".

我找不到任何可以在参考配置中指定的变量.

Seb*_*ian 8

您可以baseUrl在里面使用config参数exports.config,然后browser.get('/path')在测试规范中使用.所以在配置中你有baseUrl: 'http://localhost',所以browser.get('/path')会打电话http://localhost/path.