I am working with protractor.js and successfully logging in to my application. However, I encounter a pop-up immediately after login where I need to select a value from a dropdown menu. Despite trying different methods with protractor.js, I have not been able to accomplish this task. The code snippet that I am struggling with is provided below.
describe('angularjs homepage todo list', function() {
it('should add a todo', function() {
browser.ignoreSynchronization = true;
browser.get('https://sample.com');
//browser.waitForAngular();
//browser.sleep(10000);
browser.pause();
element(by.id('userId')).sendKeys('<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="1d7772757364336e78716b7c6f7c775d69786e69337e7270">[email protected]</a>');
browser.manage().timeouts().pageLoadTimeout(5000);
element(by.id('password')).sendKeys('*********');
browser.manage().timeouts().pageLoadTimeout(5000);
**element(by.className('id-login-button wk-button-primary wk-button-full')).click();**
//browser.manage().timeouts().pageLoadTimeout(5000);
//browser.ignoreSynchronization = false;
browser.sleep(20000);
browser.switchTo().defaultContent();
browser.wait( done => {
return element(by.model('productSelectionCtrl.selectedProduct')).isPresent();
})
.then(()=>{
element(by.model('productSelectionCtrl.selectedProduct')).click();
element(by.cssContainingText('option', 'Master Suite')).click();
browser.sleep(20000);
done;
});
});
});
The issue arises once the script reaches the highlighted line. From there onwards, I attempt to click on a specific class within the pop-up window and select the "Master suite" option from a dropdown menu which is associated with ng-model(productSelectionCtrl.selectedProduct). Unfortunately, this action is not being performed as intended. Any assistance in resolving this would be greatly appreciated.
Despite attempting [(browser.ignoreSynchronization = false;)] since the initial page utilizes Angular, my efforts have not yielded successful results. I suspect that the problem may lie with the wait or timeout functions. Below is the error message displayed in the console:
Failures:
1) angularjs homepage todo list should add a todo
Message:
Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.
Stack:
Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.
at tryOnTimeout (timers.js:232:11)
at Timer.listOnTimeout (timers.js:202:5)
1 spec, 1 failure
Finished in 36.928 seconds
[18:20:14] I/launcher - 0 instance(s) of WebDriver still running
[18:20:14] I/launcher - chrome #01 failed 1 test(s)
[18:20:14] I/launcher - overall: 1 failed spec(s)
[18:20:14] E/launcher - Process exited with error code 1