Selenium WebDriver Java Framework Course Limited Time Offer for $20

Selenium WebDriver Java Framework Course Limited Time Offer for $20

 

Print

Robot Framework Database Testing

Robot Framework Database Library provides many useful keywords to test database. To use robot framework database library, you need to download the file "pymssql-2.1.0.win-amd64-py2.7.exe" if your computer is 64 bit and install it.

 

If your computer is 32 bit, you can download specific version. See the example below. 

Step 1: create a project with RIDE as shown below, import Database Library and create variables. 

Step 2: add a test case as shown below:

Step 3: final test text looks like this below:

 

Here is the text view

 

*** Settings ***
Library           DatabaseLibrary

*** Variables ***
${Port}           1433
${Username}       sa
${DatabaseHost}    192.168.1.8
${Password}       Pass@word
@{QueryResult}
${RowCount}       ${EMPTY}

*** Test Cases ***
Database-Keywords-Test
    Connect to Database    pymssql    AdventureWorks2008    ${Username}    ${Password}    ${DatabaseHost}    ${Port}
    Check If Exists In Database    select * from Production.Product where ListPrice>50
    Check If Not Exists In Database    select * from Production.Product where ListPrice<0.0
    @{QueryResult}    Query    select Name,GroupName from HumanResources.Department
    Log    @{QueryResult[0]},@{QueryResult[1]},@{QueryResult[2]}
    ${RowCount}    Row Count    select * from HumanResources.Department
    Log    ${RowCount}
    Table Must Exist    Department
    Row Count Is Less Than X    select * from Production.Product where ListPrice<0.0    1
    Row Count Is Greater Than X    select * from HumanResources.Department    0
    Disconnect From Database

Run the test and see the result

Click the link for test result.