Selenium Sample Reservation Form (Java)

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

Selenium Sample Reservation Form (Java)
Selenium sample (Java)
[Java] Generics sample
Java GUI sample
Java sample code 04
Selenium x Java
Java sample code 01
[Java] Holiday judgment sample
[Java] logback slf4j sample
Digital signature sample code (JAVA)
Java parallelization code sample collection
Java standard log output sample
[For beginners] Run Selenium in Java
Java 9 new features and sample code
Use Chrome Headless from Selenium / Java
A simple sample callback in Java
BloomFilter description and implementation sample (JAVA)
[Java] Date period duplication check sample
EXCEL file update sample with JAVA
Sample vending machine made in Java
Sample code using Minio from Java
Java adds form fields to PDF