The Real Life Selenium Scenarios
The Real Life Selenium Scenarios
practice;
import java.time.Duration;
import java.util.List;
import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
@BeforeTest
public void setup()
{
driver.manage().timeouts().pageLoadTimeout(Duration.ofSeconds(15));
driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(20));
@AfterTest
public void teardown()
{
driver.quit();
}
@Test(priority=1)
public void VerifyAddtoProductHigh() throws InterruptedException //To add
product of highest value to the cart & printing its name & description
{
login(); //Calling function login
System.out.println(max_product_name);
System.out.println(max_value_price);
Thread.sleep(3000);
@Test(priority=2)
public void VerifyAddtoProductLow() throws InterruptedException //To add
product of lowest value to the cart & printing its name & description
{
System.out.println(min_product_name);
System.out.println(min_value_price);
driver.findElement(By.xpath("//input[@id='password']")).sendKeys("secret_sauce
");
driver.findElement(By.xpath("//input[@id='login-button']")).click();
}
}