Reputation: 43
I'm writing automation test for angular application with protractor framework.
Test scenario:
Click at button: Create PDF Report
Click at button: Run Report Now within modal-dialog
I have an issue with clicking at button within modal-dialog element.
I'm getting the following Protracor errors
Failed: stale element reference: element is not attached to the page document,
Failed: No element found using locator
describe("Managing PDF Project Report", function () {
it("contain create PDF project for test purpose ", async function () {
await logIn();
await element(by.css(".btn-group.pull-right > button ")).click();
await element(by.css(".dropdown-menu.no-print")).element(by.css("li:nth-child(3) > a")).click();
await browser.wait(element(by.css(".modal-footer > div > button:nth-child(2)")).click(), 5000);
});
I was also trying to find element by ButtonText, ng-click attribute, but it also did not work.
I'm a bit confused because this element does not behave like iframe or like browsers pop up's. Any ideas how can I interact with element inside this modal?
Upvotes: 0
Views: 533
Reputation: 734
From which element you are getting those errors? If it's the Run Report Now
button, you can try with css:
element(by.css('[ng-click="createReport()"]');
Additionally, I'd suggest adding a couple of explicit waits to make sure Protractor waits properly:
const EC = protractor.ExpectedConditions;
await browser.wait(EC.visibilityOf($$('.modal-dialog .modal-content .modal-footer')), 5000);
await browser.wait(EC.elementToBeClickable(element(by.css('[ng-click="createReport()"]')), 5000);
await element(by.css('[ng-click="createReport()"]').click();
Upvotes: 0