Page 2 sur 3

(SQUASH_TA).Comment tester "Votre login ou mot de passe est invalide !"

Publié : mer. mai 30, 2018 6:15 pm
par qdusser
Bonsoir,

Il ne s'agit pas de votre pom.xml, mais de votre test.java.

Envoyez moi aussi une capture d'écran de vos configurations de run, s'il vous plait (lorsque vous appuyez sur la petite flèche "play" d'éclipse pour lancer le test.ta).

cordialement,

Quentin

(SQUASH_TA).Comment tester "Votre login ou mot de passe est invalide !"

Publié : mer. mai 30, 2018 6:20 pm
par AIDEZMOI
Rebonjour Monsieur Quentin,

Je vous redonne mon test.java (C_MONJAVA.java), ci-joint ainsi que la config de lancement (LANCEMENT.jpg) .

Cordialement
Maurice Olivier

(SQUASH_TA).Comment tester "Votre login ou mot de passe est invalide !"

Publié : mer. mai 30, 2018 6:26 pm
par AIDEZMOI
C_MONJAVA.java

(SQUASH_TA).Comment tester "Votre login ou mot de passe est invalide !"

Publié : mer. mai 30, 2018 6:27 pm
par AIDEZMOI
C_MONJAVA.txt pou le java

(SQUASH_TA).Comment tester "Votre login ou mot de passe est invalide !"

Publié : mer. mai 30, 2018 6:29 pm
par AIDEZMOI
Je pense qu'il ne passe pas en PJ, désolé :

import java.util.regex.Pattern;
import java.util.concurrent.TimeUnit;
import org.junit.*;
import static org.junit.Assert.*;
import static org.hamcrest.CoreMatchers.*;
import org.openqa.selenium.*;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.Select;
import org.openqa.selenium.firefox.FirefoxBinary;
import org.openqa.selenium.firefox.FirefoxProfile;
import java.io.File;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;


public class C_MONJAVA {
private FirefoxBinary binary = new FirefoxBinary(new File("C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe"));
private FirefoxProfile profile = new FirefoxProfile();
private WebDriver driver;
private String baseUrl;
private boolean acceptNextAlert = true;
private StringBuffer verificationErrors = new StringBuffer();
// private String s_IHM_TEXT_EXPECTED = "Informations d'identification fournies non valides";
private String s_IHM_TEXT_EXPECTED = new String("XXXXXX_MESSAGE_D_ERREUR_BIDON_XXXXX");

@Before
public void setUp() throws Exception {
driver = new FirefoxDriver(binary,profile);
baseUrl = "https://CRYPTED";
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
}

@Test
public void Logintest() throws Exception {


System.out.println("@TEST AAAA DEBUT AAAA");

System.out.println("@TEST AAAAA s_IHM_TEXT_EXPECTED=[" + s_IHM_TEXT_EXPECTED + "]");

// log.info("XXXX");

driver.get(baseUrl);

driver.findElement(By.id("username")).clear();
driver.findElement(By.id("username")).sendKeys("LAURA");

driver.findElement(By.id("password")).clear();
driver.findElement(By.id("password")).sendKeys("bidon$");

driver.findElement(By.id("submitButton")).click();

driver.findElement(By.name("submit")).click();

// WebElement o_we_ELEMENT=driver.findElement(By.className("alert-danger"));
//
// String s_IHM_TEXT_GOT=o_we_ELEMENT.getText();
//
// System.out.println("@TEST AAAAA s_IHM_TEXT_GOT=[" + s_IHM_TEXT_GOT + "]");
//
// assertEquals(s_IHM_TEXT_GOT, s_IHM_TEXT_EXPECTED);

// Assert.assertTrue(o_we_ELEMENT.contains(s_IHM_TEXT_EXPECTED));


}

@After
public void tearDown() throws Exception {

System.out.println("@AFTER XXXXX DEBUT AAAA");


WebElement o_we_ELEMENT=driver.findElement(By.className("alert-danger"));

String s_IHM_TEXT_GOT=o_we_ELEMENT.getText();

System.out.println("@AFTER XXXXX s_IHM_TEXT_EXPECTED=[" + s_IHM_TEXT_EXPECTED + "]");
System.out.println("@AFTER AAAAA s_IHM_TEXT_GOT=[" + s_IHM_TEXT_GOT + "]");

if (s_IHM_TEXT_GOT.equals(s_IHM_TEXT_EXPECTED))
{
System.out.println("@AFTER AAAAA EGAL");
}
else
{
System.out.println("@AFTER AAAAA DIFFERENT");

}

assertEquals(s_IHM_TEXT_GOT, s_IHM_TEXT_EXPECTED);

// Assert.assertTrue(o_we_ELEMENT.contains(s_IHM_TEXT_EXPECTED));

//______________________________
driver.quit();
//______________________________

System.out.println("@AFTER AAAAA FIN AAAA");
String verificationErrorString = verificationErrors.toString();
if (!"".equals(verificationErrorString)) {
fail(verificationErrorString);
}
}

private boolean isElementPresent(By by) {
try {
driver.findElement(by);
return true;
} catch (NoSuchElementException e) {
return false;
}
}

private boolean isAlertPresent() {
try {
driver.switchTo().alert();
return true;
} catch (NoAlertPresentException e) {
return false;
}
}

private String closeAlertAndGetItsText() {
try {
Alert alert = driver.switchTo().alert();
String alertText = alert.getText();
if (acceptNextAlert) {
alert.accept();
} else {
alert.dismiss();
}
return alertText;
} finally {
acceptNextAlert = true;
}
}
}

(SQUASH_TA).Comment tester "Votre login ou mot de passe est invalide !"

Publié : jeu. mai 31, 2018 11:01 am
par qdusser
Bonjour,

Veuillez essayer avec ce script.

Cordialement,

Quentin

[center][color=#ff0000]LE SCRIPT[/color][/center]


import java.util.regex.Pattern;
import java.util.concurrent.TimeUnit;
import org.junit.*;
import static org.junit.Assert.*;
import static org.hamcrest.CoreMatchers.*;
import org.openqa.selenium.*;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.Select;
import org.openqa.selenium.firefox.FirefoxBinary;
import org.openqa.selenium.firefox.FirefoxProfile;
import java.io.File;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;


public class C_MONJAVA {
private FirefoxBinary binary = new FirefoxBinary(new File("C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe"));
private FirefoxProfile profile = new FirefoxProfile();
private WebDriver driver;
private String baseUrl;
private boolean acceptNextAlert = true;
private StringBuffer verificationErrors = new StringBuffer();
// private String s_IHM_TEXT_EXPECTED = "Informations d'identification fournies non valides";
private String s_IHM_TEXT_EXPECTED = new String("XXXXXX_MESSAGE_D_ERREUR_BIDON_XXXXX");

@Before
public void setUp() throws Exception {
driver = new FirefoxDriver(binary,profile);
baseUrl = "https://CRYPTED";
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
}

@Test
public void Logintest() throws Exception {


System.out.println("@TEST AAAA DEBUT AAAA");

System.out.println("@TEST AAAAA s_IHM_TEXT_EXPECTED=[" + s_IHM_TEXT_EXPECTED + "]");


driver.get(baseUrl);

driver.findElement(By.id("username")).clear();
driver.findElement(By.id("username")).sendKeys("LAURA");

driver.findElement(By.id("password")).clear();
driver.findElement(By.id("password")).sendKeys("bidon$");

driver.findElement(By.id("submitButton")).click();

driver.findElement(By.name("submit")).click();


WebElement o_we_ELEMENT=driver.findElement(By.className("alert-danger"));

String s_IHM_TEXT_GOT=o_we_ELEMENT.getText();

System.out.println("@AFTER XXXXX s_IHM_TEXT_EXPECTED=[" + s_IHM_TEXT_EXPECTED + "]");
System.out.println("@AFTER AAAAA s_IHM_TEXT_GOT=[" + s_IHM_TEXT_GOT + "]");

if (s_IHM_TEXT_GOT.equals(s_IHM_TEXT_EXPECTED))
{
System.out.println("@AFTER AAAAA EGAL");
}
else
{
System.out.println("@AFTER AAAAA DIFFERENT");

}

try{
assertTrue("/n LE MESSAGE D'ERREUR N'EST PAS CELUI ATTENDU /n",s_IHM_TEXT_GOT.equals(s_IHM_TEXT_EXPECTED));
}
catch(AssertionError ex){
System.out.println("/n LE MESSAGE D'ERREUR N'EST PAS CELUI ATTENDU /n");
throw ex;
}

System.out.println("/n LE MESSAGE D'ERREUR EST CONFORME /n");

}
@After
public void tearDown() {
System.out.println("/n fin du test /n");
driver.quit();

}
}

(SQUASH_TA).Comment tester "Votre login ou mot de passe est invalide !"

Publié : jeu. mai 31, 2018 11:29 am
par AIDEZMOI
Bonjour Monsieur Quentin,

Merci pour l'aménagement du java code.

Ci-joint la console.

Le squash-ta-report.html, ci-joint donne toujours un success (à tort pour ce que nous voulons vérifier fonctionnellement).

Agrèez mes cordiales salutations
Maurice Olivier

(SQUASH_TA).Comment tester "Votre login ou mot de passe est invalide !"

Publié : jeu. mai 31, 2018 2:22 pm
par qdusser
Bonjour,

Evoyez-moi un .zip de votre projet maven, je vous prie.

Quentin

(SQUASH_TA).Comment tester "Votre login ou mot de passe est invalide !"

Publié : jeu. mai 31, 2018 3:11 pm
par AIDEZMOI
Rebonjour Monsieur Quentin,

Ci-joint.

Bonne après-midi.
Maurice Olivier

(SQUASH_TA).Comment tester "Votre login ou mot de passe est invalide !"

Publié : jeu. mai 31, 2018 5:17 pm
par qdusser
Voici un projet inspiré du votre qui appelle la version 1.10.0 du framework Squash TA et utilise une version 3.4 de Selenium.

Pour lancer le build, téléchargez une jdk8 et configurez le build maven dessus.

De plus, vous verrez que le script lance le test sur google chrome, il vous faudra donc télécharger un "ChromeDriver" et le placer dans le répertoire C:\Selenium Drivers. Si vous voulez utiliser Firefox comme navigateur, il vous faudra un geckodriver (depuis Selenium 3).

Bonne soirée et bon courage dans votre projet d'automatisation.

Quentin