Reputation: 289
learning Protractor & Angular, trying to write test that perform 100 simultaneous(!) requests on my server via clicking the button after fill input with some text. Current attempt:
it('Test negative, multiple submit', function() {
for (var i = 0; i <= 99; i++) {
element(by.name('userAnswer')).sendKeys('0101010101');
element(by.name('submit')).click();
}
expect(hasClass(element(by.name('userAnswer')), 'valid')).toBe(false);
});
It works, but it just 100 times in turn set value and then click on submit. How to perform it simultaneous I dunno. Just wanna test whats gonna happen with my serverside if it receive 100 synchronous requests. I hope what I have requested is possible, thanks in advance :)
Upvotes: 0
Views: 163
Reputation: 19193
A user cannot "simultaneously" click 100 times on the same button, and protractor is not supposed to do things that a user cannot do.
As is, your protractor code will act as if the user was clicking very fast 100 times on the button, and then check if userAnswer
has the class valid
right away.
Since that client code doesn't wait for the server to come back and say "alright I received your input", this should be enough to test your server against 100 simultaneous clicks.
Now it may be a XY problem, what is supposed to happen when the server receive 100 requests at the same time?
Also note that if your server is too fast you can mock some timeout between each response.
Upvotes: 3