# ELSE IF with RF 4.x : different way of use?

**URL:** <https://forum.robotframework.org/t/else-if-with-rf-4-x-different-way-of-use/3341>\
**Category:** Robot Framework\
**Created:** [24 February 2022 08:52 UTC](https://forum.robotframework.org/t/else-if-with-rf-4-x-different-way-of-use/3341 "2022-02-24T08:52:07Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Centaure13](https://avatars.discourse-cdn.com/v4/letter/c/58956e/32.png) [@Centaure13](https://forum.robotframework.org/u/Centaure13)\
**Post date:** [24 February 2022 08:52 UTC](https://forum.robotframework.org/t/else-if-with-rf-4-x-different-way-of-use/3341/1 "2022-02-24T08:52:07Z")

</div>

Hello,

I have installed RF 4.1.3 and suddenly, my code with “ELSE IF” keyword are underlined, as if it was an error. But my test works. I suppose that with the update of RF (RF 3 to RF 4), the way of using this keyword are different but I don’t know (don’t understand also) why. I think that an argument is missing but I haven’t it. Could you help me ?

My configuration :

- RF 4.13
- Python 3.9.7
- VS Code as IDE

My code :

```
he choose a type of real estate
[Arguments] ${typeBien}
Click Element ${rechercheAnnonceSelectBien}
    Run Keyword If '${typeBien}'=='Appartement' selection of APP type
     ... ELSE IF '${typeBien}'=='Maison' selection of MAI type
     ... ELSE IF '${typeBien}'=='Garage' selection of GAR type
     ... ELSE IF '${typeBien}'=='Fonds de commerce' selection of FONDS COMM type
     ... ELSE IF '${typeBien}'=='Bien agricole' selection of AGR type
     ... ELSE IF '${typeBien}'=='Immeuble' selection of IMM type
     ... ELSE IF '${typeBien}'=='Bien viticole' selection of VIG type
     ... ELSE IF '${typeBien}'=='Local activités' selection of LAC type
     ... ELSE IF '${typeBien}'=='Local divers' selection of DIV type

```

Thanks a lot !

---

<div class="post-metadata">

**Author:** ![zastress](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/zastress/32/1259_2.png) [@zastress](https://forum.robotframework.org/u/zastress)\
**Post date:** [24 February 2022 09:00 UTC](https://forum.robotframework.org/t/else-if-with-rf-4-x-different-way-of-use/3341/2 "2022-02-24T09:00:48Z")

</div>

If the syntax is underlined but the test works it means that this is a matter of the plugin you are using to recognize de RF code and not with RF itself

---

<div class="post-metadata">

**Author:** ![ealap](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/ealap/32/1053_2.png) [@ealap](https://forum.robotframework.org/u/ealap)\
**Post date:** [24 February 2022 09:07 UTC](https://forum.robotframework.org/t/else-if-with-rf-4-x-different-way-of-use/3341/3 "2022-02-24T09:07:24Z")

</div>

You can view which VSCode plugin is reporting this error by hovering over the underlined keyword or clicking the problems button on the status bar of the editor.

---

<div class="post-metadata">

**Author:** ![Centaure13](https://avatars.discourse-cdn.com/v4/letter/c/58956e/32.png) [@Centaure13](https://forum.robotframework.org/u/Centaure13)\
**Post date:** [24 February 2022 09:08 UTC](https://forum.robotframework.org/t/else-if-with-rf-4-x-different-way-of-use/3341/4 "2022-02-24T09:08:02Z")

</div>

Hello,

The extensions I used on VS Code are :

- Robocorp Code
- Robot Framework Language Server

It’s surprising because I haven’t the problem when I was on the office’s organisation.  
Today, I’m working at home and I have this error…

---

<div class="post-metadata">

**Author:** ![Centaure13](https://avatars.discourse-cdn.com/v4/letter/c/58956e/32.png) [@Centaure13](https://forum.robotframework.org/u/Centaure13)\
**Post date:** [24 February 2022 09:10 UTC](https://forum.robotframework.org/t/else-if-with-rf-4-x-different-way-of-use/3341/5 "2022-02-24T09:10:29Z")

</div>

I have only this kind of error for example :

`Unexpected argument: '${typeBien}'=='Maison'`

---

<div class="post-metadata">

**Author:** ![ealap](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/ealap/32/1053_2.png) [@ealap](https://forum.robotframework.org/u/ealap)\
**Post date:** [24 February 2022 09:16 UTC](https://forum.robotframework.org/t/else-if-with-rf-4-x-different-way-of-use/3341/6 "2022-02-24T09:16:17Z")

</div>

Looks similar to this issue

> <https://github.com/robocorp/robotframework-lsp/issues/495>
>
> i.e.: With something as:
> 
> \`\`\`
> \*\*\* Keywords \*\*\*
> Some Keyword
> Run Keyword… IF ${Cond1} Keyword 1 ELSE IF ${Cond2} Keyword 2 ELSE Keyword 3
> \`\`\`
> The \*\*Keyword 2\*\* and \*\*Keyword 3\*\* should be properly recognized as keywords -- for code-completion, code-analysis, find definition, etc.

---

<div class="post-metadata">

**Author:** ![Centaure13](https://avatars.discourse-cdn.com/v4/letter/c/58956e/32.png) [@Centaure13](https://forum.robotframework.org/u/Centaure13)\
**Post date:** [24 February 2022 09:40 UTC](https://forum.robotframework.org/t/else-if-with-rf-4-x-different-way-of-use/3341/7 "2022-02-24T09:40:38Z")

</div>

Hello,

I finally found the solution.  
In the RF docs, it’s written " **NOTE:** Robot Framework 4.0 introduced built-in IF/ELSE support and using that is generally recommended over using this keyword."

So I have re-write my keyword as :

```
IF '${typeBien}'=='Appartement'
   selection of APP type
    ELSE IF
            .....
    ELSE IF
           ....
    END

```

And all works and syntax is not underlined anymore 🙂

Conclusion : The “Run keyword if” is not recommended with RF 4 (but works)
