I am using Protractor to test automate with Angular web application. My test suite has around 37 test cases. Each test case runs successfully when it runs individually.When I run the whole test suite, I get
ScriptTimeoutError: script timeout....................................... From: Task: Protractor.waitForAngular() - Locator: By(xpath, /html/body/app-root/app-home/div/div/div[2]/as-split/as-split-area[2]/app-tabhost/app-tab[1]/div/app-files/div/div[2]/ag-grid-angular/div/div[2]/div[1]/div[3]/div[2]/div/div/div[12]/div[1]])
most of the time.
I have followed few solutions, but they didn't work.
I have posted relevant code snippets to understand the issue. Is there any wrong?
Component_spec.js
var LoginModule = require("./LoginModule.js");
var ComponentModule = require("./ComponentModule.js");
describe('Component Spec', function () {
var componentModule = new ComponentModule();
beforeAll(async function () {
console.log("===Loading home page");
browser.driver.sleep(8000);
});
beforeEach(async function () {
browser.get(LoginModule.homeUrl);
browser.driver.sleep(8000);
});
it('editinput', async function () {
var AlertMessage = element(by.cssContainingText('.col-sm-11', 'underline'));
componentModule.editinput("value");
expect(AlertMessage.isPresent()).toBe(false);
browser.driver.sleep(5000);
});
});
ComponentModule.js
this.editinput = async function (value) {
let selectCheckbox2 = element(by.xpath('/html/body/app-root/app-home/div/div/div[2]/as-split/as-split-area[2]/app-tabhost/app-tab[1]/div/app-files/div/div[2]/ag-grid-angular/div/div[2]/div[1]/div[3]/div[2]/div/div/div[12]/div[1]'));
await selectCheckbox2.click();
await browser.driver.sleep(5000);
browser.ignoreSynchronization = true;
let selectNext = element(by.xpath('//*[@id="next"]'));
await selectNext.click();
await browser.driver.sleep(5000);
browser.ignoreSynchronization = true;
let input = element(by.xpath('/html/body/app-root/app-home/div/div/div[2]/as-split/as-split-area[2]/app-tabhost/app-tab[2]/div/div[2]/div[1]/button[2]'))
await input.click();
let right = element(by.className("right_button"));
await right.click();
await browser.driver.sleep(2000);
let edit = element(by.className("edit_box"));
await edit.sendKeys(value);
await browser.driver.sleep(5000);
let saveBtn = element(by.xpath('/html/body/app-root/app-home/div/div/div[2]/as-split/as-split-area[2]/app-tabhost/app-tab[2]/div/app-procedure/div/div[2]/div[1]/button[3]/i'));
await saveBtn.click();
await browser.driver.sleep(8000);
browser.ignoreSynchronization = false;
};
conf.js
exports.config = {
framework: 'jasmine',
seleniumAddress: 'http://localhost:4444/wd/hub',
capabilities: {
browserName: 'chrome',
acceptSslCerts: true,
shardTestFiles: false,
maxInstances: 1
},
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 100000,
},
onPrepare: () => {
browser.manage().window().maximize();
browser.manage().timeouts().implicitlyWait(10000);
browser.ignoreSynchronization = true;
}
}
Try this!
It not good automation test practise to use browser.driver.sleep(5000);
after each step. So try to remove browser.driver.sleep(5000);
from beforeAll, beforeEach and after clicking element. Always try to use minimum sleep as possible if required.
Use Expected conditions[Here]: https://www.protractortest.org/#/api?view=ProtractorExpectedConditions instead using sleep.
conf.js changes.
directConnect: true,
allScriptsTimeout: 50000,
Check [Here]: https://www.protractortest.org/#/server-setup
Use Minimum implicitlyWait
browser.manage().timeouts().implicitlyWait(500);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.