package selenium;
import java.time.Duration;
import java.util.List;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.testng.annotations.Test;
public class NewTestNG {
@Test(priority = 0)
public void RegisterwithNoData() {
System.setProperty("webdriver.chrome.driver","C:\\Selenium\\chromedriver\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.manage().window().maximize();
driver.get("http://www.kurs-selenium.pl/demo/register");
driver.findElement(By.cssSelector("input[name=firstname]"));
driver.findElement(By.cssSelector("input[name=lastname]"));
driver.findElement(By.cssSelector("input[name=phone]"));
driver.findElement(By.cssSelector("input[name=email]"));
driver.findElement(By.cssSelector("input[name=password]"));
driver.findElement(By.cssSelector("input[name=confirmpassword]"));
driver.findElement(By.cssSelector(".signupbtn")).click();
WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(3));
wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("div.alert-danger p")));
List<String> alertTextList = driver.findElements(By.cssSelector("div.alert-danger p"))
.stream()
.map(WebElement::getText)
.toList();
System.out.println("Application Status :" + alertTextList);
}
import java.time.Duration;
import java.util.List;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.testng.annotations.Test;
public class NewTestNG {
@Test(priority = 0)
public void RegisterwithNoData() {
System.setProperty("webdriver.chrome.driver","C:\\Selenium\\chromedriver\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.manage().window().maximize();
driver.get("http://www.kurs-selenium.pl/demo/register");
driver.findElement(By.cssSelector("input[name=firstname]"));
driver.findElement(By.cssSelector("input[name=lastname]"));
driver.findElement(By.cssSelector("input[name=phone]"));
driver.findElement(By.cssSelector("input[name=email]"));
driver.findElement(By.cssSelector("input[name=password]"));
driver.findElement(By.cssSelector("input[name=confirmpassword]"));
driver.findElement(By.cssSelector(".signupbtn")).click();
WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(3));
wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("div.alert-danger p")));
List<String> alertTextList = driver.findElements(By.cssSelector("div.alert-danger p"))
.stream()
.map(WebElement::getText)
.toList();
System.out.println("Application Status :" + alertTextList);
}
@Test(enabled = false)
public void RegisterwithInvalidEmail() {
System.setProperty("webdriver.chrome.driver","C:\\Selenium\\chromedriver\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.manage().window().maximize();
driver.get("http://www.kurs-selenium.pl/demo/register");
driver.findElement(By.cssSelector("input[name=firstname]")).sendKeys("suriya");
driver.findElement(By.cssSelector("input[name=lastname]")).sendKeys("parithy");
driver.findElement(By.cssSelector("input[name=phone]")).sendKeys("8123456789");
driver.findElement(By.cssSelector("input[name=email]")).sendKeys("suriya@gmail");
driver.findElement(By.cssSelector("input[name=password]")).sendKeys("12345678");
driver.findElement(By.cssSelector("input[name=confirmpassword]")).sendKeys("12345678");
driver.findElement(By.cssSelector(".signupbtn")).click();
WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(3));
wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("div.alert-danger p")));
List<String> alertTextList = driver.findElements(By.cssSelector("div.alert-danger p"))
.stream()
.map(WebElement::getText)
.toList();
System.out.println("Application Status :" + alertTextList);
}
}
No comments:
Post a Comment