@Test public void lab1(){ System.setProperty("webdriver.gecko.driver","C:\\testautomatisering\\geckodriver.exe"); WebDriver driver = new FirefoxDriver(); driver.get("http://damberg.one/lab/lab2a.html"); driver.findElement(By.id("cname")).clear(); driver.findElement(By.id("cname")).sendKeys("Zington"); driver.findElement(By.id("btn")).click(); Assert.assertTrue(driver.switchTo().alert().getText().contains("Yippie")); driver.switchTo().alert().dismiss(); driver.quit(); }
The goal of this exercise is to be able to clear a field prior to entering text in it.
Create an automated test that make sure the name field value equals the string 'Zington'. To achieve this you need to create a script that either clear the field and send keys to it, or setting the value of it.