import org.openqa.selenium.WebElement; //导入方法依赖的package包/类
@Test
public void cadastro() throws InterruptedException {
WebDriverWait wait = new WebDriverWait(driver, 30);
wait.until(ExpectedConditions.presenceOfElementLocated(By.id("Name")));
WebElement name = driver.findElement(By.id("Name"));
name.sendKeys("Vitor Cardoso");
wait.until(ExpectedConditions.presenceOfElementLocated(By.id("Email")));
WebElement email = driver.findElement(By.id("Email"));
email.sendKeys(("[email protected]"));
wait.until(ExpectedConditions.presenceOfElementLocated(By.id("Site")));
WebElement site = driver.findElement(By.id("Site"));
site.sendKeys("www.doqconsulting.com.br");
wait.until(ExpectedConditions.presenceOfElementLocated(By.id("Subject")));
WebElement assunto = driver.findElement(By.id("Subject"));
assunto.sendKeys("Teste Selenium com assert");
wait.until(ExpectedConditions.presenceOfElementLocated(By.id("Message")));
WebElement message = driver.findElement(By.id("Message"));
message.sendKeys
("Gostaria de saber mais sobre a DOQ Consulting e como podemos ajudá-lo? Envie sua mensagem pelo site ou em nossas redes sociais.");
// SUBMIT AND ASSERT
name.submit();
String respname = name.getAttribute("value");
Assert.assertEquals(respname,"Vitor Cardoso");
email.submit();
String resp = email.getAttribute("value");
Assert.assertEquals(resp,"[email protected]");
site.submit();
String respsite = site.getAttribute("value");
Assert.assertEquals(respsite,"www.doqconsulting.com.br");
assunto.submit();
String respassunto = assunto.getAttribute("value");
Assert.assertEquals(respassunto,"Teste Selenium com assert");
message.submit();
String respmsg = message.getAttribute("value");
Assert.assertEquals(respmsg,
"Gostaria de saber mais sobre a DOQ Consulting e como podemos ajudá-lo? Envie sua mensagem pelo site ou em nossas redes sociais.");
wait.until(ExpectedConditions.presenceOfElementLocated(By.cssSelector("button[class='btn btn-send']")));
WebElement sendclick = driver.findElement(By.cssSelector("button[class='btn btn-send']"));
sendclick.click(); /*Código comentado devido ao erro do webdriver com o firefox*/
// wait.until(ExpectedConditions.presenceOfElementLocated(By.className("col-sm-7 col-sm-offset-1")));
// WebElement validatemsg = driver.findElement(By.className("col-sm-7 col-sm-offset-1"));
// String test = validatemsg.getText();
// Assert.assertEquals(test," *Sua mensagem foi enviada com sucesso, logo mais um de nosso consultores irão avaliar o seu caso e entrar em contato. ");
}