Skip to content

Instantly share code, notes, and snippets.

@klamping
Created October 23, 2020 19:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save klamping/e27d36cadd656af5a1827f5326bc4922 to your computer and use it in GitHub Desktop.
Save klamping/e27d36cadd656af5a1827f5326bc4922 to your computer and use it in GitHub Desktop.
Example of test generator
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