Search code examples
testingwebdriverselenium-webdriverfunctional-testingrobotframework

Robot Framework - Case sensitive


I need to know if there is a workaround on this error:

When I use Keywords like:

  • Location Should Be
  • Location Should Contain
  • (Which are both part of the Selenium2Library.)

    I get this error: "Location should have been 'http://www.google.pt' but was 'http://WwW.GooGLe.Pt'

    I think that is because robot framework is natively case sensitive when comparing strings.

    Any help? Ty

    EDIT Question edited to clarify some subjects.


    Solution

  • Luckily Robot Framework allows for keywords to be written in python.

    MyLibrary.py

    def Compare_Ignore_Case(s1, s2):  
        if s1.lower() != s2.lower():
            return False
        else:
            return True
    
    def Convert_to_Lowercase(s1):
        return s1.lower()
    

    MySuite.txt

    | *Setting* | *Value*        |
    | Library   | ./MyLibrary.py |
    
    | *Test Case* | *Action* | *Argument*
    #
    | T100 | [Documentation] | Compare two strings ignoring case.
    |      | Compare Ignore Case | foo | FOO
    #
    | T101 | [Documentation] | Compare two strings where one is a variable.
                      # Should be Get Location in your case.
    |      | ${temp}= | MyKeyword that Returns a String
    |      | Compare Ignore Case | foo | ${temp}
    

    I have not used the Selenium library, but the example in T101 should work for you.