2014-12-22 4 views
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

Где вы называете 'Test'? –

+0

Что значит? Я просто нажал run in eclipse – SpockRock

+0

Я подозреваю, что ваша проблема не имеет ничего общего с Selenium, но с Java и Eclipse. Google Java + Eclipse + учебник! – SiKing

ответ

0

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