Пример кода Selenium не работает

1

Я следую примеру кода в селене, и я продолжаю получать ошибку "Ошибка: не удалось найти или загрузить тест основного класса". Я не уверен, что вызывает это при загрузке и распаковке селена и извлечении файлов jar в Eclipse. У меня также есть класс "Тест" в соответствующем файле, и я не уверен, что вызывает эту проблему. Вот код

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.htmlunit.HtmlUnitDriver;

public class Example  {
    public static void main(String[] args) {
        // Create a new instance of the html unit driver
        // Notice that the remainder of the code relies on the interface, 
        // not the implementation.
        WebDriver driver = new HtmlUnitDriver();

        // And now use this to visit Google
        driver.get("http://www.google.com");

        // Find the text input element by its name
        WebElement element = driver.findElement(By.name("q"));

        // Enter something to search for
        element.sendKeys("Cheese!");

        // Now submit the form. WebDriver will find the form for us from the element
        element.submit();

        // Check the title of the page
        System.out.println("Page title is: " + driver.getTitle());

        driver.quit();
    }
}
  • 0
    Где вы называете «Тест»?
  • 0
    Что значит? Я просто ударил бежать в затмении
Показать ещё 8 комментариев
Теги:
selenium

1 ответ

0

Обновите конфигурацию запуска в Eclipse. Он должен указывать на класс Example.

Ещё вопросы

Сообщество Overcoder
Наверх
Меню