我正在尝试使用PhantomJS浏览器在Amazon EC2环境中运行量角器测试.我知道不建议使用带有量角器的PhantomJS,但它是我现在唯一的选择.测试始终在Win7环境中运行.
当测试看起来像这样它总是工作正常
describe('Portal Login End 2 End test', function() {
it('should automatically redirect to login /form', function() {
browser.get('');
expect(browser.getLocationAbsUrl()).toMatch("/login");
});
it('should automatically redirect to dashboard page after successful login', function() {
element(by.model('user.username')).sendKeys('admin');
element(by.model('user.password')).sendKeys('admin');
element(by.buttonText('Sign in')).click();
expect(browser.getLocationAbsUrl()).toMatch("dashboard/home");
});
});
Run Code Online (Sandbox Code Playgroud)
但是当像这样在beforeEach函数中发出GET请求时
describe('Portal Login End 2 End test', function() {
beforeEach(function() {
browser.get('');
}
it('should automatically redirect to login', function() {
expect(browser.getLocationAbsUrl()).toMatch("/login");
});
it('should automatically redirect to dashboard page after successful login', function() {
element(by.model('user.username')).sendKeys('admin');
element(by.model('user.password')).sendKeys('admin');
element(by.buttonText('Sign in')).click();
expect(browser.getLocationAbsUrl()).toMatch("dashboard/home");
});
}); …
Run Code Online (Sandbox Code Playgroud)