Selenium 硒测试不';跑不动

Selenium 硒测试不';跑不动,selenium,selenium-webdriver,netbeans-8,Selenium,Selenium Webdriver,Netbeans 8,我正在为Booth的乘法编写一个程序,作为Netbeans 8.2中的JAVA Web应用程序。我正在使用selenium-server-standalone-2.50.1.jar和firefox46 当我编写代码并运行它时,它只会打开页面,但不会进行任何测试。请帮忙 /* * To change this license header, choose License Headers in Project Properties. * To change this template file,

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

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

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

    }
}
My 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或更高版本

什么是Selenium,Java版本?@kushal Selenium 2.50.1 Java 1.8 Firefox 46如果您使用的是Java 8,那么Selenium版本也应该是3.0或更高版本,您需要使用geckodriver来运行firefoxElse,您需要降级到Java 1.7好的,您解决了这个问题吗?反过来说,如果您使用的是selenium版本>3.0,那么java版本至少应该是8。。。。如果您使用的是java版本8,那么旧的jar将无法工作。。。这里的问题是
Selenium版本
FF版本
的兼容性。