Hi I new to robotframework
I building website with some functions and a step towards that, I has created “project info” page, I want to automate this, to make sure the content is always correct
How can I use robotframework to compare this text towards a text file?
My html code:
Project information
Create a website with HTML and python (Django 5)
Build a house functions house each room should have its own door
Content is rooms should be based on 100 days of python code with Angela Yu
Each player should be indentfied by First name, Sure name and age
As precondition name should be spelled correct
First name -> Starts with caplizate first letter in name
Second name -> Starts with caplizate first letter in name
Age -> Should only be int numbers
Its should be 4 four rooms on every floor level
Each room should number 1 to 4
Some rooms can have secret room behind
When player enters room the door is locked and when task is completed player will at same place before entering room
when played has completed room task its be counted with points to leader board
Each floor should be connected with a elevator
Building should have locked door and player needs put some details to access building
When player enters building a user name and password should be created also
and here my robotframe code so far:
Library SeleniumLibrary #Library StartApplications.py # Used for start flask server but verify is not implemted yet
Test Setup Start Browser and Maximize ${URL} ${Browser}
Test Teardown Close Browser Window
Suite Setup Setup Suite
Suite Teardown Teardown Suite
*** Variables ***
${Browser} firefox
${URL} http://127.0.0.1:8000/
${information_title} Project information
${first_description_title} Create a website with HTML and python (Django 5)
*** Test Cases ***
Verify if details is visible on welcome screen
[Documentation] Verify if details is visible on welcome screen.
# [Tags] Stat_dev
Maximize Browser Window
Click Element //[@id=“project__title”]
Sleep 2 seconds
${information} = SeleniumLibrary.Get text //[@id=“information__title”]
Should Be Equal ${information_title} ${information}
${description}= SeleniumLibrary.Get text //*[@id=“first_description__title”]
Should Be Equal ${description} ${description}
*** Keywords ***
Setup Suite Open Browser ${URL}
Teardown Suite Close Browser
There are a lot of solution for this.
Personnaly I use pandas library that manages .csv files.
You can simply read/load the file at the beginning of the test, then loop on each row, calling the column by their titles.
*** Settings ***
Library SeleniumLibrary
Library pandas
*** Variables ***
${INPUT_CSV} ./Data/datafile.csv
*** Test Cases ***
Read File
${data} Read Csv ${INPUT_CSV} encoding=UTF-8
${num_rows} Get Length ${data}
FOR ${i} IN RANGE 0 ${num_rows}
Log ${data['name'][${i}]}
END
Remember index start to 0
Column names/keys are case sensitive, so here my colum is named “name”, if you use “Name” it won’t work.
You can also search the forum, there are some excel or other alternatives can could suit.
And btw if you only use Seleniumlibrary, you can use only Get Text keyword, it will ease the read of test cases.