Implementing @BeforeSuite to run after setting up the webdriver instance in Arquillian

I am facing an issue with using @BeforeSuite after the instantiation of WebDriver in Arquillian. Below is an example:

@RunAsClient
public class GoogleTest extends Arquillian {

    @Drone
    private WebDriver driver;

    @ArquillianResource
    private URL contextRoot;

    @Page
    Google googlePage;

    @BeforeSuite
    public void init() {
        driver.get(contextRoot.toString());
    }

    @Test
    public void googleSearchTest() {
        System.out.println(contextRoot);
        googlePage.searchFor("Arquillian Graphene");
    }
}

However, I am encountering a null pointer exception because the driver is not instantiated. How can I ensure that my @BeforeSuite method is called after the one defined by Arquillian?

I would like to avoid manually instantiating the WebDriver and instead rely on Arquillian's @Drone annotation to handle it while executing my custom @BeforeSuite method afterwards.

Answer №1

The life cycle of WebDriver is managed by Arquillian Drone, eliminating the need for manual instantiation.

It is advised not to utilize WebDriver in the BeforeSuite method as it may not have been properly initialized by Arquillian at that point. The initialization occurs after this stage, making it a suitable location for programmatically overriding any settings in your arquillian.xml.

If you require setup tasks with WebDriver such as login processes, it is recommended to perform them within the test itself or in the BeforeTest method. Launching a URL should be avoided in the BeforeSuite method.

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

Utilizing Selenium webdriver to retrieve images from the internet

Currently, I am attempting to retrieve images from a website using the following code snippet: List <WebElement> listofItems = driver.findElements(By.cssSelector("div.heroThumbnails:nth-child(4) > div:nth-child(2) > div:nth-child(n)")); URL ...

Having difficulty in closing the chat box that has been opened in a web application

I attempted to close the chat box by targeting the element in this manner: driver.findElement(By.cssSelector("span.icon")).click(); However, it is throwing an exception stating "Element is not currently visible and so may not be interacted with" htt ...

Retrieving information from incoming JSON within a Java servlet

I have a client sending me a JSON file via HTTP PUT. Here is the content of the file: { "nomPers": "Testworking", "prenomPers": "WorkingTest", "loginPers": "Work", "pwdPers": "Ing", "active": true }, For my WebService framewo ...

Selenium testing with Python on a React.js frontend results in an outdated error message appearing when attempting to enter text into an input field

I am facing an issue with Selenium where the React-js frontend updates the DOM on every character input in the input field. This causes my variable reference to become stale as it no longer points at the correct DOM element. Even though the element still e ...

AngularJS, Apache Tomcat, and hashtag URLs

I feel like I'm stuck in a nightmare trying to figure out how to work with Tomcat Apache. My Goal One issue I've encountered in AngularJs is the # problem like www.example.com/#/aboutus After doing some research, I discovered that $locatio ...

Using SSL USB Key Authentication for Selenium Testing

I am exploring ways to automate a website interaction where inserting a USB key triggers an alert box asking for verification. After clicking okay, a local program opens which requires entering a pin to activate the key. I am seeking a solution for the b ...

Utilizing the power of Python with Selenium Webdriver to effortlessly upload an image onto Google's image

from selenium import webdriver from selenium.webdriver.common.keys import Keys import sys, os from time import sleep class imageSearch(): """ Image search automation using Google reverse image search with Selenium and Python 3.8. Dependencies: ...

Python automation with selenium - capturing webpage content

I am utilizing selenium to scrape multiple pages while refraining from using other frameworks such as scrapy due to the abundance of ajax action. My predicament lies in the fact that the content refreshes automatically nearly every second, especially finan ...

Issue: When attempting to launch the Chrome browser, a WebDriverException occurs due to the absence of the DevToolsActivePort file

Recently, I updated my Ubuntu to version 20.04 and encountered a problem with Chrome not being available as an APT package but rather through snap. Upon trying to launch the Chrome browser using Selenium WebDriver, I received the following error message: & ...

Is it possible to find out which JavaScript file the AJAX function is using to send a request to a Java servlet?

I am facing an issue with two js files, one.js and two.js. Both of these files make ajax requests to the same Java servlet class(AppController.java). Here is the code from one.js: function addOne(){ var formData = $('#form1').serialize(); ...

When using Selenium WebDriver with Nunit, the test may work in debug mode but encounter errors when run, particularly failing at the

While using C# Selenium WebDriver and Nunit, my test case functions correctly when executed in debug mode. However, when I run the test case in regular mode, it fails with the following message: Error: Unable to locate element {"method":"id","selector": ...

VBA combined with Selenium does not provide the capability to determine the size of an object/element

I'm encountering a frustrating issue with my Selenium setup. Currently, I am using VBA along with Selenium to verify the presence of an element on a webpage. My approach involves locating the element and then checking its size. If the size is 0, it ...

Is there a way to determine if a specific JSONArray is contained within my existing JSONArray?

I am faced with the challenge of parsing a JSONArray that may or may not include an "attachmentPoint" element. Here is an example of the JSONArray structure: [{"entityClass":"DefaultEntityClass","mac":["86:2b:a2:f1:2b:9c"],"ipv4":["10.0.0.1"],"ipv6":[], ...

Execute the LiveServerTestCase in Docker Selenium environment using Django 1.11

Starting from Django version 1.11, the --liveserver option has been removed from the manage.py test command. In the past, I used this option to make the liveserver accessible via the machine's IP address rather than just localhost using the command b ...

Experiencing challenges when using Selenium script on Firefox browser

Details Firefox version: 45.0.2 Selenium: selenium-java-2.53.1 (experimented with selenium-java-3.0.0-beta2 too) Script package Selenium_Practice; import java.util.concurrent.TimeUnit; import org.openqa.selenium.By; import org.openqa.selenium.WebDri ...

Leveraging static variables from src/test in src/main using Maven

I have encountered a challenge while migrating a simple login and logout selenium test, utilizing pagefactory with TestNG. The test runs smoothly when executed as a "TestNG" test, but after moving it to Maven, I faced difficulties in accessing variables ac ...

Interacting with JIRA using Java for handling requests and responses through its REST

This is my first question on stackoverflow. I am trying to implement a post request (using an inputBean/pojo class for necessary parameters) and receive a response (using an outputBean/pojo class to map the json response) using the Jira REST API. Currently ...

Discovering Components with Selenium WebDriver

I'm currently automating a website and having trouble locating a specific element. I've included the HTML code below for reference. Any suggestions would be greatly appreciated. Thank you. < div id="Troy_combine" class="sign_in_flow sign_in_f ...

Finding specific text within an HTML tag using Selenium can be achieved by implementing certain techniques

Can someone help me extract the price of 234,40 € from the HTML code below using selenium? <a class="js-sku-link sku-link" title="Samsung Galaxy Watch4 Classic Bluetooth Stainless Steel 46mm Αδιάβροχο με Παλμογράφο (Black)" dat ...

Selenium paired with the innovative Brave browser, a Chromium-based platform with the latest Version 1.33.106 Chromium: 96.0.4664.110 (Official Build) (64-bit)

I have just started learning Python and am currently working on a browser automation project using Selenium. Currently, I am using Brave version 96.0.4664.45 but facing issues with my Chrome driver not functioning properly. On the other hand, geckodriver i ...