jeudi 27 juillet 2017

How to test if the data entered through registration page of a web application is stored into database or not with Selenium?

I am new to Selenium. I am testing a user registration form in which i have to verify if the data is inserted into database or not. I am using following code to check. Is there any better option than this?

@Test
public void testVerifyListOfRecords() throws InterruptedException {

  String query = "SELECT ID FROM usermaster WHERE RegistrationNumber = '" + REGNO + "' ";
  String ID = DatabaseConnector.executeSQLQuery("QA", query);

  if(ID == ""){
    STATUS = "FALSE";
    System.out.println("REGISTRATION NUMBER IS NOT INSERTED..!! TEST FAILED..!!");
  } else STATUS = "TRUE";

  String sqlQuery = "SELECT FirstName,LastName,SpecialityCode,QualificationCode FROM usermaster WHERE ID = '" + ID + "' ";
  List<String> listOfDBValues = new ArrayList<String>();
  listOfDBValues = DatabaseConnector.executeSQLQuery_List("QA", sqlQuery);
  List<String> Branch = new ArrayList<>();
  Branch.add(listOfDBValues.get(0));

  List<String> list1 = new ArrayList<>(Arrays.asList("testfirstname testlastname ORP DM"));
  Assert.assertEquals(STATUS, "TRUE");
  System.out.println("STATUS IS " + STATUS);
  Assert.assertEquals(Branch, list1);
}

Aucun commentaire:

Enregistrer un commentaire