I'm writing this looping test in Mocha, trying to get it to visit a url
taken from sitesObj
, do a test, then repeat with the others. The only problem is the url
variable is "https://www.example.com/about"
throughout all of the tests.
In short: test.describe(site...
is working in the loop, but driver.get(url...
is not.
My code is below. Any help is very much appreciated!
//Driver + test setup
var sitesObj = {
"Homepage": "https://www.example.com",
"About Page": "https://www.example.com/about"
}
for (site in sitesObj) {
var cid;
var pageName = site;
var url = sitesObj[site];
test.describe(site + ' CID Cookie Set Test', function() {
test.beforeEach(function(done) {
//Driver stuff
cid = Math.random().toString(36).substring(2, 6);
console.log(url + '?cid=' + cid); //URL is ALWAYS ...site.com/about...
driver.get(url + '?cid=' + cid); //URL is ALWAYS ...site.com/about...
driver.manage().timeouts().implicitlyWait(10000);
done();
});
//afterEach, quit, done
//Test 1, done
//Test 2, done
});
}
Aucun commentaire:
Enregistrer un commentaire