We have taken Page Object Model (POM) approach. It works perfectly fine when ‘Control Flow’ is enabled.
But when we disable ‘Control Flow’ in conf.js file by flag SELENIUM_PROMISE_MANAGER: false
and apply Async/Await we are getting following error message:-
S D:oldcode> protractor Conf.js
[15:37:02] I/launcher - Running 1 instances of WebDriver
[15:37:02] I/direct - Using ChromeDriver directly...
DevTools listening on ws://127.0.0.1:64832/devtools/browser/1d68c5dc-5b58-495a-9db9-
c1d45c531723
Started
.
1 spec, 0 failures
Finished in 0.018 seconds
[15:37:07] E/launcher - Error while waiting for Protractor to sync with the page: "both
angularJS testability and angular testability are undefined. This could be either
because this is a non-angular page or because your test involves client-side navigation,
which can interfere with Protractor's bootstrapping. See http://git.io/v4gXM for
details"
[15:37:07] E/launcher - Error: Error while waiting for Protractor to sync with the page:
"both angularJS testability and angular testability
are undefined. This could be either because this is a non-angular page or because your
test involves client-side navigation, which can interfere with Protractor's
bootstrapping. See http://git.io/v4gXM for details"
at C:UsersDbindalAppDataRoamingnpmnode_modulesprotractorbuiltbrowser.js:461:23
at processTicksAndRejections (node:internal/process/task_queues:96:5)Error
at ElementArrayFinder.applyAction_
(C:UsersDbindalAppDataRoamingnpmnode_modulesprotractorbuiltelement.js:459:27)
at ElementArrayFinder.<computed> [as click]
(C:UsersDbindalAppDataRoamingnpmnode_modulesprotractorbuiltelement.js:91:29)
at ElementFinder.<computed> [as click]
(C:UsersDbindalAppDataRoamingnpmnode_modulesprotractorbuiltelement.js:831:22)
at demoPage.submit (D:oldcodepage.js:34:18)
at UserContext.<anonymous> (D:oldcodedemo13_spec.js:13:16)
at
C:UsersDbindalAppDataRoamingnpmnode_modulesprotractornode_modulesjasminewd2index.js:112:25
at new Promise ()
at SimpleScheduler.promise
(C:UsersDbindalAppDataRoamingnpmnode_modulesprotractornode_modulesselenium-
webdriverlibpromise.js:2242:12)
at schedulerExecute
(C:UsersDbindalAppDataRoamingnpmnode_modulesprotractornode_modulesjasminewd2index.js:95:18)
at C:UsersDbindalAppDataRoamingnpmnode_modulesprotractornode_modulesselenium-
webdriverlibpromise.js:2232:22
[15:37:07] E/launcher – Process exited with error code 199
PS D:oldcode> [7160:14332:0111/153709.074:ERROR:device_event_log_impl.cc(214)]
[15:37:09.074] USB: usb_device_handle_win.cc:1048 Failed to read descriptor from node
connection: A device attached to the system is not functioning. (0x1F)
[7160:14332:0111/153709.077:ERROR:device_event_log_impl.cc(214)] [15:37:09.077] USB:
usb_device_handle_win.cc:1048 Failed to read descriptor
from node connection: A device attached to the system is not functioning. (0x1F)
[7160:21072:0111/153709.120:ERROR:chrome_browser_main_extra_parts_metrics.cc(226)]
crbug.com/1216328: Checking Bluetooth availability started. Please report if there is no
report that this ends.
[7160:21072:0111/153709.128:ERROR:chrome_browser_main_extra_parts_metrics.cc(229)]
crbug.com/1216328: Checking Bluetooth availability ended.
[7160:21072:0111/153709.129:ERROR:chrome_browser_main_extra_parts_metrics.cc(232)]
crbug.com/1216328: Checking default browser status started. Please report if there is no
report that this ends.
[7160:21072:0111/153709.143:ERROR:chrome_browser_main_extra_parts_metrics.cc(236)]
crbug.com/1216328: Checking default browser status ended.
[2632:18876:0111/153905.755:ERROR:gpu_init.cc(457)] Passthrough is not supported, GL is
disabled, ANGLE is
We have used two .js files. One for locators and action methods is page.js and its code is as below
let demoPage = function () {
let prefix = element(by.xpath("//input[@value = 'Mr']"));
let firstname = element(by.id('first-name'));
let lastname = element(by.id('last-name'));
let subject = element(by.xpath("//input[@value = 'Computers']"));
let street = element(by.id('street'));
let city = element(by.cssContainingText('option', 'Delhi'));
let zip = element(by.id('zip'));
let submit = element(by.xpath("//button[@type = 'submit']"));
let link = element(by.partialLinkText('Link'));
let hover = element(by.xpath('//*[contains(text(), "Mouse Over")]'))
this.get= async function(url){
await browser.get(url);
await browser.manage().window().maximize();
expect(await browser.getCurrentUrl()).toBe('http://localhost:4200/');
}
this.submit= async function(fn, ln, str, zp){
await prefix.click();
await firstname.click().sendKeys(fn);
await lastname.click().sendKeys(ln);
await subject.click();
await street.click().sendKeys(str);
await city.click();
await zip.click().sendKeys(zp);
await browser.actions().mouseMove(hover).perform();
text= await browser.driver.switchTo().alert().getText();
console.log(text);
await browser.driver.switchTo().alert().accept();
await submit.click();
}
};
module.exports = new demoPage();
The other test file is testspec.js and its code is as follow –
let demoPage = require('./page');
describe('mySuite', function () {
it('Test case', function () {
demoPage.get("http://localhost:4200/");
demoPage.submit("John", "Smith", "CP", "110001");
});
});
It would be great if the community here guide me in finding a solution. I am thankful in advance for the invaluable advice from fellow members.