Professional Documents
Culture Documents
I have just completed the basic scenarios for DB testing (CRUD-Create Read Update Delete)
Operation
Selenium Code:
Selenium.type(“id=EMPID”,”321622”);
Selenium.type(“id=EMPNAME”,”senthilkumar”);
Selenium.click(“id=create”);
(iii) Below selenium code validate whether the added employee information available in the
corresponding table or not.
int xpath_ID=
selenium.getXpathCount("//table[@class='htmldbMinReport']/tbody/tr/td[1]").intVa
lue();
int xpath_NAME=
selenium.getXpathCount("//table[@class='htmldbMinReport']/tbody/tr/td[1]").intVa
lue();
System.out.println("COUNT: "+xpath_ID);
xpath_name++;
for(int i=2;i<=xpath_ID;i++)
{
String
EMP_ID=selenium.getText("//table[@class='htmldbMinReport']/tbody/tr["+i+"]/td[1
]");
String
EMP_NAME=selenium.getText("//table[@class='htmldbMinReport']/tbody/tr["+i+"]/
td[2]");
System.out.println(“ID:”+EMP_ID+”NAME:”+EMP_NAME+”);
if(EMP_ID.equals("321622") &&EMP_NAME.equals("senthilkumar")))
{
System.out.println("SUCCESS");
}
}
selenium.click("link=Logout");
selenium.waitForPageToLoad("200000");
assertEquals("Logout Confirmation", selenium.getTitle());
2) Update
(i)The below snap shot contain 2 fields.
EMP ID:
EMP name:
selenium.type(“id=EMPID”,”421422”);
selenium.type(“id=EMPNAME”,”senthilkumar”);
selenium.click(“id=Update”);
(iii) Below selenium code validate whether the updated employee ID is available in the corresponding
table or not.
int xpath_ID=
selenium.getXpathCount("//table[@class='htmldbMinReport']/tbody/tr/td[1]").intVa
lue();
int xpath_NAME=
selenium.getXpathCount("//table[@class='htmldbMinReport']/tbody/tr/td[1]").intVa
lue();
System.out.println("COUNT: "+xpath_ID);
xpath_name++;
for(int i=2;i<=xpath_ID;i++)
{
String
EMP_ID=selenium.getText("//table[@class='htmldbMinReport']/tbody/tr["+i+"]/td[1
]");
String
EMP_NAME=selenium.getText("//table[@class='htmldbMinReport']/tbody/tr["+i+"]/
td[2]");
System.out.println(“ID:”+EMP_ID+”NAME:”+EMP_NAME+”);
if(EMP_ID.equals("421422") &&EMP_NAME.equals("senthilkumar")))
{
System.out.println("SUCCESS");
}
}
selenium.click("link=Logout");
selenium.waitForPageToLoad("200000");
assertEquals("Logout Confirmation", selenium.getTitle());
3) Delete
(i)The below snap shot contain 2 fields.
EMP ID:
EMP name:
(ii) click Delete
Selenium Code:
Selenium.click(“id=Delete”);
(iii) Below selenium code validate whether the deleted employee information available in the
corresponding table or not.
int xpath_ID=
selenium.getXpathCount("//table[@class='htmldbMinReport']/tbody/tr/td[1]").intVa
lue();
int xpath_NAME=
selenium.getXpathCount("//table[@class='htmldbMinReport']/tbody/tr/td[1]").intVa
lue();
System.out.println("COUNT: "+xpath_ID);
xpath_name++;
for(int i=2;i<=xpath_ID;i++)
{
String
EMP_ID=selenium.getText("//table[@class='htmldbMinReport']/tbody/tr["+i+"]/td[1
]");
String
EMP_NAME=selenium.getText("//table[@class='htmldbMinReport']/tbody/tr["+i+"]/
td[2]");
System.out.println(“ID:”+EMP_ID+”NAME:”+EMP_NAME+”);
if(EMP_ID!=”421422” )
{
System.out.println("SUCCESS");
}
}
selenium.click("link=Logout");
selenium.waitForPageToLoad("200000");
assertEquals("Logout Confirmation", selenium.getTitle());