pytest-dev / pytest-selenium

Plugin for running Selenium with pytest

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support for custom driver initialization and webdriver manager

dAnjou opened this issue · comments

Hi,

I've only looked at the source code so far, and it seems cumbersome to programmatically initialize a custom driver, it's not documented at least.

And it'd be nice if https://github.com/SergeyPirogov/webdriver_manager was supported.

Thanks!

Would you mind giving an example of that? What problem are you trying to solve?

As for webdriver_manager, without digging deeper into it - I think it's out of scope for this plugin. You should be able to add that to whatever test-framework you're using.

As for webdriver_manager, without digging deeper into it - I think it's out of scope for this plugin.

That's fair. I was just mentioning it because it's a very convenient and apparently also very popular way of getting a driver instance. Considering that, it'd be nice to support initialization of a driver programmatically.

Currently, at least according to the docs, it's only possible to specify a driver via CLI flag, and there are browsers missing that one might wanna use, like, Brave or Chromium.

Currently, at least according to the docs, it's only possible to specify a driver via CLI flag, and there are browsers missing that one might wanna use, like, Brave or Chromium.

I see, so would you like to see a generic CLI option of specifying a browser? Would you help me understand what that would look like? I ask, because we basically only wrap the browser configuration from the underlying Selenium. So unless I misunderstand (which is 100% possible), that functionality would have to be supported by them first.

Out of curiosity, are there drivers for Brave and Chromium?

Out of curiosity, are there drivers for Brave and Chromium?

Ah, brave == chromium, https://abodeqa.com/selenium-tests-in-brave-browser/

I see, so would you like to see a generic CLI option of specifying a browser?

I barely ever use CLI flags with pytest, just my preference, I rather configure my test environment in code or settings. So in this case, I'd rather be able to overwrite a fixture.

I've had a look at the code and I'm not sure whether I'd get away with overwriting the driver fixture because there are things happening in there which might have implications that I don't understand yet.

commented

With regards to supporting webdriver_manager I think the biggest use case is to be able to let users run tests against different browsers without having to install them manually (i.e making sure they are present on the host system)

Looking at the code I think it may be possible to override driver_args fixture to be able to supply custom service object for arguments of the driver class? But then user has to write additional logic for initializing service class themselves based on passed arguments through --driver. Also the fact that driver_args is currently returning None makes me think it may change in future releases?

Right now it seems that only chrome driver supports driver_args argument, so there is seemingly no way to pass your custom service objects along to WebDriver instance?

With regards to supporting webdriver_manager I think the biggest use case is to be able to let users run tests against different browsers without having to install them manually (i.e making sure they are present on the host system)

Looking at the code I think it may be possible to override driver_args fixture to be able to supply custom service object for arguments of the driver class? But then user has to write additional logic for initializing service class themselves based on passed arguments through --driver. Also the fact that driver_args is currently returning None makes me think it may change in future releases?

Right now it seems that only chrome driver supports driver_args argument, so there is seemingly no way to pass your custom service objects along to WebDriver instance?

As soon as the re-write of pytest-html is finished, we're planning to take look at pytest-selenium.

Mainly to make sure it fully supports Selenium 4.0, but also if we can add or at least easily support extensions like this.

As there Selenium 4.0 is now supported, are there any chances to get also support for webdriver_manager ?