This is a sample of Selenium.
I used the next page for testing. Reservation Form
reserve_form.java
// -----------------------------------------------------------------------
/*
reserve_form.java
Sep/21/2018
*/
// -----------------------------------------------------------------------
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.By;
public class reserve_form {
// -----------------------------------------------------------------------
public static void main(String[] args) {
System.err.println ("***start***");
String url = "http://example.selenium.jp/reserveApp/";
WebDriver driver = new FirefoxDriver();
driver.get(url);
driver.findElement(By.id("reserve_month")).clear();
driver.findElement(By.id("reserve_month")).sendKeys("11");
driver.findElement(By.id("reserve_day")).clear();
driver.findElement(By.id("reserve_day")).sendKeys("10");
driver.findElement(By.id("reserve_term")).clear();
driver.findElement(By.id("reserve_term")).sendKeys("3");
driver.findElement(By.id("headcount")).clear();
driver.findElement(By.id("headcount")).sendKeys("2");
String str_select = "input[type='radio'][name='bf'][value='off']";
WebElement item=driver.findElements(By.cssSelector(str_select)).get(0);
item.click();
str_select = "input[type='checkbox'][id='plan_b']";
item=driver.findElements(By.cssSelector(str_select)).get(0);
item.click();
driver.findElement(By.id("guestname")).clear();
driver.findElement(By.id("guestname")).sendKeys("Kogoro Akechi");
driver.findElement(By.id("goto_next")).click();
System.err.println ("***End***");
}
// -----------------------------------------------------------------------
}
// -----------------------------------------------------------------------
Makefile
reserve_form.class: reserve_form.java
javac reserve_form.java -cp ./client-combined-3.14.0.jar
clean:
rm -f reserve_form.class
Execution method
export CLASSPATH=.:./client-combined-3.14.0.jar:./guava-26.0-jre.jar:./okhttp-3.11.0.jar:./okio-2.0.0.jar:./kotlin-stdlib-1.2.60.jar:./commons-exec-1.3.jar
#
java reserve_form
Recommended Posts