You are on page 1of 8

Selenium with DB(ORACLE 10g ) Testing

The documentation covered the validating part of DB tables data.

I have just completed the basic scenarios for DB testing (CRUD-Create Read Update Delete)
Operation

1) Create and Read


(i)The below snap shot contain 2 fields.
EMP ID:
EMP name:

(ii) Give the valid data then click Create

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.

DB Testing selenium Code(ORACLE 10g)


selenium.open("http://127.0.0.1:8080/apex/f?
p=4550:11:2113917715938198::NO:::");
assertEquals("Application Express Login", selenium.getTitle());
selenium.type("id=P11_USERNAME", "system");
selenium.type("id=P11_PASSWORD", "admin");
selenium.click("id=LOGIN");
selenium.waitForPageToLoad("200000");
assertEquals("Oracle", selenium.getTitle());
selenium.click("css=img[alt=\"SQL\"]");
selenium.waitForPageToLoad("200000");
assertEquals("SQL", selenium.getTitle());
selenium.click("css=img[alt=\"SQL Commands\"]");
selenium.waitForPageToLoad("200000");
assertEquals("SQL Commands", selenium.getTitle());
selenium.type("id=P1003_SQL_COMMAND1", "select * from izone");
selenium.click("//input[@value='Run']");

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:

(ii) Give the valid data then click Update


Selenium Code:

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.

DB Testing selenium Code(ORACLE 10g)


selenium.open("http://127.0.0.1:8080/apex/f?
p=4550:11:2113917715938198::NO:::");
assertEquals("Application Express Login", selenium.getTitle());
selenium.type("id=P11_USERNAME", "system");
selenium.type("id=P11_PASSWORD", "admin");
selenium.click("id=LOGIN");
selenium.waitForPageToLoad("200000");
assertEquals("Oracle", selenium.getTitle());
selenium.click("css=img[alt=\"SQL\"]");
selenium.waitForPageToLoad("200000");
assertEquals("SQL", selenium.getTitle());
selenium.click("css=img[alt=\"SQL Commands\"]");
selenium.waitForPageToLoad("200000");
assertEquals("SQL Commands", selenium.getTitle());
selenium.type("id=P1003_SQL_COMMAND1", "select * from izone");
selenium.click("//input[@value='Run']");

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.

DB Testing selenium Code(ORACLE 10g)


selenium.open("http://127.0.0.1:8080/apex/f?
p=4550:11:2113917715938198::NO:::");
assertEquals("Application Express Login", selenium.getTitle());
selenium.type("id=P11_USERNAME", "system");
selenium.type("id=P11_PASSWORD", "admin");
selenium.click("id=LOGIN");
selenium.waitForPageToLoad("200000");
assertEquals("Oracle", selenium.getTitle());
selenium.click("css=img[alt=\"SQL\"]");
selenium.waitForPageToLoad("200000");
assertEquals("SQL", selenium.getTitle());
selenium.click("css=img[alt=\"SQL Commands\"]");
selenium.waitForPageToLoad("200000");
assertEquals("SQL Commands", selenium.getTitle());
selenium.type("id=P1003_SQL_COMMAND1", "select * from izone");
selenium.click("//input[@value='Run']");

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());

You might also like