Created
October 23, 2020 19:02
-
-
Save klamping/e27d36cadd656af5a1827f5326bc4922 to your computer and use it in GitHub Desktop.
Example of test generator
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
function runTest (options) { | |
browser.url(options.siteUrl); | |
options.inputs.forEach(input => { | |
$(input.selector).setValue(input.value); | |
}); | |
$(options.submitSelector).click(); | |
} | |
const tests = [ | |
{ | |
name: 'Test Name 1', | |
siteUrl: 'https://exampleone.com', | |
inputs: [ | |
{ | |
selector: '#productName', | |
value: 'Widget' | |
}, | |
{ | |
selector: '#qty', | |
value: 1 | |
}, | |
{ | |
selector: '#diameter', | |
value: 2.2 | |
} | |
], | |
submitSelector: '#submit' | |
}, | |
{ | |
name: 'Test Name 2', | |
siteUrl: 'https://exampletwo.com', | |
inputs: [ | |
{ | |
selector: '.product', | |
value: 'Thingamajig' | |
}, | |
{ | |
selector: '.quantity', | |
value: 2 | |
}, | |
{ | |
selector: '.radius', | |
value: 5 | |
} | |
], | |
submitSelector: '#submit' | |
} | |
]; | |
describe('My Tests', function () { | |
tests.forEach(test => { | |
it(test.name, function () { | |
runTest(test); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment