Using where Clause To Get Data From Table Using Selenium WebDriver

Now you are well aware about how to INSTALL MYSQL, CREATING TABLES and ACCESS DATA from MySql data tables for your selenium WebDriver test. You can compare and verify that data or you can use all those data as Input values In some web forms. In previous example, We learnt
how to execute simple select query to get all data from MySql table. You can also use where clause In query to get specific data rows from table.

How to use where clause with query In test
If you are executing query In database manually then you can use where clause very simply with your query. To use where clause In query, You need to use PreparedStatement Interface. PreparedStatement Interface will allow you to use where clause with query In your test. I have prepared example to get value from database using where clause as bellow. It will get and print result In console where name = "smith" and age = 25.

Download MySqlReadDatawithwhere.zip folder. There will be MySqlReadData.java test script file In zip folder. Extract zip folder and Import It In your eclipse and then execute.

When you execute above test In eclipse, It will return result as bellow In console.

This way you can use where clause with query to get specific result. Next post will show you how to update record In MySQL table to test data In selenium.

1 comment:

  1. Hi, The test script is excellent to understand the setting. Thanks, Ted

    ReplyDelete