Retrieve the ReadTimeout while using Selenium webdrivers on Heroku platform

Encountering an error while using selenium webdrivers on Heroku. (rspec->capybara->selenium)

Net::ReadTimeout: Net::ReadTimeout with #<TCPSocket:(closed)>

Utilizing the heroku-buildpack-google-chrome buildpack, alongside webdrivers-gem.

Here is the block in spec setup:

chrome_shim = ENV.fetch("GOOGLE_CHROME_SHIM", nil)

Selenium::WebDriver::Chrome.path = chrome_shim

chrome_opts = { "chromeOptions" => { "binary" => chrome_shim } }

Capybara.register_driver :selenium do |app|
    Capybara::Selenium::Driver.new(
      app,
      browser: :chrome,
      desired_capabilities: Selenium::WebDriver::Remote::Capabilities.chrome(chrome_opts)
    )
end

Capybara.javascript_driver = :headless_chrome

Webdrivers.logger.level = :DEBUG output can be found here https://gist.github.com/IanVaughan/3e0c50d2fa4a60e672b96f6726fbbb8c

capybara (3.30.0)
webdrivers (4.2.0)
selenium-webdriver (3.142.7)

Full stack trace available at: https://gist.github.com/IanVaughan/09b31613833d965ee4f3b7d1e48fd1e2

The specific spec being executed is :

RSpec.feature 'User signup flow', :js do
  scenario 'Visits home page to signup' do
    visit root_path
    new_window = window_opened_by { click_link 'Sign Up', match: :first }
    within_window new_window do
      expect(page).to have_text('New Enquiry', wait: 5)
    end
  end

Answer №1

In the event that your application experiences a timeout during its initial request, particularly when performing a one-time task such as compiling assets, it may be necessary to adjust the permitted read timeout.

To address this, you can modify the Selenium driver configuration in Capybara by increasing the timeout value. This can be achieved by setting the timeout parameter to 60 seconds, which is an increase from the default value of 30 seconds.

Answer №2

There is a chance that the cookies are being cleared after 30 seconds in headless mode.

You can attempt to fix this issue by including the following code in the Chrome options:

--enable-features=NetworkService,NetworkServiceInProcess

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

Attempting to navigate a menu by hovering over it and selecting a link from the sub-menu, only to be met with unsuccessful results

I'm currently practicing how to hover over a menu and then click on a link in the sub-menu. For this exercise, I need to visit the URL "", hover over "Hello Sign in", and finally click on the link labeled "Start here". I've managed to successfu ...

How can I create a reusable function in Java Selenium WebDriver that can be called multiple times?

