I have a simple test that my Dev colleagues would like to run repeatedly - they have experienced issues where a page loads, then refuses to render correctly.
Here is the code of the test:
describe('DBM Tags', function() {
it('clears prefill basket', function() {
var startTime;
browser.get('https://gxptag.guestline.net/qa/');
// browser.driver.manage().window().maximize();
browser.ignoreSynchronization = true,
browser.sleep(3000);
expect(browser.getTitle()).toEqual('DBM QA Tag Tester');
browser.sleep(500);
//timer start
browser.controlFlow().execute(function() {
startTime = new Date().getTime();
});
//Clicks on basket prefill to load Hotel1
element(by.xpath("/html/body/div[1]/div[1]/button[6]")).click();
browser.switchTo().frame(element(by.tagName('iframe')).getWebElement());
browser.sleep(500);
var EC = protractor.ExpectedConditions;
var e = element(by.xpath ('/html/body/div[1]/div[2]/div/div[2]/div/div[2]/div[2]/div/div[1]/div/span'));
browser.wait(EC.presenceOf(e),5000);
//timer stop
browser.controlFlow().execute(function() {
var endTime = new Date().getTime();
var elapsedTime = endTime - startTime;
console.log('Elapsed Time Basket Prefill modal = ' + elapsedTime + 'ms');
});
browser.switchTo().defaultContent();
//verifies there is a value
browser.switchTo().frame(element(by.tagName('iframe')).getWebElement());
var value1 = element(by.xpath('/html/body/div[1]/div[2]/div/div[2]/div/div[2]/div[2]/div/div[2]/div/div/div/div[2]/div/div[1]/span/span'));
expect(value1.getText()).toEqual('£440.00');
browser.sleep(1000);
//closes modal
browser.switchTo().defaultContent();
element(by.xpath('//*[@id="dbm-close-btn"]')).click();
browser.sleep(500);
//clicks on Hotel1
element(by.xpath('/html/body/div[1]/div[1]/button[3]')).click();
browser.sleep(3000);
//clears room
browser.switchTo().frame(element(by.tagName('iframe')).getWebElement());
browser.sleep(3000);
element(by.deepCss('.removeBooking > svg:nth-child(1)')).click();
browser.sleep(1000);
browser.switchTo().defaultContent();
element (by.xpath('//*[@id="dbm-close-btn"]')).click();
browser.sleep(1000);
});
});
What I want to do is loop this code x times...in the old VB parlance
for x = 1 to 100,
//code here
next x
I appreciate we need to consider promises but any other advice would be greatly appreciated.
Thanks