Selenium Robot Framework Table Verification

In this example, you will learn how to use Selenium2Library to verify tables in web application testing.


Selenium2Library has keywords: Get Table Cell, Table Cell Should Contain, Table Column Should Contain, Table Footer Should Contain, Table Header Should Contain and etc. In this table below, we verify that the first cell (row id=1 , column id=1) contains text "Test Case ID".

Robot Framework Table Test

Test Case ID Application Module Test Result Tester
TestCase001 Sign Up Pass TesterA
TestCase002 Login Fail TesterB
TestCase003 Logout Did not run TesterC

Step 1: launch RIDE console, add a resource file named "resource.txt". In this resource file, import Selenium2Library and OperatingSystem library. Add a variable ${Browser}=Firefox.  This resource file will be used in the test.

When view the resource.text in the "Text Edit" view, it looks like this.

Step 2: add a new Suite named "TableKeywords". In this suite, import the resource.txt file as Resource and add a test case named "TableTest".

Test Case Keywords view looks like this

*** Settings ***
Resource          ../resource.txt

*** Test Cases ***
    Open Browser    ${Browser}
    sleep    5s
    Page Should Contain Element    id=table_container
    Table Cell Should Contain    xpath=//div[@id='table_container']/table    1    1    Test Case ID
    Close Browser

Step 4: run the test as pybot and see the result. Test passed. see the result file at this location below.