如何告诉量角器全局使用baseUrl中的哈希? [英] How to tell Protractor to use hash in baseUrl globally?

查看:84
本文介绍了如何告诉量角器全局使用baseUrl中的哈希?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当前,在我的Angular应用中以及运行时启用了HashLocationStrategy

Currently, HashLocationStrategy is enabled in my Angular App, and when I run

  expect(browser.getCurrentUrl()).toBe(browser.baseUrl + '/login');

在我的e2e规范中,我收到以下错误:

in my e2e spec, I receive following error:

有没有办法告诉量角器全局使用 baseUrl 中的哈希后缀?

Is there a way to tell Protractor to use hash suffix in baseUrl globally?

推荐答案

您可以在配置文件中定义 baseUrl ,或者从命令行或 Jenkins传递参数,以便所有规格均可使用.

You can define baseUrl in your config file Or pass parameter from command line or Jenkins so that it would be available to all specs.

exports.config = {
    seleniumServerJar: '../../node_modules/protractor/node_modules/webdriver-manager/selenium/selenium-server-standalone-3.11.0.jar',
    specs: ['../spec/*.js'],
    framework:'jasmine2',
    baseUrl: "http://localhost:49152/#/"
}

并且可以检查期望,

expect(browser.getCurrentUrl()).toBe(browser.baseUrl + 'login');
expect(browser.getCurrentUrl()).toContain(browser.baseUrl + 'login');

或者,如果您从命令行传递参数,

Or if you pass parameter from command line,

protractor --baseUrl='http://localhost:49152/#/' protractor.conf.js

这篇关于如何告诉量角器全局使用baseUrl中的哈希?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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