Executing Specific Test First Before All Others Using Specific Parameters - WDIO and Selenium

I'm currently working with WebDriverIO and I have a specific requirement:

  • Execute a single test before any other tests (createNewUsers)
  • Utilize certain capabilities (proxy settings) for this initial test
  • Afterwards, switch to using default capabilities for all subsequent tests

However, I'm facing an issue:

I attempted to add a different set of capabilities while using the exclude argument to restrict it to a particular spec. Yet, I am unsure if this approach is feasible and how to execute that specific test in my before block - this is how I define the excluded capability:

exclude: [ './newUserCreationStage/newStageUsers.js' ],

In the before block - how can I specify to run that test (if possible):

before: function (capabilities, specs) {
    expect = require('chai').expect;

    RUN THIS './newUserCreationStage/newStageUsers.js'
},

Answer №1

To improve your setup, consider exploring different approaches. Check out the xUnit Fixture Setup Patterns for guidance. You can achieve the functionality of `createNewUsers` through SuiteFixture Setup, Prebuilt Fixture, Setup Decorator, and Creation Method. This will help set the System Under Test (SUT) in the desired state without the need to

Run a single test before any test is run

If possible, consider seeding a database or calling APIs to preload necessary data before running tests. This concept is also known as Back Door Manipulation. Delegate these tasks to your CI server as a dedicated step.

Since you're using Mocha, leverage tags to organize your test suites and specs efficiently. Additionally, explore tools like mocha-tags to streamline this process. Consider implementing the Strategy pattern for managing different driver capabilities based on specific test requirements. This approach allows for easy customization by creating subclasses with varying behaviors.

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

Navigating through xpath in Python Selenium?

a = driver.find_elements_by_xpath("//article[3]/div[3]/div[2]/a[*[local-name()='time']]") for links in a: print (links.text) This code snippet is part of a project I am developing for Instagram using Selenium. It aims to track the mo ...

Can Selenium be considered a viable automation tool, similar to how one would utilize cURL?

Due to certain limitations, we are unable to utilize cURL for automating tasks on a third-party website. Instead, we have turned to using Selenium through PHP integration which allows us to successfully perform the necessary tasks. While Selenium is prima ...

Maximizing the Benefits of Scrapy's Concurrency Using Non-Selenium Requests

Currently facing an intriguing challenge while developing a Scrapy web scraper for extracting products from a website. The obstacle lies in the fact that the catalog pages on the site utilize lazy-loading, restricting me to gather only the initial 12 items ...

Is it possible to incorporate conditions with axes in XPATH?

Is it possible to use conditions with axes in XPATH? I am attempting to check both parent and child elements using XPath. For example: //span[text()='Accounts']/parent::a OR child::div I know the syntax above is incorrect. Is there a way to ac ...

The method org.openqa.selenium.firefox.GeckoDriverService.access$000(GeckoDriverService.java:42) allows access to a specific

I encountered a problem while attempting to execute a simple code in eclipse. System Specifications: Firefox version - 61.0b4 (64-bit), Jdk - jdk1.8.0_121, Eclipse oxygen import org.openqa.selenium.WebDriver; import org.openqa.selenium.firefox.FirefoxDri ...

Extract keys from the string

Is there a better way to extract keys from a string? const {Builder, By, Key, until} = require('selenium-webdriver'); ... const obj = {val: 'Key.SPACE'} if(obj.val.startsWith('Key.'))obj.val = eval(obj.val); (...).sendKeys(obj ...

Storing and accessing a hyperlink using Selenium Webdriver

My strategy is as follows: Navigate to the desired webpage. Identify and save the link's class attribute. Access the saved link. This is the code implementation I have developed: driver.get("http://www.example.com/"); driver.findElement(By ...

Guide to using Python Selenium to locate and click on the last text found on a webpage

When visiting a webpage, I noticed that there are multiple texts with the same name. For example: Explore Explore Explore Explore Explore I am interested in clicking either the 4th or 5th occurrence of this text. Please note that the count of occurren ...

Locating a button using the span text in Python with Selenium

<li id="b43d980c-53bb-4892-8f32-5ae8ebd9026e" class=""> <input type="button"> <span>Male</span> </li> Is there a way to find and interact with this element? ...

use selenium to choose an element

I'm attempting to target a specific element in the HTML code below: <ul class="selectReplace opened"> <li class="default">Standard pizzas</li> <li class="first">Standard pizzas</li> <li class="">Special pizzas</ ...

Entering values into Dash table during Selenium testing

To better illustrate my issue, I have put together a self-contained example for you to review. Below is: a basic Dash application featuring a single table an attempt to enter a new value into the editable table using Selenium (necessary for testing purpo ...

Transformation of Python try-except (or try-catch) code block into VBA for a simple Excel-Selenium workflow

Here is a piece of code I'm working on: #Code snippet in Python try: io = myElm.get_attribute("rel") print(io) except IndexError: d_io = myElm.get_attribute("data-outcome") print(d_io) except: print ...

Automating the process of updating cookies with Selenium and Python

I've been experimenting with checking the freshness of my cookies. Specifically, I'm conducting tests on Facebook.com. It's a hassle to have to log in every time I want to test something, so I'm keen on avoiding that if possible. Howev ...

Obtaining the Id token bearer through selenium webdriver - a step-by-step guide

Is there a way to retrieve the id token bearer post-login using selenium webdriver or another framework? Any suggestions would be appreciated. Thank you! ...

Struggling to Create a T-Rex Game Bot with Selenium and Robot Class

I'm currently facing an issue with my T-Rex game bot. Initially, the code runs smoothly for a few seconds but then the game abruptly ends. In this project, I have employed Selenium and The Robot class. Below is a snippet of my code: public static voi ...

selenium problem: having trouble choosing an option from a dropdown menu when using thymeleaf

I am currently experiencing a dilemma when trying to select a value from a dropdown during a selenium test. I am retrieving my values from a properties file using thymeleaf in the following manner: <option th:each="medication : ${medications}" ...

The element within the HTML code seems to be elusive when attempting to locate it using the Selenium Robot Framework

Displayed below is the HTML code for a toggle element representing a sidebar menu (nbn network rollout reports) that will reveal two links upon being clicked or expanded. An attempt was made to use the "Click Element" keyword with "network rollout repots ...

Guide to switching to the next window using Python's selenium package

Task: Log in to the main page using username/password credentials. Once logged in, a new page will appear with a dropdown button. Select an option from the dropdown and capture a snapshot of the page. from selenium import webdriver from selenium.webdriver ...

What is the best way to extract data from each individual product subpage using Selenium?

My goal was to extract information from a specific website. url = "https://www.goldenvisas.com/investment?location=portugal&paged={page}" Once I had successfully managed the pagination, my next task was to collect data within each 'prod ...

The action cannot be executed with more than one method argument specified

Whenever I try to utilize one of the standard PHPUnit Selenium assertions, the test fails and an error message is displayed: Error: Command cannot have multiple method arguments. The correct usage according to is: void assertElementValueEquals(string $ ...