Currently, I am utilizing protractor for the e2e testing of my application. In the process of updating a record, I am creating an array of new values to compare with the old ones to ensure proper updates.
One of the fields in question is a select menu, and I am aiming to extract the text from the option and add it to the array.
To select the option, I am using:
element(by.id(fieldName6)).click().then(function() {
element(by.css('#' + fieldName6 + ' option:nth-child(2)')).click();
});
This method is working smoothly. However, now I need to retrieve the text (not the value) of that option to include in the array. I attempted the following approaches:
newValues.push(browser.executeScript("$('#" + fieldName6 + " option:nth-child(3)').text()"));
which resulted in
Promise::17234 {[[PromiseStatus]]: "pending"}
, and
newValues.push(element(by.css('#' + fieldName6)).$('option:checked').getText());
which returned [object Object]
.
I seem to be stuck at this point. Any assistance or guidance would be highly appreciated.