Ceci est un échantillon de sélénium.
J'ai utilisé la page suivante pour tester. Formulaire de réservation
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 ("***début***");
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 ("***Fin***");
}
// -----------------------------------------------------------------------
}
// -----------------------------------------------------------------------
Makefile
reserve_form.class: reserve_form.java
javac reserve_form.java -cp ./client-combined-3.14.0.jar
clean:
rm -f reserve_form.class
Méthode d'exécution
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