gns3-web-ui/e2e/helpers/project-map.po.ts

50 lines
1.8 KiB
TypeScript
Raw Normal View History

2020-02-26 18:39:36 +00:00
import { TestHelper } from "./common.po"
import { browser, by } from "protractor";
export class ProjectMapPage {
helper = new TestHelper();
async openAddProjectDialog() {
let addButton = await browser.driver.findElement(by.css('button.addNode'));
await addButton.click();
}
async addNode() {
let inputs = await browser.driver.findElements(by.css('input.mat-input-element'));
await inputs[0].sendKeys('VPCS');
this.helper.sleep(1000);
let selects = await browser.driver.findElements(by.css('mat-select.mat-select'));
await selects[1].click();
this.helper.sleep(1000);
let options = await browser.driver.findElements(by.css('mat-option.mat-option'));
await options[1].click(); //first option should be chosen
this.helper.sleep(1000);
// new select appears after refreshing data
selects = await browser.driver.findElements(by.css('mat-select.mat-select'));
if (selects[2]) {
await selects[2].click();
this.helper.sleep(1000);
options = await browser.driver.findElements(by.css('mat-option.mat-option'));
await options[0].click();
this.helper.sleep(1000);
}
let addButton = await browser.driver.findElement(by.css('button.addButton'));
await addButton.click();
this.helper.sleep(1000);
}
async verifyIfNodeWithLabelExists(labelToFind: string) {
let nodeLabel = await browser.driver.findElement(by.css('#map > g > g.layer > g.nodes > g:nth-child(1) > g > g > g > text'));
let selectedNode;
let textFromNodeLabel = await nodeLabel.getText();
if (textFromNodeLabel == labelToFind) selectedNode = nodeLabel;
return selectedNode ? true : false;
}
}