@Test(priority = 0) public void platformAdminLogin() { // logging in as a platform admin using correct credentials try { driver.findElement(By.id("emailId")).sendKeys("example@example.com"); driver.findElement(By.id("password")).sen ...

Searching for a way to input information that includes double quotation marks with Selenium Webdriver?

When attempting to input a password with a special character, specifically double quotes, I encountered a compile time error in Java due to the following code. driver.findElement(By.id("cred_password_inputtext")) .sendKeys("ghsfdjfsg"ksdkhkh"); ...

Error message stating that there may be a stall in the supplied function when using the titleContains() method in Selenium 4.0.0-alpha-5 with Java 11

After searching extensively on Google, I couldn't find any relevant information about this timeout issue. Despite reviewing the source code in Selenium, I still couldn't find a solution or any helpful insights in the logs. Has anyone else encount ...

Having trouble closing the popup with the Selenium driver, the main problem seems to be the element not being found

When attempting to close a popup using selenium's find element method with xpath, it fails to detect the popup. After trying methods like time.sleep(10) and driver.find_element(By.XPATH, "XPATH").close(), the issue persists. I've also experiment ...

Running tests using Selenium and Maven works fine on a local machine, but encounters an issue in Azure Pipeline with the error message "unable to access org.testng.Assert."

Running TestNG or Maven tests locally shows that all test cases are working correctly. However, when running the tests in a pipeline, an error is encountered stating "cannot access org.testng.Assert". Attached below are error screenshots of Azure Pipeline: ...

I'm struggling with a Python Bot issue, as it seems the driver is not being acknowledged

I'm encountering an error with my code while trying to run a WhatsApp bot. Can anyone help me figure out why this error is occurring? Here is the error message that I am getting: Error: Traceback (most recent call last): File "C:\Users&bs ...

RobotFramework encountered an unexpected issue - TypeError: WebDriver.__init__() was given an unknown argument 'service_log_path'

Today, I embarked on a journey to set up and utilize RobotFramework for the very first time. Following all the necessary installations, I eagerly wrote a test robot that aimed to simply open Chrome. However, every attempt I made resulted in an error messag ...

Is there a way to maintain the scroll bar's position even when I click the go back button?

Upon clicking each transaction within the Activity and then returning to this website here , the scroll bar automatically moves back to the top of the page. https://i.stack.imgur.com/3nObv.png I attempted to solve this issue with the following code: WebDr ...

Identify the button within an unordered list and interact with it when the specified condition is fulfilled

Utilizing Python/Selenium to interact with an unordered list on a webpage. Using the find_element_by_xpath method to correctly pinpoint the specific div (text "$x.xx" is typically unique). The goal is to automate clicking the purchase button wit ...

An issue with the Selenium webdriver: 'to_capabilities' attribute not found in 'NoneType' object

I've encountered an issue while attempting to run the code snippet below in Python: Cell In[11], line 10 driver = webdriver.Remote(service.service_url,options) File ~/anaconda3/envs/algo/lib/python3.10/site-packages/selenium/webdriver/remote/ ...

Selenium: Mastering explicit waits within a loop

Here is a different approach to implementing explicit waits for an element: from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_c ...

Unable to interact with Hebrew text using Selenium WebDriver with Python

Exploring Selenium Web Driver using Python with Chrome driver has been an interesting journey for me. I discovered that while I was able to make it click a button with English text, it failed to do so when the text was in Hebrew. To illustrate this issue, ...

Encountering ERR_EMPTY_RESPONSE in Google Chrome while utilizing BrowserMobProxy for conducting Selenium tests

I have developed a simple method for extracting network traffic data from Chrome: public void saveNetworkTraffic() { System.setProperty("webdriver.chrome.driver", System.getProperty("user.dir") + "/bin/chromedriver"); String sFileName = "networkl ...

Retrieve the text content of an element utilizing Selenium without any HTML tags

I'm looking to extract the text 'Rejected' from the code snippet below. <tr bgcolor="#f0f0f0"> <td class="bodyText" width="45%"> <td class="bodyText" width="55%"> <b>Status:</b> Rejected ...

Using Python and Selenium to interact with dropdown menus in the browser

Being new to this, I've reviewed some of the examples provided here but despite their simplicity, I'm still struggling to make it work. The website I am trying to navigate is: www.webauto.de Below is my code for selecting a car make, model, and ...

Encountering a StaleElementReferenceException when attempting to interact with buttons in a dynamically updated table using Python with Selenium Webdriver

Encountering a StaleElementReferenceException while testing a webpage with a table is proving to be a challenge. The table includes points and the status of two Blocking points, each with toggle state buttons for 'Yes' and 'No'. The st ...

Is there a way for me to retrieve randomly generated id values?

I've been grappling with extracting randomly generated ID values from the mentioned website. Despite trying to combine various find_element options, I haven't had any success in retrieving these ID values. Can someone suggest an appropriate optio ...

Tips for choosing multiple rows from various locations in a table with Selenium WebDriver

I have been experimenting with the following code to retrieve table rows, but I want to specifically select rows that are in various locations within the table. @Test public void testRowSelectionUsingControlKey() { List selectedRows = ...

Encountered an issue while attempting to set up WebDriver on Google Colab

This is the code I used in Google Colab: !pip install selenium !apt-get update !apt install chromium-chromedriver from selenium import webdriver chrome_options = webdriver.ChromeOptions() chrome_options.add_argument('--headle ...