forked from juice-shop/juice-shop
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Wait for alerts using ExpectedConditions
(see http:https://stackoverflow.com/questions/31667573/how-to-click-ok-in-alert-box-using-protractor)
- Loading branch information
1 parent
d5bbdc7
commit 11e6495
Showing
4 changed files
with
12 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,32 +7,19 @@ describe('/rest', function () { | |
protractor.beforeEach.login({email: '[email protected]', password: 'admin123'}); | ||
|
||
it('should be possible to create a new product when logged in', function () { | ||
var EC = protractor.ExpectedConditions; | ||
|
||
browser.ignoreSynchronization = true; | ||
browser.executeScript('var $http = angular.injector([\'juiceShop\']).get(\'$http\'); $http.post(\'/api/Products\', {name: \'XSS4\', description: \'<script>alert("XSS4")</script>\', price: 47.11});'); | ||
browser.driver.sleep(2000); | ||
|
||
browser.get('/#/search'); | ||
browser.driver.sleep(3000); | ||
|
||
browser.wait(EC.alertIsPresent(), 5000, "'XSS4' alert is not present"); | ||
browser.switchTo().alert().then( | ||
function (alert) { | ||
expect(alert.getText()).toEqual('XSS4'); | ||
alert.accept(); | ||
browser.executeScript('var $http = angular.injector([\'juiceShop\']).get(\'$http\'); $http.put(\'/api/Products/12\', {description: \'alert disabled\'});'); | ||
browser.driver.sleep(3000); | ||
browser.ignoreSynchronization = false; | ||
}); | ||
|
||
browser.switchTo().alert().then( | ||
function (alert) { | ||
alert.accept(); | ||
}, | ||
function(err) { | ||
console.log('Second alert did not trigger. No big deal.'); | ||
} | ||
); | ||
|
||
}); | ||
|
||
protractor.expect.challengeSolved({challenge: 'xss4'}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters