0% found this document useful (0 votes)
14 views2 pages

Assignment 11 STQA 11

Uploaded by

sujata
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views2 pages

Assignment 11 STQA 11

Uploaded by

sujata
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

SIES College of Management Studies SYMCA (Revised), Sem III,

Roll No: 11

Assignment - 11

Implement Data provider Annotation on a testing website for username and password.
Code:
DemoDataProvider.java

import org.testng.annotations.Test;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.annotations.DataProvider;
public class DemoDataProvider1 {
@Test(dataProvider = "dp")
public void f(String un, String ps) {
System.setProperty("webdriver.chrome.driver", "S:\\SEM 3\\STQA\\102\\
chromedriver.exe");
WebDriver wd = new ChromeDriver();
wd.get("http://www.saucedemo.com");
wd.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
wd.findElement(By.id("user-name")).sendKeys(un);
wd.findElement(By.id("password")).sendKeys(ps);
wd.findElement(By.className("btn_action")).click();
try {
wd.findElement(By.xpath("//*[@id=\"react-burger-menu-
btn\"]")).click();

wd.findElement(By.xpath("/html/body/div/div/div/div[1]/div[1]/div[1]/div/div[2]/
div[1]/nav/a[3]")).click();
System.out.println("Login Success");
}catch(Exception e) {
System.out.println("Login Fail");
}
}

@DataProvider
public Object[][] dp() {
return new Object[][] {
new Object[] { "standard_user", "secret_sauce" },
new Object[] { "problem_user", "secret_sauce" },
new Object[] { "locked_out_user", "secret_sauce" }

Subject: MCAL35 Software Testing & Quality Assurance Lab


Academic Year First Half 2023_24
SIES College of Management Studies SYMCA (Revised), Sem III,
Roll No: 11

};
}
}
Output:

Subject: MCAL35 Software Testing & Quality Assurance Lab


Academic Year First Half 2023_24

You might also like