In this post, we will integrate RobotFramework with BrowserStack and we will run our test in BrowserStack’s cloud grid system. Last week, I described how to install and use RobotFramework in this post. If you don’t have any experience or if you don’t know how to use RobotFramework, please check that post first.
Please, see the latest update for RobotFramework and Selenium 3.0 Integration in this article.
I want to go with the same Linkedin Login test example. Our test scenario is shown below:
- Open LinkedIn page
Check Title- Enter User Name
- Enter the Wrong Password
- Click Login
- Wait 5 seconds
- Assert Warning Message
- Close Browser
This time, I want to use two files for a better test structure. These are setup.robot and BrowserStackLoginTest.robot
We will have two folders one of them is Resource and the other is Tests folder. Resource folder comprises of setup.robot and Tests folder contains BrowserStackLoginTest.robot file.
setup.robot file holds Settings, Variables, Keywords information, and BrowserStackLoginTest.robot contains test codes.
setup.robot
In order to connect BrowserStack, we should register it and have an account. By using our account’s AccessKey and username information, we can connect BrowserStack. Also, we should use desired capabilities to declare which operating system, browser, browser version, OS version, etc. we will use. In below code, I did all these settings.
*** Settings *** Library Selenium2Library *** Variables *** ${Username} swtestacademy@gmail.com ${Password} wrongpass ${SiteUrl} http://www.linkedin.com ${DashboardTitle} World's Largest Professional Network | LinkedIn ${ExpectedWarningMessage} Hmm, we don't recognize that email. Please try again. ${WarningMessage} Login Failed! ${Delay} 5s ${BSUser} YOUR-USER ${AccessKey} YOUR-ACCESS-KEY ${RemoteUrl} http://${BSUser}:${AccessKey}@hub.browserstack.com/wd/hub *** Keywords *** Open LinkedinPage [Arguments] ${BROWSER} ${BROWSER_VERSION} ${OS} ${OS_VERSION} Open Browser url=${SiteUrl} browser=${BROWSER} remote_url=${RemoteURL} desired_capabilities=browser:${BROWSER},browser_version:${BROWSER_VERSION},os:${OS},os_version:${OS_VERSION} Maximize Browser Maximize Browser Window Enter User Name Input Text id=login-email ${Username} Enter Wrong Password Input Text id=login-password ${Password} Click Login Click Button css=[name=submit] #Check Title #Title Should Be ${DashboardTitle} #There is an encoding problem in this function. Assert Warning Message Element Text Should Be id=session_key-login-error ${ExpectedWarningMessage} ${WarningMessage}
When I tried to run the same test on BrowserStack I got an encoding error on the “Title Should Be” method. I tried to fix that encoding problem but I was not successful. I also asked about this issue on StackOverflow (Link: http://stackoverflow.com/questions/36936352/how-to-match-browserstack-and-robotframework-encoding). If you know the solution, please write a comment.
Error Screen is shown below. :(
Now, let’s write our test robot file.
BrowserStackLoginTest.robot
*** Settings *** Resource ../Resource/setup.robot Suite Teardown Close Browser Force Tags BrowserStack *** Test Cases *** Login Should Failed With Unregistered Mail Adress Open LinkedinPage BROWSER=Chrome BROWSER_VERSION=47.0 OS=Windows OS_VERSION=7 #Check Title Enter User Name Enter Wrong Password Click Login sleep ${Delay} Assert Warning Message [Teardown] Close Browser
Execution & Results
Open a command prompt and go to your test folder and then type the below command.
robot BrowserStackLoginTest.robot
Then, you will see below execution at the command prompt.
and you will see test execution on BrowserStack’s Dashboard.
Thanks.
-Onur

Onur Baskirt is a Software Engineering Leader with international experience in world-class companies. Now, he is a Software Engineering Lead at Emirates Airlines in Dubai.
I have tried the same code and it is giving an error as no browser is open on the keyword openLinkedinpage
Also the response code 10061 from Selenium2Library
Everything is working fine. I have just run the code again. I think you are doing something wrong.
Hey. How do you get the http://user@domain.com:pass@address working? For me it cuts already the address from the first @ -mark and tries to remote connect to pass@address as the remote url. I have tried escaping it with \ or putting %40 in place of @ for the email username. It does no have affect if I have the username and password in variables or write it straight to the the address.
I really don’t know your question’s answer. Did you do a google search for that?
How can pass the Testcase name to the bowsertack from RobotFramework? longside browser=${BROWSER} remote_url=${RemoteURL}
You need to pass another parameter ${name} along with the desired capabilities.
It works fine for the public server, I need ti run the same think for a local server in the remote browser. I have this issue : Could not get IP address for host: hub.browserstack.com
Please Help !
Has Any1 been able to implement the same in Jenkins pipeline for browserstack local testing
Very neat and clean ………..better understanding …….Thanks
Thanks for your feedback.
Hi,
Thanks for simple yet details explanation. Code works like gem. Appreciate your help !
Hi Jameer, I am so happy to help you. Thank you for your kind feedback.
Hi, How to run parallel testing on broswerstack from robotframework ?
You should try PaBot. Here is an example: http://testnblog.com/running-robot-test-cases-in-parallel-pabot/ I hope it works.
Or try this one!
Place a list of browsers you want to execute your test case in a list and run the for loop for your test case
*** Variables ***
@{BROWSERS} Chrome firefox chrome
*** test cases ***
test with several browsers
:FOR ${browser} IN @{BROWSERS}
\ Step 1
\ Step 2
so that your test case will run in all the browsers which you have listed in @{BROWSERS}. Your test script will be failed if it failed at any case(any browser)
reference: https://stackoverflow.com/questions/43383892/how-to-run-a-single-test-case-to-multiple-browser-in-robot-framework
how to select date from date picker using robot frame work and website developed in angular js
You can try this library: https://github.com/rickypc/robotframework-extendedselenium2library
Reference: https://stackoverflow.com/questions/31332961/robot-frameworkselenium2library-with-angularjs-2-0
@onur Baskirt, Is there any alternative in Python 3 as ExtendedSelenium2Library is not maintained for Python 3 only compatible with Python 2.
Hi Rakesh, for robot framework, I highly suggest connecting with “Tugce Alphan Acar” and “Sinan Erdinç” on Linkedin. They are the experts in RobotFramework and they can answer your questions better. For a long time, I am not using RobotFramework daily basis.
Hi This was very helpful.. I’m trying to run the script through my local. The elements are not getting recognized. And it fails.
Second question i have enough parallel run but im getting the error “WebDriverException: Message: All parallel tests are currently in use, including the queued tests. Please wait to finish or upgrade your plan to add more sessions.”
Hi Josey, It was a very basic test scenario to help us to go further. Probably elements’ ids changed. I will try to update the article in the future. But I guess that the concept will be the same. For parallel runs, I did not try parallel execution with RF. It is better to check StackOverflow for these kinds of problems.
Hi,
I’ve tried to use some robot command in browser stack, to upload a file. Below commands were used. They are working fine in my local machine i.e. without using browser stack, but in browser stack the below mentioned commands are not working. Not getting any error as well.
robot.keyPress(KeyEvent.VK_CONTROL);
robot.setAutoDelay(2000);
robot.keyPress(KeyEvent.VK_V);
robot.keyRelease(KeyEvent.VK_CONTROL);
robot.keyRelease(KeyEvent.VK_V);
Any suggestion why these are not working.?