# Check Text in a website with a case insensitive focus

**URL:** <https://forum.robotframework.org/t/check-text-in-a-website-with-a-case-insensitive-focus/5971>\
**Category:** Robot Framework\
**Created:** [20 July 2023 10:16 UTC](https://forum.robotframework.org/t/check-text-in-a-website-with-a-case-insensitive-focus/5971 "2023-07-20T10:16:34Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![coopernico46](https://avatars.discourse-cdn.com/v4/letter/c/9dc877/32.png) [@coopernico46](https://forum.robotframework.org/u/coopernico46)\
**Post date:** [20 July 2023 10:16 UTC](https://forum.robotframework.org/t/check-text-in-a-website-with-a-case-insensitive-focus/5971/1 "2023-07-20T10:16:34Z")

</div>

Hi all,

I just wnat to ask you if you know an easy way to verify a website Text with a case insensitive focus.  
I mean, for example check that Praga text it’s into a particular website using a keyword like:  
Page Should Contain Praga  
But keeping in mind that for us it’s is valid algo values like “praga”, “pRaga”, pragA", etc…

I know that i can build an .py file to difine a function like:  
def compare\_strings\_case\_insensitive(string1, string2):  
return string1.lower() == string2.lower()

or write RF code like:  
${text} Get Text # Replace this with the actual keyword to get the text from the page  
Run Keyword If ‘Praga’ in ${text} OR ‘praga’ in ${text}  
… ELSE Fail The page does not contain ‘Praga’ or ‘praga’

But i’m looking for a easier way like a param or action inside some RF buildIn keywords.

Thanks in advance

---

<div class="post-metadata">

**Author:** ![damies13](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/damies13/32/623_2.png) [@damies13](https://forum.robotframework.org/u/damies13)\
**Post date:** [20 July 2023 15:13 UTC](https://forum.robotframework.org/t/check-text-in-a-website-with-a-case-insensitive-focus/5971/2 "2023-07-20T15:13:51Z")

</div>

Hi Pablo,

Well String library has [Convert To Lower Case](https://robotframework.org/robotframework/latest/libraries/String.html#Convert%20To%20Lower%20Case) so you cold use that, but likewise you can use python variable methods on robot framework variables as well, so you can do this which is probably easier:

```python
***Test Cases***
Case Insensitive Example
	${var1}= Set Variable pRaga
	${var2}= Set Variable pragA
	Should Be Equal As Strings ${var1.lower()} ${var2.lower()}

```

 ![image](https://europe1.discourse-cdn.com/flex005/uploads/robotframework1/original/2X/9/93afa39937ed371c9ecb6d532c2914894bca9a0b.png)

Hopefully that helps,

Dave.

---

<div class="post-metadata">

**Author:** ![coopernico46](https://avatars.discourse-cdn.com/v4/letter/c/9dc877/32.png) [@coopernico46](https://forum.robotframework.org/u/coopernico46)\
**Post date:** [21 July 2023 12:43 UTC](https://forum.robotframework.org/t/check-text-in-a-website-with-a-case-insensitive-focus/5971/3 "2023-07-21T12:43:28Z")

</div>

> [@damies13](#):
>
> ```python
> Case Insensitive Example
> ${var1}= Set Variable pRaga
> ${var2}= Set Variable pragA
> Should Be Equal As Strings ${var1.lower()} ${var2.lower()}
> 
> ```

Hi @damies13  
Thanks for your support, this looks fine for me as it’s an easier approach to solve my problem but i was looking for something different and maybe i didn’t explain good enough my question.

Imagine that i have to check that, a particular web site have the string `"user@company.com"` just that simple validation.

Right now i could use:

`Page should contain user@company.com`

But i would like the test **PASS** with a **non case sensitive approach** so if RF found “[user@company.com](mailto:user@company.com)” or " [User@company.com](mailto:User@company.com)" or " [user@Company.com](mailto:user@Company.com)" or " [User@Company.com](mailto:User@Company.com)" **or any other combination**

I was cheching the RF doc to review if keyword or other that check for strings could have params or actions like:

`Page should contain user@company.com caseSensitive=false`

that could be the super easier approach 🙂 but i can’t find something like that.

@damies13 , anyway your approach looks better than others that i tried to implement so thanks a lot

---

<div class="post-metadata">

**Author:** ![damies13](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/damies13/32/623_2.png) [@damies13](https://forum.robotframework.org/u/damies13)\
**Post date:** [21 July 2023 15:00 UTC](https://forum.robotframework.org/t/check-text-in-a-website-with-a-case-insensitive-focus/5971/4 "2023-07-21T15:00:01Z")

</div>

Hi Pablo,

Arguments to a keyword are up to the implementation of the library that the keyword comes from, there is no set of standard arguments that apply to all libraries, some keywords can even have no arguments (again it’s up to the implementation)

I’m guessing the [Page Should Contain](https://robotframework.org/SeleniumLibrary/SeleniumLibrary.html#Page%20Should%20Contain) is this one from SeleniumLibrary? if so It only has 2 arguments shown in it’s documentation, so it appears no there’s no easy way to tell it to ignore case.

Having said that, it might be possible with [Page Should Contain Element](https://robotframework.org/SeleniumLibrary/SeleniumLibrary.html#Page%20Should%20Contain%20Element) and XPATH with some [XPATH string functions](https://www.w3schools.com/xml/xsl_functions.asp#string)

I guess something like this might do what you want:

```python
    Page Should Contain Element //*[contains(translate(text(),'ABCDEFGHIJKLMNOPURSTUWXYZ','abcdefghijklmnopurstuwxyz'), 'user@company.com')]

```

I initially tried to use the xpath `//*[contains(lower-case(text()), 'user@company.com')] ` but it didn’t work (even outside robot framework), I don’t really know why but a quick google put me onto the translate() trick and that xpath worked in the browser dev tools for this page, so hopefully this will work for you.

If you need to use it often you might want to wrap it in a keyword like this:

```python
***Test Cases***
Case Insensitive Example 2
    Page Should Contain Case Insensitive User@Company.com
***Keywords***
Page Should Contain Case Insensitive
    [Arguments] ${searchtext}
    Page Should Contain Element //*[contains(translate(text(),'ABCDEFGHIJKLMNOPURSTUWXYZ','abcdefghijklmnopurstuwxyz'), '${searchtext.lower()}')]

```

Dave.

---

<div class="post-metadata">

**Author:** ![Lennart](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/lennart/32/2587_2.png) [@Lennart](https://forum.robotframework.org/u/Lennart)\
**Post date:** [29 July 2023 11:16 UTC](https://forum.robotframework.org/t/check-text-in-a-website-with-a-case-insensitive-focus/5971/5 "2023-07-29T11:16:51Z")

</div>

`lower-case` is in xpath 2.0 which browsers generally don’t support. For all practical intents and purposes, it seems xpath 1.0 is the last version there will ever be. I tried to make some sense of the reasons; it seems like no one wants to include anything new xml related.

---

<div class="post-metadata">

**Author:** ![coopernico46](https://avatars.discourse-cdn.com/v4/letter/c/9dc877/32.png) [@coopernico46](https://forum.robotframework.org/u/coopernico46)\
**Post date:** [7 August 2023 10:12 UTC](https://forum.robotframework.org/t/check-text-in-a-website-with-a-case-insensitive-focus/5971/6 "2023-08-07T10:12:26Z")

</div>

> [@damies13](#):
>
> ```python
> Page Should Contain Case Insensitive
> [Arguments] ${searchtext}
> Page Should Contain Element //*[contains(translate(text(),'ABCDEFGHIJKLMNOPURSTUWXYZ','abcdefghijklmnopurstuwxyz'), '${searchtext.lower()}')]
> 
> ```

Thanks a lot @damies13  
Implemented and working as expected!!!

Best regards
