@Test public void lab2b() { System.setProperty("webdriver.gecko.driver","C:\\testautomatisering\\geckodriver.exe"); WebDriver driver = new FirefoxDriver(); driver.get("http://damberg.one/lab/lab2b.html"); driver.findElement(By.id("occasion")).sendKeys("Test automation course"); driver.findElement(By.id("basedate")).clear(); driver.findElement(By.id("basedate")).sendKeys("2020-10-12"); if(!driver.findElement(By.id("42days")).isSelected()) driver.findElement(By.id("42days")).click(); driver.findElement(By.id("generationbtn")).click(); Assert.assertTrue(driver.findElement(By.id("result")).getText().length() > 0); driver.quit(); } @Test public void lab2bMoreBrowsers() { System.setProperty("webdriver.gecko.driver","C:\\testautomatisering\\geckodriver.exe"); WebDriver driver = new FirefoxDriver(); driver.get("http://damberg.one/lab/lab2b.html"); driver.findElement(By.id("occasion")).sendKeys("Test automation course"); JavascriptExecutor jse = (JavascriptExecutor)driver; jse.executeScript("document.getElementById('basedate').setAttribute('value', '2020-10-12')"); By fortyTwoDaysCheckbox = By.id("42days"); if(!driver.findElement(fortyTwoDaysCheckbox).isSelected()){ driver.findElement(fortyTwoDaysCheckbox).click(); } driver.findElement(By.id("generationbtn")).click(); Assert.assertTrue(driver.findElement(By.id("result")).getText().length() > 0); driver.quit(); }
In the following utility, automate any input of your choice for: