PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Friday, October 28, 2022

[FIXED] How to search for empty string/compare two strings in Robot Framework

 October 28, 2022     compare, if-statement, is-empty, robotframework, string     No comments   

Issue

I have read this question

How to test for blank text field when using robotframework-selenium?

as well as the two links to the Robot Framework documentation in the answers but I still don't get how to check if a variable is empty.

I want to do this

if var A equals var B then
   do something
else
   do something else

where A is a string that can both contain something as well as be empty and where B is empty or null.


Solution

can be achieve using many different ways some are as follows, use whichever fits for you

  1. this way you can check two variables equals OR not

    Run Keyword If    '${A}'=='${B}'   do something    ELSE    do something
    
  2. this way you can check if both of your variable are None or not in one go

    Run Keyword If    '${A}'=='None' And '${B}'=='None'    do something
    
  3. using following also you can get if your variables are equal of not if both values are equal it will return true

    Should Be Equal    ${A}    ${B}
    
  4. if both values are NOT equal it will return true.

    Should Not Be Equal   ${A}    ${B}
    

for more information go through this docs

there is also ${EMPTY} variable in robot framework which you can use to check if variable is empty or not



Answered By - Dev
Answer Checked By - Mildred Charles (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing