package com.example.tests;
import com.thoughtworks.selenium.*;
import java.util.regex.Pattern;
public class Untitled extends SeleneseTestCase {
public void setUp() throws Exception {
setUp("http://change-this-to-the-site-you-are-testing/", "*chrome");
}
public void testUntitled() throws Exception {
selenium.open("/home/index.nhn");
selenium.type("query", "리쌍");
selenium.click("//input[@type='image']");
selenium.waitForPageToLoad("30000");
verifyTrue(selenium.isTextPresent("개리"));
}
}
import com.thoughtworks.selenium.SeleneseTestCase;
public class SimpleRCTest extends SeleneseTestCase {
public void setUp() throws Exception {
setUp("http://dev.music.naver.com/", "*firefox");
}
public void testSearch() throws Exception {
selenium.open("/home/index.nhn");
selenium.type("query", "리쌍");
selenium.click("//input[@type='image']");
selenium.waitForPageToLoad("30000");
verifyTrue(selenium.isTextPresent("개리"));
}
}
-- repository 설정
<repositories>
<repository>
<id>selenium-repository</id>
<url>http://selenium.googlecode.com/svn/repository/</url>
</repository>
</repositories>
-- dependency 설정
-- 아래서 WebDriver 간단설명 예정으로 WebDriver 포함 버전으로 설정했음.
<dependencies>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium</artifactId>
<version>2.0a4</version>
<scope>provided</scope>
</dependency>
</dependencies>
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());
}
}