I have two angular applications
For Login
For business Logic
I have tried to start automation testing for these applications by using protractor. But facing problem to get the element details from 2nd application after login (1st application).
The files are
specs: [
'login.js',// 1st application
'navigatetoRegisterReport.js',// page loaded by menu navigation from 1st application
'requestCreation.js',// 2nd application page loaded by `browser.get(2nd app Url)`
'navigateToDcOtherInvoice.js'// navigation to another screen in my 2nd application
],
I have done the logic for login by this below way and it is working very well
async first() {
await browser.driver.get(browser.baseUrl).then(async () => {
await browser.wait(ExpectedConditions.elementToBeClickable(element(by.linkText("Other User"))), 30000);
await element(by.linkText("Other User")).click().then(() => {
browser.wait(ExpectedConditions.elementToBeClickable(element(by.css('#username'))), 30000);
element(by.css('#username')).sendKeys('XXXXX').then(() => {
browser.wait(ExpectedConditions.elementToBeClickable(element(by.id("password-field"))), 30000);
element(by.id("password-field")).sendKeys('XXXXX').then(() => {
browser.wait(ExpectedConditions.elementToBeClickable(element(by.id('login-submit'))), 30000);
element(by.id('login-submit')).click().then(async () => {
const dashboardImage = await element(by.css("app-dashboard .dashboard-image"));
browser.wait(ExpectedConditions.elementToBeClickable(dashboardImage), 30000);
dashboardImage.isDisplayed().then((value) => {
if (value == true) {
console.log('dashborad image is displayed')
} else {
console.log('dashborad image is not identified')
}
}).catch(error => console.error('caught error while login', error));;
}).catch(error => console.error('caught error 7', error));;
}).catch(error => console.error('caught error on password', error));;
}).catch(error => console.error('caught error on user name', error));;
}).catch(error => console.error('caught error tab click', error));;
}).catch(error => console.error('caught error on load', error));
}
But while getting the element value from 2nd application I am getting error
async requestCreation(date: string, report: string) {
await browser.get('https://2ndapplication/xxx/xxxx').then(async () => {
var selectDate = element(by.xpath("//input[@id='icon-right']"));
var reportType = element(by.xpath("//input[@placeholder='Report Type']"));
browser.wait(ExpectedConditions.elementToBeClickable(selectDate), 30000);
selectDate.clear();
selectDate.sendKeys(date)
browser.wait(ExpectedConditions.elementToBeClickable(reportType), 30000);
reportType.click();
reportType.clear();
reportType.sendKeys(report)
}).catch(error => console.error('caught error on requestCreation', error));
}
Error:
ScriptTimeoutError: script timeout
(Session info: chrome=88.0.4324.190)
(Driver info: chromedriver=88.0.4324.96 (68dba2d8a0b149a1d3afac56fa74648032bcf46b-refs/branch-heads/4324@{#1784}),platform=Windows NT 10.0.18363 x86_64)
at Object.checkLegacyResponse (E:\updatedCode\backup\node_modules\selenium-webdriver\lib\error.js:546:15)
at parseHttpResponse (E:\updatedCode\backup\node_modules\selenium-webdriver\lib\http.js:509:13)
at doSend.then.response (E:\updatedCode\backup\node_modules\selenium-webdriver\lib\http.js:441:30)
at process._tickCallback (internal/process/next_tick.js:68:7)
From: Task: Protractor.waitForAngular() **- Locator: By(xpath, //input[@id='icon-right'])
I can see the element in browser and it is visible. But protractor throwing the error as it is not there. I know it will be solved if I providing false for WaitForAngularDisabled(false)
. But the both applications are implemented by Angular only. So I don't want to loose any protractor features by disable angular. So how to test two angular applications by protractor?
Versions:
- Protector: 7.0.0
- Angular: 7.3.9