WebDriverRunner getSelenideDriver() method

229 views
Skip to first unread message

Monbo

unread,
Nov 26, 2019, 7:53:31 AM11/26/19
to selenide

Hi, I am using the version 5.3.1. So I updated to the newest... 5.5.0.

Now I can't access to getSelenideDriver() on WebDriverRunner. I can see that now the method is not public. Why this movement?

I need to have webdriver and selenideDriver on BaseTest class.

Thank you!

Andrei Solntsev

unread,
Nov 27, 2019, 5:07:24 PM11/27/19
to Monbo, selenide
Hi Monbo.
Yes, we made method WebDriverRunner.getSelenideDriver() non-public. 
The reason is that you should never use this method. It was my mistake to make it public. 

Please describe why you need it, and I will show you a better solution. :)

Andrei Solntsev


вт, 26 нояб. 2019 г. в 14:53, Monbo <juli....@gmail.com>:
--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenide/e0410ae9-0474-4f60-9a35-ff3ca18deb66%40googlegroups.com.

Monbo

unread,
Nov 28, 2019, 2:40:40 AM11/28/19
to selenide
Ahhh sure, suppose that would be it.

I need to have multi-thread with SelenideDriver, I save the SelenideDriver on a static final ThreadLocal<SelenideDriver> selenideDrivers;variable on BaseClass.

So in tests a call getSelenideDriver() method to get the current thread: return selenideDrivers.get();

I create the SelenideDriver on beforeMethod (I know that Selenide do it automatically, but I need manually). Using: new SelenideDriver(new SelenideConfig(browser("chrome"));

Do you think that multithread and pageobject will run correctly?

Best Regards.

Andrei Solntsev

unread,
Nov 28, 2019, 5:09:19 PM11/28/19
to Monbo, selenide
Hi.
This is the point: "but I need manually". Why do you need? I don't think you really need. 

1. When you need to create webdrivers manually, you should use method WebDriverRunner.setWebDriver(yourWebDriver).
2.\\ When you need to get a WebDriver for the current thread, you should use method WebDriverRunner.getWebDriver().

Both methods operate with WebDriver, not SelenideDriver. You should almost never use object SelenideDriver.
The only case when you really need  SelenideDriver is when you create multiple browsers in the same thread (as described in https://selenide.org/2018/10/10/selenide-5.0.0/). But then you hold them in  local variables, not ThreadLocal. 

Andrei Solntsev


чт, 28 нояб. 2019 г. в 09:40, Monbo <juli....@gmail.com>:
--
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.

Monbo

unread,
Nov 29, 2019, 7:06:37 AM11/29/19
to selenide
So I don't need to manage SelenideDriver, only call $() and other methods of Selenide statically. Automatically will use the correct thread?

Could you give me a tutorial/example with Multi-thread tests using Page Object?

Thank you Andrei.

Andrei Solntsev

unread,
Nov 29, 2019, 6:20:35 PM11/29/19
to Monbo, selenide
Yes, sure. You just call Selenide.open() and Selenide.$(), and it will use a per-thread webdriver automatically. 

There is no a specific example for multi-threaded tests. All Selenide tests can be executed in parallel. 
For example, these tests work fine in multi-threaded run: https://github.com/selenide-examples/google/tree/master/test/org/selenide/examples/google/selenide_page_object

Andrei Solntsev


пт, 29 нояб. 2019 г. в 14:06, Monbo <juli....@gmail.com>:
--
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.
Reply all
Reply to author
Forward
0 new messages