計算を行い、その結果をSelenium Web Driverを使用してフィールドに入力しようとしています。私たちは、使用する必要がdouble値を入力するときにseleniumのsendkeyの代わりに使用するもの
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class ProjectOne {
public static void main(String[] args) {
// TODO Auto-generated method stub
WebDriver driver = new FirefoxDriver();
driver.get("http://www.techno-geek.co.uk/SeleniumPractice/webform1.html");
driver.manage().window().maximize();
driver.findElement(By.xpath(".//*[@id='continue']")).click();
driver.findElement(By.xpath("//input[@id='COB']")).sendKeys("Toronto");
driver.findElement(By.xpath(".//*[@id='DOB']")).sendKeys("19th January 1986");
driver.findElement(By.xpath("//input[@id='color']")).sendKeys("Cream");
driver.findElement(By.xpath("//input[@id='food']")).sendKeys("Pizza");
double a = 14.867;
double b = 67.902;
double c = 22567.325;
double d = 76.908;
double r1 = a * b;
double r2 = c/d;
driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
driver.findElement(By.id("multiply")).sendKeys(r1);//1009.49903
driver.manage().timeouts().implicitlyWait(40, TimeUnit.SECONDS);
driver.findElement(By.id("divide")).sendKeys(r2);//293.432738
}
}