我正在尝试为我们的应用程序实施e2e测试。 但是后来我的第一个测试用例失败,并出现以下错误。
Failed: Error while running testForAngular: javascript error: Unexpected
identifier
JavaScript stack:
SyntaxError: Unexpected identifier
at callback (eval at executeAsyncScript (:457:5), <anonymous>:5:5)
at check (eval at executeAsyncScript (:457:5), <anonymous>:50:7)
at eval (eval at executeAsyncScript (:457:5), <anonymous>:53:3)
at eval (eval at executeAsyncScript (:457:5), <anonymous>:54:4)
at eval (eval at executeAsyncScript (:457:5), <anonymous>:55:63)
at executeAsyncScript (<anonymous>:457:26)
at <anonymous>:473:29
at callFunction (<anonymous>:361:33)
at <anonymous>:371:23
at <anonymous>:372:3
(Session info: chrome=71.0.3578.98)
(Driver info: chromedriver=2.45.615291 (ec3682e3c9061c10f26ea9e5cdcf3c53f3f74387),platform=Windows NT 6.1.7601 SP1 x86_64)
任何人都可以帮助我如何解决此错误?
错误来自browser.js,来自promise this.executeAsyncScript_(clientSideScripts.testForAngular,msg('test for angular'),Math.floor(timeout / 1000),this.ng12Hybrid)。
可以肯定的是,我尝试使用角度站点进行测试并且该测试用例已通过,但是测试我的应用程序中当前页面的测试用例失败了
import { browser, by, element } from 'protractor';
import { protractor } from 'protractor/built/ptor';
describe('Testing abc', () => {
beforeEach(() => {
});
it('should open the page', () => {
browser.get('/abc');
browser.getCurrentUrl().then(function(actualUrl) {
expect(actualUrl).toContain('/abc');
});
});
it('should display page', () => {
browser.get('https://angular.io');
expect(browser.getCurrentUrl()).toBe('https://angular.io/');
});
});
在第一个测试用例中,promise browser.getCurrentUrl()之后的块未执行。 请帮助我
答案 0 :(得分:-1)
actualUrl
?您定义了吗?browser.get
地址应仅是协议的绝对路径,例如browser.get('https://angular.io/')
,而不是browser.get('/something')