function browserLaunched(utils) {
logger("Début du script Selenium");
var wd = utils.getWebDriver();
wd.get(ihm);
var url = utils.waitForURL(2000);
logger('browserLaunched ' + utils.getBrowserId() + ' url: ' + url);
logger("Proxy : " + utils.getProxyAddress() + ":" + utils.getProxyPort());
if (url.startsWith(ihm)){
selenium(wd);
}
}
// Logging with the script name is super helpful!
function logger() {
}
(async function selenium(driver){
try{
// Apply timeout for 15 seconds
await driver.manage().setTimeouts( { implicit: 15000 } );
// Navigate to url
//Création d'un projet
console.log("Je veux créer un premier projet");
await driver.findElement(By.xpath("/html/body/jhi-main/ciri-navbar/header/nav/mat-toolbar/mat-toolbar-row/div/a[1]")).click();
await driver.findElement(By.xpath("/html/body/jhi-main/div/projects/mat-drawer-container/mat-drawer-content/div/div/div/div/button")).click();
await driver.findElement(By.xpath("/html/body/div[1]/div[2]/div/mat-dialog-container/create-project/mat-dialog-content/div[1]/mat-form-field/div/div[1]/div")).click();
await driver.findElement(By.xpath("/html/body/div[1]/div[2]/div/mat-dialog-container/create-project/mat-dialog-content/div[1]/mat-form-field/div/div[1]/div/input")).sendKeys("Test1");
await driver.findElement(By.xpath("/html/body/div[1]/div[2]/div/mat-dialog-container/create-project/mat-dialog-content/div[2]/mat-form-field/div/div[1]/div[3]")).click();
await driver.findElement(By.xpath("/html/body/div[1]/div[2]/div/mat-dialog-container/create-project/mat-dialog-content/div[2]/mat-form-field/div/div[1]/div[3]/textarea")).sendKeys("Ceci est le projet de tests numéro 1");
await driver.findElement(By.xpath("/html/body/div[1]/div[2]/div/mat-dialog-container/create-project/mat-dialog-content/div[4]/div[2]/button")).click();
await driver.findElement(By.xpath("/html/body/div[1]/div[2]/div/mat-dialog-container/create-project/mat-dialog-content/div[5]/div/div[3]/gridster/gridster-item")).click();
await driver.findElement(By.xpath("/html/body/div[1]/div[2]/div/mat-dialog-container/create-project/mat-dialog-content/div[5]/div/div[4]/div/div/button")).click();
await driver.findElement(By.xpath("/html/body/div[1]/div[2]/div/mat-dialog-container/create-project/mat-dialog-content/div[6]/mat-form-field/div/div[1]/div")).click();
await driver.findElement(By.xpath("/html/body/div[1]/div[2]/div/mat-dialog-container/create-project/mat-dialog-content/div[6]/mat-form-field/div/div[1]/div/input")).sendKeys("release");
await driver.findElement(By.xpath("/html/body/div[1]/div[2]/div/mat-dialog-container/create-project/mat-dialog-content/div[7]/mat-form-field/div/div[1]/div")).click();
await driver.findElement(By.xpath("/html/body/div[1]/div[2]/div/mat-dialog-container/create-project/mat-dialog-content/div[7]/mat-form-field/div/div[1]/div/input")).sendKeys("cycle");
await driver.findElement(By.xpath("/html/body/div[1]/div[2]/div/mat-dialog-container/create-project/mat-dialog-content/div[8]/div[2]/button")).click();
await driver.findElement(By.xpath("/html/body/div[1]/div[4]/div/mat-dialog-container/create-campaign/mat-dialog-content/div/mat-form-field/div/div[1]/div")).click();
await driver.findElement(By.xpath("/html/body/div[1]/div[4]/div/mat-dialog-container/create-campaign/mat-dialog-content/div/mat-form-field/div/div[1]/div/input")).sendKeys("campagne");
await driver.findElement(By.xpath("/html/body/div[1]/div[4]/div/mat-dialog-container/create-campaign/mat-dialog-content/add-test-template/div/mat-stepper/div[2]/div[1]/div[4]/gridster/gridster-item[1]")).click();
await driver.findElement(By.xpath("/html/body/div[1]/div[4]/div/mat-dialog-container/create-campaign/mat-dialog-content/add-test-template/div/mat-stepper/div[1]/mat-step-header[2]/div[3]")).click();
await driver.findElement(By.xpath("/html/body/div[1]/div[4]/div/mat-dialog-container/create-campaign/mat-dialog-content/add-test-template/div/mat-stepper/div[2]/div[2]/table/tbody/tr[1]/td[2]/input")).click();
await driver.findElement(By.xpath("/html/body/div[1]/div[4]/div/mat-dialog-container/create-campaign/mat-dialog-content/add-test-template/div/mat-stepper/div[2]/div[2]/table/tbody/tr[1]/td[2]/input")).sendKeys("équipement");
await driver.findElement(By.xpath("/html/body/div[1]/div[4]/div/mat-dialog-container/create-campaign/mat-dialog-content/add-test-template/div/mat-stepper/div[2]/div[2]/div[2]/div/button[2]")).click();
await driver.findElement(By.xpath("/html/body/div[1]/div[4]/div/mat-dialog-container/create-campaign/mat-dialog-content/add-test-template/div/mat-stepper/div[2]/div[3]/div[2]/div/button[2]")).click();
//Attendre
await driver.findElement(By.className("bottom-right")).findElements(By.className('toast-body')).then(async function(elements){
while(elements.length != 0){
var elements = await driver.findElement(By.className("bottom-right")).findElements(By.className('toast-body'))
driver.sleep(1000);
}
})
await driver.findElement(By.xpath("/html/body/div[1]/div[4]/div/mat-dialog-container/create-campaign/mat-dialog-actions/button[2]")).click();
await driver.findElement(By.xpath("/html/body/div[1]/div[2]/div/mat-dialog-container/create-project/mat-dialog-actions/button[2]")).click();
console.log("Premier projet créé");
console.log("Fin du script Selenium");
}
finally{
driver.quit();
console.log("Browser closed");
}
}());