I am currently working on testing a non-angular JS website using Protractor. Even though my test case passes successfully, I am looking to eliminate the sleep statement and replace it with either a wait or Expected condition in my test case.
Here is a snippet of my code:
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("<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="8dfef8fdfde1e4e8ffd2fde2fff9ece1cdf4ece5e2e2a3eee2e0">[email protected]</a>");
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);
}));
});
When I attempt to run my test, I encounter the following error message. Can someone provide guidance on how to resolve this issue?
---------------- 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
Please offer your assistance. Thank you!