Currently, I am in the process of developing a series of automated tests for a software product within my company. The software itself is built using AngularJS, and to create the tests, I am utilizing Protractor.
My focus right now is on creating tests that cover the navigation aspect of the application. I have already implemented several tests that pass or fail based on specific criteria.
However, I am facing a challenge with one particular test related to navigating to a specific page within the application, which is the 'Charts' page. Upon initial access to this page, a dialog pops up prompting the user to either create a new chart or configure an existing one. In most cases, as a user, I would simply click 'Cancel' on this dialog to proceed to the page.
The issue arises when trying to simulate the action of clicking the 'Cancel' button within the automated test script.
All of the tests I have written are currently housed in the same file and run sequentially. For example:
/*Test that 'Alarms' menu item works correctly */
it('should navigate to the Alarms page', function() {
// Test steps here...
});
/*Test that 'Charts' menu item works correctly */
it('should navigate to the Charts page', function() {
// Test steps here...
});
/*Test that 'Export' menu item works correctly */
it('should navigate to the Export page', function() {
// Test steps here...
});
The test causing me trouble is the second one listed above.
When running the test from the command line, I encounter issues during the execution:
// Command sequence displayed here...
In the problematic test, there is a function call to close the dialog on the 'Charts' page. A `browser.wait(...)` function has been added before it to ensure the dialog fully loads before attempting to close it:
// Code snippet here...
The `closeDlg()` function code is designed to handle the closing of the dialog:
// Function content displayed here...
Despite adding the `browser.wait(...)` within the function, the console outputs a Jasmine spec timeout error, and the browser remains stuck on the 'Charts' page with the dialog open, hampering further test execution.
How can I effectively address the issue of accessing and clicking the dialog's 'Cancel' button within my automated test script?
Edit:
Upon further inspection, an error message appears in the console where `webdriver-manager start` was executed once the `closeDlg()` function is called by the test:
It seems this issue may be related to Angular/Protractor synchronization. How could I go about resolving this matter?