1

I am trying to leverage testing Dash application as described here: https://dash.plotly.com/testing

However I found no way of specifying the Chromedriver path for the webdriver-manager under the hood of dash testing.

I tried this below which calls webdriver-manager before reaching the test code:

def test_bsly001_falsy_child(dash_duo):
    
    app = import_app("my_app_path")
    dash_duo.start_server(app)

webdriver-manager then would start downloading the latest Chrome version. But due to company policy we cannot just download things from the internet, it is blocked by firewall. We are supposed to use the Chromedriver which is already downloaded for us on the internal network.

I tried implementing a pytest fixture to set up the Chrome driver before the testing starts:

driver = webdriver.Chrome(executable_path="...")

But webdriver-manager does not accept this.

Do you know any ways of working around this? Any hints? Any way of doing Dash testing without webdriver-manager?

Thanks.

Daniel
  • 11
  • 1
  • If you put your Chromedriver in the same folder you should not give path of Chromedriver so, put your Chromedriver in same folder and use it like:`driver = webdriver.Chrome()` – Devam Sanghvi Apr 12 '22 at 15:03
  • I tried this but did not help. It is Dash feature/limitation that WebDriver manager starts every time and tries to download the latest ChromeDriver, even it is on the path, even if it is on the same folder, even if it has already been loaded before by Selenium itself. – Daniel Apr 13 '22 at 07:11
  • Are you using webdriver-manager module?you do not need to use webdriver-manager module. – Devam Sanghvi Apr 13 '22 at 07:39
  • With Dash there is no other option: https://dash.plotly.com/testing. That is what I am trying to resolve or work around. – Daniel Apr 13 '22 at 09:50
  • can you provide some more code snippet and you can also try [chromedriver-autoinstaller](https://pypi.org/project/chromedriver-autoinstaller/) module may it helps you – Devam Sanghvi Apr 13 '22 at 09:59

1 Answers1

0

I had a similar problem and ended up with another pytest fixture dash_duo_bis which uses another class DashComposite(Browser) inside the conftest.py where the _get_chrome method is overriden as follows:

class DashComposite(Browser):

    def __init__(self, server, **kwargs):
        super().__init__(**kwargs)
        self.server = server

    def get_webdriver(self):
        return self._get_chrome()

    def _get_chrome(self):
        return webdriver.Chrome(executable_path = r"MY_CHROME_EXECUTABLE_PATH")

    def start_server(self, app, **kwargs):
        """Start the local server with app."""

        # start server with app and pass Dash arguments
        self.server(app, **kwargs)

        # set the default server_url, it implicitly call wait_for_page
        self.server_url = self.server.url
Anthony
  • 1
  • 2