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

[js] finish second part of E2E, the iris advanced toolchain, #119

parent 4f3eab03
No related branches found
No related tags found
1 merge request!10JS & Python Testing
......@@ -2,11 +2,14 @@
const {Builder, By, Key, until} = require('selenium-webdriver');
const firefox = require('selenium-webdriver/firefox');
const winX = 1920, winY = 1080;
const options = new firefox.Options();
options.addArguments('-headless');
options.addArguments(`--window-size=${ winX },${ winY }`);
(async function example() {
let driver = await new Builder().forBrowser('firefox').setFirefoxOptions(options).build();
await driver.manage().window().setRect({x: 0, y: 0, width: winX, height: winY});
try {
await driver.get('http://localhost:9101/');
......@@ -25,17 +28,17 @@ options.addArguments('-headless');
// make new exp
const eUser = await driver.findElement(By.css('input[placeholder="Experiment user..."]'));
eUser.clear();
eUser.sendKeys('selenium');
await eUser.clear();
await eUser.sendKeys('selenium');
const eName = driver.findElement(By.css('input[placeholder="Experiment name..."]'));
eName.clear();
eName.sendKeys('means');
await eName.clear();
await 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);
// go to new exp
await driver.findElement(By.linkText('selenium/test/iris/1/means')).click();
await driver.wait(until.elementLocated(By.css('div.experimentEditor')), 2000);
......@@ -60,14 +63,179 @@ options.addArguments('-headless');
await driver.findElement(By.css('div.experimentEditor > div.d-flex > button.btn-outline-secondary')).click();
await driver.sleep(1000);
/**************************************************************
* 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);
/**************************************************************
* ADVANCED IRIS TOOLCHAIN
*/
// navigate to tc list
await driver.findElement(By.linkText('toolchains')).click();
await driver.wait(until.elementLocated(By.css('input[placeholder="Search toolchains..."]'), 2000));
// click the clone button next to test/iris/1
let tLink = await driver.findElement(By.linkText('test/iris/1'));
await tLink.findElement(By.xpath('../..')).findElement(By.css('button.btn-outline-success + button.btn-outline-success')).click();
await driver.wait(until.elementLocated(By.css('.modal')), 2000);
// make new tc
const tUser = await driver.findElement(By.css('input[placeholder="Toolchain user..."]'));
await tUser.clear();
await tUser.sendKeys('selenium');
const tName = driver.findElement(By.css('input[placeholder="New toolchain name..."]'));
await tName.clear();
await tName.sendKeys('iris_advanced');
await driver.sleep(1000);
await driver.findElement(By.css('.modal button.btn-primary')).click();
await driver.wait(until.elementLocated(By.linkText('selenium/iris_advanced/1')), 2000);
await driver.sleep(1000);
// go to new tc
await driver.findElement(By.linkText('selenium/iris_advanced/1')).click();
await driver.wait(until.elementLocated(By.css('div.toolchainEditor')), 2000);
// delete conn between training_data.measurements & training_alg.measurements
let rcEl = await driver.findElement(By.css('#\\#training_data-measurements-training_alg-measurements'));
await driver.actions().contextClick(rcEl).perform();
await driver.sleep(1000);
await driver.findElement(By.css('nav.react-contextmenu--visible > div')).click();
// delete conn between testing_data.measurements & testing_alg.measurements
rcEl = await driver.findElement(By.css('#\\#testing_data-measurements-testing_alg-measurements'));
await driver.actions().contextClick(rcEl).perform();
await driver.sleep(1000);
await driver.findElement(By.css('nav.react-contextmenu--visible > div')).click();
// add training preprocessor block way below the rest of the toolchain
let originEl = await driver.findElement(By.css('#block_testing_data'));
await driver.actions().move({x: 100, y: 100, origin: originEl}).pause(500).contextClick().perform();
await driver.sleep(1000);
await driver.findElement(By.css('nav.react-contextmenu--visible > div:first-child')).click();
// edit training preprocessor
await driver.findElement(By.css('#block_block')).click();
await driver.sleep(1000);
// name
let tbName = await driver.findElement(By.css('#tcModalInitFocus'));
tbName.clear();
tbName.sendKeys('pre_training');
// input
await driver.findElement(By.css('.modal-body .btn-secondary')).click();
let tbiName = await driver.findElement(By.css('.modal-body > form > div.row input'));
await tbiName.clear();
await tbiName.sendKeys('measurements');
// output
await driver.findElement(By.css('.modal-body .col-sm-6 + .col-sm-6 .btn-secondary')).click();
let tboName = await driver.findElement(By.css('.modal-body > form > div.row .col-sm-6 + .col-sm-6 input'));
await tboName.clear();
await tboName.sendKeys('measurements');
await driver.sleep(1000);
//close
await driver.findElement(By.css('.modal button.close')).click();
await driver.sleep(1000);
// copy the block
rcEl = await driver.findElement(By.css('#block_pre_training'));
await driver.actions().contextClick(rcEl).perform();
await driver.sleep(1000);
await driver.findElement(By.css('nav.react-contextmenu--visible > div + div')).click();
// paste testing preprocessor block way below the rest of the toolchain
originEl = await driver.findElement(By.css('#block_pre_training'));
await driver.actions().move({x: 150, origin: originEl}).pause(500).contextClick().perform();
await driver.sleep(1000);
await driver.findElement(By.css('nav.react-contextmenu--visible > div:first-child')).click();
// unselect pasted block
await driver.actions().move({y: 200, origin: originEl}).pause(500).click().pause(500).perform();
// edit the block name
await driver.findElement(By.css('#block_pre_training0')).click();
await driver.sleep(1000);
tbName = await driver.findElement(By.css('#tcModalInitFocus'));
await tbName.clear();
await tbName.sendKeys('pre_testing');
await driver.sleep(1000);
//close
await driver.findElement(By.css('.modal button.close')).click();
await driver.sleep(1000);
//console.log('connecting');
// connect pre_training to rest of tc
// data to pre
let fromBox = await driver.findElement(By.css('rect#training_data-output-measurements'));
let toBox = await driver.findElement(By.css('rect#pre_training-input-measurements'));
await driver.actions().dragAndDrop(fromBox, toBox).pause(500).perform();
// pre to alg
fromBox = await driver.findElement(By.css('rect#pre_training-output-measurements'));
toBox = await driver.findElement(By.css('rect#training_alg-input-measurements'));
await driver.actions().dragAndDrop(fromBox, toBox).pause(500).perform();
//console.log('connecting 2');
// connect pre_testing to rest of tc
// data to pre
fromBox = await driver.findElement(By.css('rect#testing_data-output-measurements'));
toBox = await driver.findElement(By.css('rect#pre_testing-input-measurements'));
await driver.actions().dragAndDrop(fromBox, toBox).pause(500).perform();
// pre to alg
fromBox = await driver.findElement(By.css('rect#pre_testing-output-measurements'));
toBox = await driver.findElement(By.css('rect#testing_alg-input-measurements'));
await driver.actions().dragAndDrop(fromBox, toBox).pause(500).perform();
//console.log('fix channel');
// fix the channel on pre_training
await driver.findElement(By.css('#block_pre_training')).click();
await driver.sleep(1000);
await driver.findElement(By.css('.modal-body select.form-control')).click();
await driver.findElement(By.css('.modal-body option[value="training_data"]')).click();
await driver.sleep(500);
await driver.findElement(By.css('.modal button.close')).click();
await driver.sleep(1000);
//console.log('getting layout');
// layout the tc
await driver.findElement(By.xpath('//button[contains(.,"Layout")]')).click();
// needs to communicate w graphviz, give it some time
await driver.sleep(5000);
// make sure the tc is still valid
await driver.wait(until.elementLocated(By.css('.badge-success')), 2000);
// save
//await driver.findElement(By.css('div.toolchainEditor > div.d-flex > button.btn-outline-secondary')).click();
//await driver.sleep(1000);
/**************************************************************
* CLEANUP
*/
// go back and delete toolchain
await driver.findElement(By.linkText('toolchains')).click();
await driver.wait(until.elementLocated(By.css('input[placeholder="Search toolchains..."]'), 2000));
tLink = await driver.findElement(By.linkText('selenium/iris_advanced/1'));
await tLink.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);
/**************************************************************
* ADVANCED IRIS PREPROCESSOR ALGORITHM
*/
/**************************************************************
* CLEANUP
*/
/**************************************************************
* ADVANCED IRIS EXPERIMENT
*/
......@@ -76,15 +244,6 @@ options.addArguments('-headless');
* 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!');
......
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