将参数传递给 browser.get - 量角器

Passing parameters to browser.get - protractor

上下文:

问题:

protractorbrowser 方法 get 如何接受 url 参数查询?

browser.get('${browser.baseUrl}?p=2') 正在重定向到 http://localhost:4200/&p=2 而不是 http://localhost:4200&p=2

当我抑制 browser.baseUrl 的最后一个字符时,重定向的 url 是 http://localhost:420/&p=2 ...

有什么想法吗?

编辑:

我尝试通过添加 baseUrl 来编辑 protractor.conf.js,但我没有更改任何内容...

如果你在config文件中设置了一个baseUrl,那么get方法中就不需要添加browser.baseUrl,可以省略。

例如,在您的配置中:

exports.config = {
   // ...

   baseUrl: 'https://github.com/search',
}

在测试中,您可以像这样添加查询参数:

it('should open the URL with the query parameter', async () => {
  await browser.get('?q=test'); // will open the 'https://github.com/search?q=test' page
});