Я просто пытаюсь заставить базовый Selenium2Example работать с Firefox 4, используя Maven для получения jar Selenium:
public class Selenium2Example {
public static void main(String[] args) {
// Create a new instance of the Firefox driver
// Notice that the remainder of the code relies on the interface,
// not the implementation.
WebDriver driver = new FirefoxDriver();
// 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());
//Close the browser
driver.quit();
}
}
Если я пойду туда: http://code.google.com/p/selenium/wiki/UsingWebDriver,, это говорит о том, что я должен попробовать такую зависимость:
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium</artifactId>
<version>2.0b3</version>
</dependency>
, но самые последние jar-файлы можно найти ни в одном репозитории, последняя версия, которая работает (со всеми найденными зависимостями), - это "2.0a4" (в 2.0a5 до 2.0a7 и 2.0b1 до 2.0b3 отсутствуют основные jar или отсутствуют зависимости) и эта версия "2.04" не имеет правильных классов для работы примера.
Если я пойду туда: http://seleniumhq.org/docs/03_webdriver.html#chapter03-reference,, это говорит, что я должен использовать эту зависимость:
<dependency>
<groupId>org.seleniumhq.webdriver</groupId>
<artifactId>webdriver-firefox</artifactId>
<version>0.9.7376</version>
</dependency>
Пример компилируется, но этот выпуск не обновлялся с октября 2009 года и не работает с Firefox 4 (см. http://repo1.maven.org/maven2/org/seleniumhq/webdriver/webdriver-firefox/)
Если я пойду туда http://seleniumhq.org/download/maven.html,, там написано, что я должен попробовать что-то вроде:
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-firefox-driver</artifactId>
<version>...</version>
</dependency>
Но версия 2.0b3 тоже не работает (отсутствуют зависимости). Вот сообщение об ошибке:
23/05/11 22:09:07 CEST: Build errors for first-webdriver-test; org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal on project first-webdriver-test: Unable to get dependency information for org.apache.httpcomponents:httpcore:jar:4.0.1: Failed to process POM for org.apache.httpcomponents:httpcore:jar:4.0.1: Non-resolvable parent POM org.apache.httpcomponents:httpcomponents-core:4.0.1 for org.apache.httpcomponents:httpcore:4.0.1: Failed to resolve POM for org.apache.httpcomponents:httpcomponents-core:4.0.1 due to Missing:
----------
1) org.apache.httpcomponents:httpcomponents-core:pom:4.0.1
----------
1 required artifact is missing.
for artifact:
org.apache.httpcomponents:httpcomponents-core:pom:4.0.1
from the specified remote repositories:
central (http://repo1.maven.org/maven2, releases=true, snapshots=false)
Я не знаю значения этой ошибки, так как я могу найти запрошенный pom здесь: http://repo1.maven.org/maven2/org/apache/httpcomponents/httpcomponents-core/4.0.1/httpcomponents-core-4.0.1.pom
Таким образом, единственный способ, которым я могу пока привести пример, - это вручную загрузить банки 2.0b3.
Кто-нибудь может заставить его работать с Maven?