# RobotFramework use wrong browser

**URL:** <https://forum.robotframework.org/t/robotframework-use-wrong-browser/973>\
**Category:** Robot Framework\
**Created:** [18 November 2020 10:45 UTC](https://forum.robotframework.org/t/robotframework-use-wrong-browser/973 "2020-11-18T10:45:16Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Max35](https://avatars.discourse-cdn.com/v4/letter/m/94ad74/32.png) [@Max35](https://forum.robotframework.org/u/Max35)\
**Post date:** [18 November 2020 10:45 UTC](https://forum.robotframework.org/t/robotframework-use-wrong-browser/973/1 "2020-11-18T10:45:16Z")

</div>

Hello everyone  
i am a Maxime, beginner in RobotFramework and I am facing issue.

I am working with Python 3.9 and Robot 3.2.2.

I try to write some code to test a web application. For this I write python Class who use selenium to launch application under a web browser (Chrome).

To test it I need to launch 2 instances of my class.

When I do that with robot, it seems that robot use only the last version of my class (wrong driver)

here my example:

My robot code:

\*\* Settings \*\*\*  
Library AppUI WITH NAME UI1  
Library AppUI WITH NAME UI2

\*\*\* Keywords \*\*\*  
Test CheckCall  
UI1.open application  
UI2.open application  
UI1.login login password #In this case Robot use last openned browser UI2 browser  
UI2.login login password #This failed because login page is not display he already login …

My python code:  
Class AppUI(object):

```
def __init__ (self, url)
    self.url = url
    self.driver = None

def open_application(self):
    """ Launch application """
        self.driver.get(self.url)

```

If I try to write my test in python everything is working as expected but with Robot, it used the wrong driver (everytime the last one)

Does anyone have an idea about this issue ?

---

<div class="post-metadata">

**Author:** ![Max35](https://avatars.discourse-cdn.com/v4/letter/m/94ad74/32.png) [@Max35](https://forum.robotframework.org/u/Max35)\
**Post date:** [19 November 2020 09:12 UTC](https://forum.robotframework.org/t/robotframework-use-wrong-browser/973/2 "2020-11-19T09:12:05Z")

</div>

Hello, It’s me again,

Because I haven’t any answer maybe my issue is not clear so I write an example to reproduce this issue.

I am new user so I can not upload file so I will juste copy my code here:

My python lib :

> from time import sleep  
> from selenium import webdriver as webdriver  
> from selenium.webdriver.support.ui import WebDriverWait  
> from selenium.webdriver.support import expected\_conditions as ec  
> from selenium.webdriver.common.by import By

class AppUI(object):  
ROBOT\_LIBRARY\_SCOPE = ‘GLOBAL’

```
def __init__ (self):
    self.driver = None

def open_application(self, url):
    """ Launch application """
    self.driver = webdriver.Chrome()
    self.driver.get(url)
    sleep(5)

def close_application(self):
    """ Close application """
    self.driver.quit()

def get_element_by_class_name(self, element, timeout=5, poll_frequency=0.5):
    return WebDriverWait(self.driver, timeout, poll_frequency).until(ec.visibility_of_element_located((By.CLASS_NAME, element)))

def click_forum_logo(self):
    self.get_element_by_class_name("title").click()

```

def main():  
my\_app\_1 = AppUI()  
my\_app\_2 = AppUI()  
my\_app\_1.open\_application(“[https://forum.robotframework.org/](https://forum.robotframework.org/)”)  
my\_app\_2.open\_application(“[Robot Framework documentation](https://robotframework.org/robotframework/)”)  
my\_app\_1.click\_forum\_logo()

if **name** == “ **main** ”:  
main()

If you execute it everything works fine

Here my robot test:  
\*\*\* Settings \*\*\*  
Library lib.appui.AppUI WITH NAME browser1  
Library lib.appui.AppUI WITH NAME browser2

\*\*\* Keywords \*\*\*  
Test Teardown  
browser1.close application  
browser2.close application

\*\*\* Test Cases \*\*\*  
#CHP O1  
Test Search  
[Teardown] Test Teardown  
browser1.open application ${see\_first\_links\_in\_python\_lib\_new\_user\_can\_only\_put\_2\_links}  
browser2.open application ${see\_second\_links\_in\_python\_lib\_new\_user\_can\_only\_put\_2\_links}  
browser1.click forum logo

For me it is a robot issue, robot does not handle correctly class instances but maybe I am wrong and I do not use robot correctly so please if you guys have any idea how I can solve that tell me 🙂

Have a nice day  
Max

---

<div class="post-metadata">

**Author:** ![Max35](https://avatars.discourse-cdn.com/v4/letter/m/94ad74/32.png) [@Max35](https://forum.robotframework.org/u/Max35)\
**Post date:** [19 November 2020 09:34 UTC](https://forum.robotframework.org/t/robotframework-use-wrong-browser/973/3 "2020-11-19T09:34:51Z")

</div>

Hello,

Sorry it is me again, I have the same issue than here : [https://github.com/robotframework/robotframework/issues/3417](https://github.com/robotframework/robotframework/issues/3417)

With that topics I manage to understand how robot works to create class instance so I manage to solve my issue

Thanks  
Maxime

---

<div class="post-metadata">

**Author:** ![anton264](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/anton264/32/509_2.png) [@anton264](https://forum.robotframework.org/u/anton264)\
**Post date:** [24 November 2020 08:28 UTC](https://forum.robotframework.org/t/robotframework-use-wrong-browser/973/4 "2020-11-24T08:28:25Z")

</div>

Hi Maxime

You should use the seleniumlibrary for your tests rather than write your own keywords. Here is an example

> **[robotframework/SeleniumLibrary](https://github.com/robotframework/SeleniumLibrary/#usage)**
>
> Web testing library for Robot Framework. Contribute to robotframework/SeleniumLibrary development by creating an account on GitHub.
