我正在使用量角器测试非角度js网站。
我的测试用例成功运行,但我想删除sleep语句,并将wait或Expected条件添加到我的测试用例中。
我的代码如下:
var co = require('co');
var path = require('path');
describe("TEST ", function () {
it("test", co.wrap(function* () {
browser.ignoreSynchronization = true;
var EC = protractor.ExpectedConditions;
yield browser.get('URL');
browser.wait(function () {
return browser.driver.isElementPresent(by.css(a[href = "#login"]));
}, 30000);
var elmOK = browser.driver.findElement(by.css('a[href="#login"]'));
yield elmOK.click();
expect(browser.getCurrentUrl()).toContain("login");
yield browser.switchTo().frame('here-account-sdk').then(function () {
browser.driver.findElement(by.id('sign-in-email')).sendKeys("supplier_portal@yahoo.com");
browser.driver.findElement(by.id('sign-in-password-encrypted')).sendKeys("voting123");
browser.driver.findElement(by.xpath(' //*[@id="sign-in-form"]/div[2]/div[6]/form/fieldset[3]/button')).click();
});
// browser.sleep(5000);
var elmOK = browser.driver.findElement(by.xpath('//*[@id="lnav"]/li[3]/a'));
yield elmOK.click();
// browser.sleep(1500);
browser.driver.findElement(by.xpath('//*[@id="administration"]/div/div[1]/select/option[2]')).click();
// browser.sleep(5000);
browser.driver.findElement(by.xpath('//*[@id="administration"]/div/div[2]/table/tbody/tr[1]/td[10]/span')).click();
// browser.sleep(5000);
browser.driver.findElement(by.xpath('//*[@id="content"]/div/div[2]/div/div/div/div[3]/button[1]')).click();
// browser.sleep(5000);
}));
});
当我尝试运行测试时,出现以下错误。我不知道如何解决它。
---------------- Spec started: ----------------
F[13:57:01] E/launcher - Cannot read property '_failures' of undefined
[13:57:01] E/launcher - TypeError: Cannot read property '_failures' of undefined
at null.self.specDone (C:\Users\jasharma\gitrepo\supplier-portal\node_modules\jasmine-reporters\src\junit_reporter.js:274:46)
at dispatch (C:\Users\jasharma\gitrepo\supplier-portal\node_modules\protractor\node_modules\jasmine-core\lib\jasmine-core\jasmine.js:1966:28)
at ReportDispatcher.specDone (C:\Users\jasharma\gitrepo\supplier-portal\node_modules\protractor\node_modules\jasmine-core\lib\jasmine-core\jasmine.js:1949:11)
at Spec.specResultCallback [as resultCallback] (C:\Users\jasharma\gitrepo\supplier-portal\node_modules\protractor\node_modules\jasmine-core\lib\jasmine-core\jasmine.js:903:18)
at complete (C:\Users\jasharma\gitrepo\supplier-portal\node_modules\protractor\node_modules\jasmine-core\lib\jasmine-core\jasmine.js:368:12)
at QueueRunner.clearStack (C:\Users\jasharma\gitrepo\supplier-portal\node_modules\protractor\node_modules\jasmine-core\lib\jasmine-core\jasmine.js:660:9)
at QueueRunner.run (C:\Users\jasharma\gitrepo\supplier-portal\node_modules\protractor\node_modules\jasmine-core\lib\jasmine-core\jasmine.js:1881:12)
at C:\Users\jasharma\gitrepo\supplier-portal\node_modules\protractor\node_modules\jasmine-core\lib\jasmine-core\jasmine.js:1898:16
at C:\Users\jasharma\gitrepo\supplier-portal\node_modules\protractor\node_modules\jasmine-core\lib\jasmine-core\jasmine.js:1842:9
at C:\Users\jasharma\gitrepo\supplier-portal\node_modules\jasminewd2\index.js:18:5
[13:57:01] E/launcher - Process exited with error code 199
请帮帮忙?
答案 0 :(得分:0)
这是:
yield browser.switchTo().frame('here-account-sdk').then(function () {
browser.driver.findElement(by.id('sign-in-email')).sendKeys("supplier_portal@yahoo.com");
browser.driver.findElement(by.id('sign-in-password-encrypted')).sendKeys("voting123");
browser.driver.findElement(by.xpath(' //*[@id="sign-in-form"]/div[2]/div[6]/form/fieldset[3]/button')).click();
});
你唯一没有角度相关的部分?如果是,请尝试在browser.switchTo().defaultContent();
之前添加var elmOK = browser.driver.findElement(by.xpath('//*[@id="lnav"]/li[3]/a'));
。