Configuring Dash application testing with webdriver-manager by setting the local path for Chromedriver

I am currently exploring testing Dash applications using the method outlined in this guide:

However, I have encountered an issue with specifying the path of Chromedriver for the webdriver-manager used in dash testing.

Below is a snippet of what I attempted, which triggers the webdriver-manager before the actual test code:

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

When executing this, webdriver-manager initiates the download of the latest Chrome version. Unfortunately, this poses a problem as company policy restricts internet downloads due to firewall restrictions. The mandated approach is to utilize the pre-downloaded Chromedriver available internally on the network.

I made an attempt at creating a pytest fixture to set up the Chrome driver prior to commencing testing:

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

However, webdriver-manager does not seem to accept this alternative setup.

Is there any workaround you are aware of for this challenge? Any suggestions on how to proceed with Dash testing without relying on webdriver-manager?

Thank you.

Answer №1

Dealing with a similar issue led me to create a new pytest fixture called dash_duo_bis. This fixture utilizes a custom class DashComposite(Browser) located in the conftest.py file. In this class, the default behavior of the _get_chrome method is modified as shown below:

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 provide Dash arguments
        self.server(app, **kwargs)

        # Set the default server_url and implicitly call wait_for_page
        self.server_url = self.server.url

Answer №2

I encountered a similar problem but managed to resolve it by adding Chromedriver to the PATH and executing tests. You can try the following steps:

export PATH=$PATH:<path to your chromedriver>
pytest <path to your directory where your test scripts are located>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Unexpected behavior occurs in Django routing with a VueJS single page application when the URL is missing a trailing slash

In my development setup, I am utilizing a Django backend with a VueJS frontend, serving a REST API through Django and using VueJS along with vue-router for the single page application. After reading up on this on Stack Overflow, I found a helpful suggesti ...

What is the best method to merge specified rows in Python using pandas?

I understand that pandas can automatically merge rows and calculate the sum of the rows using the groupby() function. However, I am curious about how to combine two or more rows that do not have common values. Here is an example dataset for reference: C ...

Exploring web content using BeautifulSoup and Selenium

Seeking to extract average temperatures and actual temperatures from a specific website: Although I am able to retrieve the source code of the webpage, I am encountering difficulties in filtering out only the data for high temperatures, low temperatures, ...

The ChromeDriver is experiencing difficulties in correctly switching between frames

Having trouble switching frames properly. The project is a maven project with the following pom.xml: <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.o ...

Is there a way to efficiently resize a collection of 2D arrays (stored as a 3D array) using a 2D array in NumPy for vectorized operations?

I have a 3D array consisting of N x N covariance matrices for M channels [M x N x N]. Additionally, I possess a 2D matrix containing scaling factors for each channel at various time points [M x T]. My goal is to generate a 4D array that includes a scaled v ...

Unable to establish a connection with the python3 service located at /usr/local/bin/geckodriver

Here is the code snippet I am using: #!/usr/bin/python3 from selenium import webdriver driver = webdriver.Firefox(executable_path=r'/usr/local/bin/geckodriver') driver.get('http://www.python.org') The error that I am encountering is ...

Python - Exiting a while loop in response to pressing the Escape key through command line input()

I'm a beginner with Python and I'm currently working on Windows OS. In my application, I am extracting text from the command prompt using the input() method within a while loop. I would like to be able to exit the while loop by pressing the Esc k ...

Difficulty encountered in translating regex patterns into Python code

Dealing with regular expressions can be tricky. I am currently working on a regex that looks like this: [^\\]["'&<>] My goal is to match some unescaped characters, and I decided to try converting it into a Python string format. H ...

Python GData library is generating an excessive amount of redirects

Currently, I am utilizing python GData to interact with Google Calendar. My tasks involve relatively straightforward requests such as creating events and require OAuth authorization. Typically, everything runs smoothly; however, on occasion, I encounter ...

Launching a Shinyapp through the use of Python onto the Shinyapps.io

Having trouble deploying a shiny app with Python on Shinyapps.io. When attempting to deploy, I encountered the following: rsconnect deploy shiny first_python_app --name myaccount --title first_python_app_test The deployment process showed: Validating serv ...

Relative paths in Selenium using Java

One of my files is designated for uploading private String myPath = "..server\\app\\src\\test\\resources"; This file is stored in source control, with everyone having the same structure after the server directory. ...

Tips for extracting the URL of a fresh webpage using Selenium and Scrapy

I'm currently working on a web-scraping project to extract data from a platform known as "Startup India," which facilitates connections with various startups. I have set up filters to select specific criteria and then click on each startup to access d ...

Python OpenCV error encountered

Upon running the Python code provided below, an error message popped up: Traceback (most recent call last): File "C:\Users\smart-26\Desktop\예제\face.py", line 28, in faces = face_cascade.detectMultiScale(grayframe, 1 ...

Unable to interact with element on the following page using Selenium in Python

Attempting to extract data from multiple pages of a URL using Selenium in Python, but encountering an error after the first page. The code successfully navigates to the subsequent pages but fails to scrape, throwing an error message: "Element ... is not ...

Connecting JSON objects based on unique GUID values generated

I am in search of a method to automate the laborious task of linking multiple JSON objects with random GUIDs. The JSON files are all interconnected: { "name": "some.interesting.name", "description": "helpful desc ...

When the enter key is pressed and a text is entered on the same line or under a specific condition

Is it possible to input text and press the enter key using a single statement? I attempted to separate the steps of inputting text and pressing the enter key. Can this be achieved in just one statement? WebElement department = driver.findElement(By.xpat ...

Save the data to a document and ensure it is properly structured and

I am working with a set that contains pairs of names. Here's an example: names = {('nevio', 'chetan'), ('oishee', 'tafel'), ('utas', 'brea'), ('zoiie', 'fennell'), (&a ...

Seeking advice on iterating through Pandas dataframe for developing a stock market algorithm

When it comes to analyzing a trading algo on historical stock market data using Python and pandas, I encountered a problem with looping over large datasets. It's just not efficient when dealing with millions of rows. To address this issue, I started ...

Obtaining the console.log data from Chrome using the Selenium Python API bindings

Currently, I am utilizing Selenium to conduct tests in Chrome through the Python API bindings. I am facing difficulties when it comes to configuring Chrome in order to access the console.log output from the executed test. While exploring the WebDriver ob ...

Discovering parent elements with Selenium C# WebDriver: A straightforward guide

Is there a way to retrieve the parent elements of a By class object after calling the FindElements method? ...