I have an existing CasperJS test script in the following format:
casper.test.begin('SIDEBAR', function (test) {
var iconExists = casper.exists('#sideNavIcon');
test.assert(iconExists, 'Icon exists on the sidebar');
casper
.waitForSelector('#sidebar-spinner')
.then(function () {
test.assertVisible('.sidebar-notifications', 'Notifications are visible on the sidebar');
test.assert(
casper.getElementInfo('#sidebar-notifications-unread').text === casper.getElementInfo('.header-alerts-unread').text,
'The unread counts on the sidebar and header match'
);
});
};
I am now trying to modify the tests to include multiple classes or Ids for each of the assert statements, and only one of them can be present. I believe I could do something like the following:
casper.test.begin('SIDEBAR', function (test) {
var iconExists = casper.exists('#sideNavIcon') || casper.exists('#alertsIcon');
test.assert(iconExists, 'Icon exists on the sidebar');
casper
.waitForSelector('#sidebar-spinner')
.then(function () {
test.assertVisible('.sidebar-notifications', 'Notifications are visible on the sidebar') || test.assertVisible('.sidebar-alerts', 'Notifications are visible on the sidebar');
test.assert(casper.getElementInfo(...).text == ....) || test.assert(casper.getElementInfo(...).text == ....)
The above solution looks very 'dirty' and I am also having trouble to get this to work with the last assert. Is there a better way of achieving this? Any help would be much appreciated.
Aucun commentaire:
Enregistrer un commentaire