J'écris un programme pour la multiplication de Booth en tant qu'application Web JAVA dans Netbeans 8.2. J'utilise selenium-server-standalone-2.50.1.jar et Firefox 46.Le test sélénium ne fonctionne pas
Lorsque j'écris mon code et l'exécute, il ouvre juste la page mais aucun test ne se produit. S'il vous plaît aider.
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
*
*/
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
public class booth {
private WebElement element, element1;
public String str;
public void Mul_Positive(){
WebDriver driver = new FirefoxDriver();
driver.get("http://localhost:8080/BoothsMul/index.html");
element = driver.findElement(By.xpath("//input[@name='t1']"));
element.sendKeys("2");
str = driver.findElement(By.xpath("//input[@name='t1']")).getText();
System.out.println(str);
element1 = driver.findElement(By.xpath("//input[@name='t2']"));
element1.sendKeys("5");
str = driver.findElement(By.xpath("//input[@name='t2']")).getText();
System.out.println(str);
driver.findElement(By.xpath("//input[@name='submit']")).click();
driver.quit();
}
public void Mul_Negative(){
WebDriver driver = new FirefoxDriver();
driver.get("http://localhost:8080/BoothsMul/index.html");
element = driver.findElement(By.xpath("//input[@name='t1']"));
element.sendKeys("c");
str = driver.findElement(By.xpath("//input[@name='t1']")).getText();
System.out.println(str);
element = driver.findElement(By.xpath("//input[@name='t2']"));
element.sendKeys("5");
str = driver.findElement(By.xpath("//input[@name='t2']")).getText();
System.out.println(str);
driver.findElement(By.xpath("//input[@name='submit']")).click();
driver.quit();
}
public static void main(String[] args){
booth b = new booth();
b.Mul_Positive();
b.Mul_Negative();
}
}
Mon index.html
<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
<body>
<form name='f1' action='http://localhost:8080/BoothsMul/Boothmul' method='get'>
First No. <input type='text' name='t1'><br>
Second No. <input type='text' name='t2'><br>
<input type='submit' name='submit' value='submit'>
</form>
</body>
</html>
Quelles sont vos sélénium, version Java? – kushal
@kushal Selenium 2.50.1 Java 1.8 Firefox 46 – Varun
Si vous utilisez Java 8 alors la version de sélénium doit être 3.0 ou supérieure aussi, vous devrez utiliser geckodriver pour exécuter firefox – kushal