即時通訊新的Javascript(Nightwatch JS)和一般編程。守夜JS - 如果否則如果斷言
我有一個問題,在哪裏用我的If,Else If,Else測試用例,不用繼續Else If語句。
我想這是因爲我在IF語句中的條件是斷言(.expect.element();)
我想知道是否有人能給我什麼,我的IF語句做一些指點。
基本上我想驗證:
If (checkbox is un-clickable) {
run set code;
} Else if (this checkbox is clickable) {
run set code;
} Else {
.end();
}
這裏是我的樣品測試我做到了。
' Uninstall Missions Module ' : function(uninstallModule) {
\t uninstallModule
\t .url('http://drupal8.develop:8091/admin/modules/uninstall')
\t .setValue('#edit-text', "Missions")
\t .pause(800);
\t uninstallModule.expect.element('#edit-uninstall-missions').to.be.present;
\t uninstallModule.waitForElementVisible('//*[@id="system-modules-uninstall"]/table/tbody/tr[31]/td[3]/div/div/ul/li/a', 1000, false);
\t if (uninstallModule.expect.element('#edit-uninstall-missions').to.not.be.enabled) {
\t \t uninstallModule.expect.element('body').text.to.contain('Remove mission entities')
\t \t uninstallModule
\t \t .url('http://drupal8.develop:8091/admin/modules/uninstall/entity/mission')
.verify.urlEquals('http://drupal8.develop:8091/admin/modules/uninstall/entity/mission');
uninstallModule.expect.element('body').text.to.contain('Are you sure you want to delete all mission entities?');
uninstallModule.click('xpath', '//*[@id="edit-submit"]');
uninstallModule
.pause(10000)
.verify.visible("body > div.layout-container > main > div.region.region-highlighted > div > h2", "All mission entities have been deleted.");
\t } else if (uninstallModule.expect.element('#edit-uninstall-missions').to.be.enabled) {
\t \t uninstallModule
\t \t .url('http://drupal8.develop:8091/admin/modules/uninstall')
\t .setValue('#edit-text', "Missions");
\t uninstallModule.click('#edit-uninstall-missions');
\t uninstallModule.pause(800);
\t uninstallModule.verify.urlEquals("http://drupal8.develop:8091/admin/modules/uninstall/confirm");
\t uninstallModule.click('xpath', '//*[@id="edit-submit"]');
\t uninstallModule.pause(1000);
\t uninstallModule.verify.visible('body > div.layout-container > main > div.region.region-highlighted > div.messages.messages--status', "The selected modules have been uninstalled.");
\t } else {
\t \t uninstallModule.end();
\t }
}, \t \t
}
謝謝你,你一直是最有幫助的! –