Currently, I am incorporating the page object model alongside nightwatch for my testing procedures. Encountering challenges while trying to interact with an element led me to execute some jquery. However, the 'execute' command is not featured in the available subset of commands within the page object api. To utilize it, I am required to invoke the complete nightwatch command api. For further information on this matter, please refer to https://github.com/nightwatchjs/nightwatch/wiki/Page-Object-API. My query is how can I revert back to the page object api after executing my jquery statement.
Here is an outline of my page object:
elements: {
nameInput: 'input[name="name"]',
billingEmail: 'input[name="billingEmail"]',
licenseNumber: 'input[name="licenses.total"]',
licensePrice: 'input[name="subscription.price"]',
hardwareModel: 'input[name="model"]',
hardwareQuantity: 'input[name="quantity"]',
hardwarePrice: 'input[name="price"]',
customerEmail: 'input[name="customerEmail"]',
createButton: 'button[name="createAccount"]',
cancelButton: 'button[name="cancel"]',
},
inputClientDetails (name, email) {
this
.waitForElementVisible('body', 10000)
.setValue('@nameInput', name)
.setValue('@billingEmail', email)
.setValue('@licenseNumber', '10')
.setValue('@licensePrice', '9.99')
.api.execute(function () {
$('.datepicker--wrapper').find('input[type=text]').val('2017-08-30').trigger($.Event("keydown", {keyCode: 40}));
})
.setValue('@hardwareModel', 'Test model')
.setValue('@hardwarePrice', '9.99')
.setValue('@hardwareQuantity', '10')
.setValue('@customerEmail', email)
.click('@createButton')
return this.api;
},
While executing the test, I encounter the following error: ERROR: Unable to locate element: "@hardwareModel" using: css selector
Interestingly, when the 'execute' statement is absent from the page object, no issue arises. Hence, I am curious if there is a way to revert to the page object api after engaging with the primary nightwatch api. I attempted to incorporate a return statement within the function, but it proved to be ineffective.