How to use Selenide with Robot Framework

429 views
Skip to first unread message

charles...@gmail.com

unread,
Oct 7, 2015, 6:21:55 PM10/7/15
to selenide
For anyone interested, I thought I'd point out how I got Selenide working with http://robotframework.org/

It turns out that Robot uses a new thread for every keyword executed. It has the same thread name, but the TID changes for each keyword executed.

So, even if you call "WebDriverRunner.setWebDriver(myWebDriverInstance)" you will see Selenide attempt to open a new browser in each Robot Keyword.

The solution is to create a custom KeywordLibrary that sets the webdriver used by Selenide before each Keyword is executed:

public class MyKeywordLibrary extends AnnotationLibrary {
public static final String ROBOT_LIBRARY_SCOPE = "GLOBAL";
private static final String LIBRARY_DOCUMENTATION = "My Keyword Library";

private final Logger logger = LoggerFactory.getLogger(UiKeywordLibrary.class);

public UiKeywordLibrary(String classpath) {
super(classpath);
}

@Override
public Object runKeyword(String keywordName, Object[] args) {
myWebDriver = .... ; // Get your webdriver from somewhere, however your framework works
logger.info("Setting WebDriver for Selenide framework.");
WebDriverRunner.setWebDriver(myWebDriver);
return super.runKeyword(keywordName, args);
}

}

Andrei Solntsev

unread,
Oct 9, 2015, 2:36:58 AM10/9/15
to charles...@gmail.com, selenide
Hi Charles!
Thank you very much for the knowledge exchange. 

It's a good material for a blog post on selenide.org
Do you want to send a pull request with blog post, or I will do it by myself?

Andrei Solntsev


--
You received this message because you are subscribed to the Google Groups "selenide" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenide+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

charles...@gmail.com

unread,
Oct 14, 2015, 1:16:55 PM10/14/15
to selenide, charles...@gmail.com
Go for it!

Andrei Solntsev

unread,
Oct 14, 2015, 3:15:08 PM10/14/15
to Charles Capps, selenide
Hi Charles!
I will write blog post later, right now I am busy with JokerConf conference. :)
If you want to try writing blogpost by yourself, just write it in markdown format and create pull request in "gh-pages" branch. It should be easy, see previous posts for example:



Andrei Solntsev

Ranadheer

unread,
Aug 6, 2021, 2:17:07 AM8/6/21
to selenide
Hi 👋 

May I know if this is documented somewhere for reference? The reference links do not work.

Best
Ranadheer 

Andrei Solntsev

unread,
Aug 6, 2021, 2:56:29 AM8/6/21
to Ranadheer, selenide
Hi Ranadher!
What do you mean? How to use Selenide with Robot framework?
No, it's not described on selenide.org yet. 

Andrei Solntsev


пт, 6 авг. 2021 г. в 09:17, Ranadheer <ranad...@gmail.com>:

Ranadheer

unread,
Aug 6, 2021, 4:17:44 AM8/6/21
to Andrei Solntsev, selenide
Hi Andrei

Yes, wanted to know how to use Selenide with Robotframework. Somehow my team wanted to have reports as detailed as robotframework reports to our existing Selenide tests. So checking out if there are any guides out there from anyone who tried before.

Ranadheer


Andrei Solntsev

unread,
Aug 6, 2021, 4:33:30 AM8/6/21
to Ranadheer, selenide
The original receipt was described in the beginning of this thread:


P.S. As far as I understand, Robot framework is not for reporting. You are probably trying to solve a wrong problem. :)
To generate a nice report, I recommend using Allure - it has built-in integration with Selenide. 
There is also a working example on github: https://github.com/selenide-examples/selenide-allure-junit

Andrei Solntsev


пт, 6 авг. 2021 г. в 11:17, Ranadheer <ranad...@gmail.com>:
Reply all
Reply to author
Forward
0 new messages