After logging in to a web page, we need to use a for loop to perform multiple tests on the page. The ideal test scenario involves a table with buttons on each row that leads to another page where data needs to be validated. Currently, all expectations and assertions are placed in a single IT block, which is not an optimal solution. It's necessary to separate the tests into different IT blocks.
require('..\\waitAbsent.js');
require("../node_modules/jasmine-expect/index.js");
var EC = protractor.ExpectedConditions;
describe('Student Enrollment Page Content Validation', function() {
beforeAll(function () {
browser.driver.manage().window().maximize();
browser.get(globalVariables.loginMain);
globalVariables.Email_Input_box.sendKeys(globalVariables.Demo_User);
globalVariables.Password_Input_Box.sendKeys(globalVariables.Demo_PWD);
globalVariables.Submit_Button.click();
browser.wait(EC.invisibilityOf(globalVariables.Submit_Button), 25000, 'submit button is not disappearing yet');
});
async function Row_Numbers() {
const RowCount = (globalVariables.tableData_Dashboard.all(by.tagName("tr")).count()).then(function(RC){
return RC;
});
}
for (var i = 1; i<Row_Numbers(); i++){
function tableData(n){
var row_1 = globalVariables.tableData_Dashboard.all(by.tagName("tr")).get(n);
// get cell values
var cells = row_1.all(by.tagName("td"));
it ('should return the data fo the first cell', function(){
var Student_ID = cells.get(0).getText().then(function (SID) {
console.log(SID);
return SID;
});
expect(Student_ID.toEqual('Something'));
});
it ("should show the button in this row", async function(){
const Button = globalVariables['Edit_Button_' + n];
// console.log(Button)
expect(await Button.isDisplayed());
Button.click();
// do some thing
});
}tableData(i)
}
});
When running the test using this script, an error message appears:
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 involve s client-side navigation, which can interfere with Protractor's bootstrapping. See https://github.com/angular/protractor/issues/2643 for details"
How can I modify the for loop to accomplish our objective?