Commits

Alan Franzoni  committed 30e32dc

Initial checkin.

  • Participants

Comments (0)

Files changed (5)

+target
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <groupId>eu.franzoni</groupId>
+    <artifactId>seleniumautolaunch</artifactId>
+    <packaging>jar</packaging>
+    <version>1.0-SNAPSHOT</version>
+    <name>seleniumautolaunch</name>
+    <url>http://maven.apache.org</url>
+    <dependencies>
+        <dependency>
+            <groupId>org.seleniumhq.selenium</groupId>
+            <artifactId>selenium-support</artifactId>
+            <version>2.0b3</version>
+        </dependency>
+        <dependency>
+            <groupId>org.seleniumhq.webdriver</groupId>
+            <artifactId>webdriver-selenium</artifactId>
+            <version>0.9.7376</version>
+        </dependency>
+        <dependency>
+            <groupId>org.seleniumhq.selenium</groupId>
+            <artifactId>selenium-htmlunit-driver</artifactId>
+            <version>2.0b3</version>
+        </dependency>
+        <dependency>
+            <groupId>log4j</groupId>
+            <artifactId>log4j</artifactId>
+            <version>1.2.12</version>
+        </dependency>
+    </dependencies>
+    <properties>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    </properties>
+</project>

File src/main/java/eu/franzoni/seleniumautolaunch/GoogleLucky.java

+package eu.franzoni.seleniumautolaunch;
+
+import com.gargoylesoftware.htmlunit.BrowserVersion;
+import com.thoughtworks.selenium.Selenium;
+
+import org.openqa.selenium.htmlunit.HtmlUnitDriver;
+import org.openqa.selenium.WebDriverBackedSelenium;
+
+public class GoogleLucky {
+
+    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.
+        HtmlUnitDriver driver = new HtmlUnitDriver(BrowserVersion.FIREFOX_3_6);
+        driver.setJavascriptEnabled(true);
+        
+        String baseUrl = "http://www.google.com/webhp?complete=0&hl=en";
+        Selenium selenium = new WebDriverBackedSelenium(driver, baseUrl);
+        selenium.start();
+
+        selenium.open("/");
+        selenium.type("lst-ib", "I'm feeling lucky");
+        
+        selenium.click("btnI");
+        selenium.waitForPageToLoad("2000");
+        System.out.println("page title is " + driver.getTitle());
+        
+        selenium.stop();
+    }
+}

File src/main/resources/commons-logging.properties

+org.apache.commons.logging.Log=org.apache.commons.logging.impl.Log4JLogger

File src/main/resources/log4j.xml

+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
+
+    <appender name="out" class="org.apache.log4j.ConsoleAppender">
+        <layout class="org.apache.log4j.PatternLayout">
+            <param name="ConversionPattern" value="%d{yyyy-MM-dd, HH:mm:ss} %p - %m%n" />
+        </layout>
+    </appender>
+
+    <root>
+        <priority value="error" />
+        <appender-ref ref="out" />
+    </root>
+</log4j:configuration>