What is the best way to ensure that sessions in a Selenium Grid can remain idle without any limitations, while also efficiently removing disconnected sessions?

I am currently working with a selenium grid that has the following configuration:

{
  "port": 4444,
  "newSessionWaitTimeout": 2000
}

There are also 2 nodes that use this configuration:

{
  "capabilities": [{
    "browserName": "chrome",
    "platform": "LINUX",
    "maxInstances": 8
  }],
  "configuration": {
    "nodeTimeout": 120,
    "port": 5555,
    "hubPort": 4444,
    "hubHost": "hubhost",
    "nodePolling": 2000,
    "registerCycle": 10000,
    "register": true,
    "cleanUpCycle": 2000,
    "timeout": -1,
    "browserTimeout": -1,
    "maxSession": 8
  }
}

I have written a Java code that establishes a connection using the RemoteWebDriver-Class. The code performs various actions on the driver and then goes into a suspended state for an unknown duration (between 30 seconds to 1 hour). I need the session to remain open as the process needs to quickly resume upon waking up.

When the timeout is set to -1, everything works fine. The process stays connected to the session and the browser indefinitely. However, at times the process gets terminated randomly by an automated service. The node acknowledges the client shutdown with the message:

selenium deleted due to client timeout

But the sessions are not cleaned up! The unlimited timeout keeps them alive and the grid doesn't release them for further use.

Is there a solution within the selenium config to address this issue?

Implementing a process-shutdown-hook that calls "driver.quit()" to release the session is not desirable in my case.

Any suggestions or assistance would be greatly appreciated. Thank you!

Answer №1

Have you observed the configuration setting "cleanUpCycle": 2000? This indicates that the Hub will perform self-cleanup every 2000 milliseconds!

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

Having issues with Chropath for Selenium Xpath not functioning properly?

After installing chropath to help me find the xpath for websites, I tried to locate the username field on a specific website using Selenium from selenium import webdriver from selenium.webdriver.common.keys import Keys driver = webdriver.Chrome("C:\ ...

Selenium - Comparing text_to_be_present_in_element with text_to_be_present_in_element_value

Would you be able to provide an example in Python that demonstrates the contrast between text_to_be_present_in_element and text_to_be_present_in_element_value? I came across this link which attempts to clarify how text_to_be_present_in_element functions, ...

Use Selenium to locate the element through the label

Here is the html code snippet that I'm working with: <label class="error" id="field">Invalid format </label> I have been attempting to retrieve the value Invalid format using this command: System.out.println(driver.findElement(By.id("fi ...

The Selenium script is encountering difficulties recognizing the web elements while running on IE10

One common issue faced by Selenium developers is the inability of Selenium code to identify web elements on IE10, even after the driver path has been set. File file = new File("D:\\Driver\\IEDriverServer.exe"); System.setProperty("webd ...

What is the best location to place the "get current URL" method while implementing page objects in Selenium?

When attempting to confirm whether the current URL matches the homepage URL, is it recommended to include the logic for retrieving the current URL directly within the test method, as shown in let currentUrl = browser.getCurrentUrl();, or should this logic ...

a guide on transforming a string array into JSON

I initialized an array like this String[] finalcodes = new String[50] ; and populated it with some values. However, when I print finalcodes, the output is: ["aaa","bbb","ccc"] My goal is to convert this string array into a JSON Object. Can someone pl ...

What are some effective strategies for ensuring employees consistently turn in their timesheets?

At our company, it is necessary to submit timesheets on a weekly basis every Monday. Wondering how to go about filling out the timesheets? Simply access a website Choose the previous week's data from a dropdown menu. Input the time spent on each ta ...

What steps do I need to take to integrate an Android app with an online MySQL database?

I am currently developing an Android app where users will input text, and I need to store that data in an online database for later retrieval. I have a LAMP server set up online that I can utilize. Could someone guide me on how to connect Java with PHP an ...

Leveraging regular expressions to target elements with dynamic numerical values embedded within xpath patterns

Within my application, I encounter emails in the inbox with unique IDs. Unfortunately, clicking on the first email is proving to be a challenge due to the constantly changing mail ID. The specific xpath looks like this: //*[@id='r1295']/td[4]/a ...

Ways to avoid running any cucumber-jvm scenarios if the initial scenario fails

I have 8 scenarios using cucumber-jvm, with the very first scenario focused on measuring page load time and checking environment availability. If this initial scenario fails, such as due to an unavailable environment or slow loading times, I want all other ...

Transferring cookie data between requests in CrawlSpider

My current project involves scraping a bridge website to gather data from recent tournaments. I have previously asked for help on this issue here. Thanks to assistance from @alecxe, the scraper now successfully logs in while rendering JavaScript with Phant ...

Can you explain the functionality of the Selenium Service class?

I am intrigued by the function of the Selenium class known as "Service." Could this be beneficial for configuring a Chrome driver instead of simply invoking a webdriver with my_driver = webdriver.Chrome(...)? After reviewing the documentation, I found it ...

JSON - just return an Integer instead of a Long

Is there a way to retrieve an Integer instead of a Long from JSON data? When working with JSON in Java, I encounter an issue where the parser returns numbers as type Long, but I need them to be Integer. I attempted casting the long value to an integer, h ...

Using Selenium to interact with a numerical keyboard and pressing a button within the numerical scope

In my program, I have a numerical touchpad (1-9) that needs testing. The goal is to check if the user enters numbers that end in 1 to 9, such as 0.01, 0.33, or 4.46, the system should display a notification: "Invalid price". Numbers are only valid if they ...

GeckoDriver Firefox and Protractor(Selenium) encountered a NoSuchWindowError due to the browsing context being discarded

I need assistance with running a basic test script using protractor. Environment: Node Version: v9.8.0 Protractor Version: 5.4.1 Angular Version: 1.x Browser(s): Mozilla Firefox 60.1.0 Operating System and Version: HELiOS release 6.10 Below is my config ...

I'm having difficulty changing to an IFrame on Internet Explorer

I recently created a keyword-driven framework which includes an action keyword to switch frames. While it works perfectly fine with Mozilla, I encountered an issue with Internet Explorer where the frame is not switching and it logs an error instead. IE Dri ...

The REST Client is reporting back with an HTTP status code of 401

Thank you for taking the time to read this! Overview: I have developed a JAVA REST client that authenticates with a username and password, returning a JSON response. Issue: I am encountering the following exception: Error in thread "main" java.io.IOExc ...

Enhance block opacity and adjust collision box dimensions (Version 1.10.2)

My candle block has some issues: The sandstone doesn't render properly Collision is set as a full block The selection box appears as a full block (gray wireframe) The old methods provided by Forge to adjust bounding boxes are now deprecated. Settin ...

Java Regular Expression not replacing all instances in certain JSON object (converted to a string)

Having trouble removing all the slashes from a JSON Object and adding it to an array list. No matter what Regex I use, I can't seem to get rid of the slashes or the brackets and duplicate strings. It's been a struggle trying different things, eve ...

Drag and drop a file onto the center of the screen to upload it using Python

I need to upload a file to a website using Python Selenium, but because I am working in headless mode, I cannot click on the upload file button. Is there a way for me to automatically upload a file by dropping it in the center of the screen? I attempted th ...