Skip to content
Snippets Groups Projects
Commit f2b8075b authored by Jaden DIEFENBAUGH's avatar Jaden DIEFENBAUGH
Browse files

[js] added first part of selenium test for tutorial

parent 3bd52765
No related branches found
No related tags found
1 merge request!10JS & Python Testing
// must have the rest server running with at least the contents of the tutorial prefix
const {Builder, By, Key, until} = require('selenium-webdriver');
const firefox = require('selenium-webdriver/firefox');
const options = new firefox.Options();
//options.addArguments('-headless');
(async function example() {
let driver = await new Builder().forBrowser('firefox').setFirefoxOptions(options).build();
try {
await driver.get('http://localhost:9101/');
// create the means experiment
// navigate to exp list
await driver.findElement(By.linkText('experiments')).click();
//.sendKeys('webdriver', Key.RETURN);
await driver.wait(until.elementLocated(By.css('input[placeholder="Search experiments..."]'), 2000));
// click the clone button next to test/test/iris/1/iris
let eLink = await driver.findElement(By.linkText('test/test/iris/1/iris'));
await eLink.findElement(By.xpath('../..')).findElement(By.css('button.btn-outline-success')).click();
await driver.wait(until.elementLocated(By.css('.modal')), 2000);
// make new exp
const eUser = await driver.findElement(By.css('input[placeholder="Experiment user..."]'));
eUser.clear();
eUser.sendKeys('selenium');
const eName = driver.findElement(By.css('input[placeholder="Experiment name..."]'));
eName.clear();
eName.sendKeys('means');
await driver.sleep(1000);
await driver.findElement(By.css('.modal button.btn-primary')).click();
// go to new exp
await driver.wait(until.elementLocated(By.linkText('selenium/test/iris/1/means')), 2000);
await driver.sleep(1000);
await driver.findElement(By.linkText('selenium/test/iris/1/means')).click();
await driver.wait(until.elementLocated(By.css('div.experimentEditor')), 2000);
// CLEANUP
// go back and delete exp
await driver.findElement(By.linkText('experiments')).click();
await driver.wait(until.elementLocated(By.css('input[placeholder="Search experiments..."]'), 2000));
eLink = await driver.findElement(By.linkText('selenium/test/iris/1/means'));
await eLink.findElement(By.xpath('../..')).findElement(By.css('button.btn-outline-danger')).click();
await driver.sleep(1000);
await driver.findElement(By.css('.modal button.btn-danger')).click();
await driver.sleep(1000);
console.log('selenium tests finished successfully!');
} catch(e) {
console.log('selenium tests failed!');
console.error(e);
} finally {
await driver.quit();
}
})();
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment