Selenium Test не запускается

Я пишу программу для умножения Бута как веб-приложение JAVA в Netbeans 8.2. Я использую 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>

1 ответ

Решение

ОБНОВЛЕНО:

Если вы используете selenium 3.0.1 или выше, чем версия JAVA должна быть также 1.8, вам нужно использовать geckodriver бежать Firefox, (Убедитесь, что вы используете последние версии всех необходимых компонентов в этом случае)

Иначе, вам нужно обновить версию Selenium до 3.0 or higher,

Другие вопросы по тегам