Selenium 测试没有 运行

Selenium Test doesn't run

我正在 Netbeans 8.2 中为 Booth 的乘法编写程序作为 JAVA Web 应用程序。我正在使用 selenium-server-standalone-2.50.1.jar 和 Firefox 46.

当我编写我的代码并 运行 它时,它只是打开页面,但没有进行任何测试。请帮忙。

/*
 * 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();

    }
}

我的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>

更新:

如果您使用 selenium 3.0.1 或更高版本,那么 JAVA 版本也应该是 1.8,您需要使用 geckodriver 到 运行 Firefox。 (在这种情况下,请确保您使用的是所有必需组件的最新版本)

否则,您需要将 Selenium 版本升级到 3.0 or higher