What could be causing Selenium to point to the wrong root directory in this particular CircleCI 2.0 build?

I'm currently in the process of setting up a Rails application for testing on CircleCI 2.0, which was previously functioning well on v1.0.

I have created a configuration file with the following Docker images (this is my first experience with Docker, so I'm not certain if this setup is correct):

build:
  docker:
    - image: circleci/ruby:2.4-node
      environment:
        SELENIUM_DRIVER_URL: http://localhost:4444/wd/hub
    - image: circleci/postgres:10.2
        environment:
          POSTGRES_USER: user
          POSTGRES_DB: datatbase
          POSTGRES_PASSWORD: ""
    - image: selenium/standalone-chrome:3.5.3

Although everything appears to be functional and all tests are passing, there is one test that fails!

Failure/Error: attach_file 'file', File.join(Rails.root, 'spec', 'support', 'images', 'test_image.jpg'), visible: false
     Selenium::WebDriver::Error::ExpectedError:
       invalid argument: File not found : /home/circleci/project/spec/support/images/test_image.jpg

The file test_image.jpg does exist and is successfully used in other non-JS specs that pass without any issues.

This failing spec is the only one testing JavaScript, and as a result, it is being executed via selenium/chrome.

Based on the test output, it seems like selenium is searching in home/circleci/project instead of the Rails root directory.

How can I adjust the configuration to ensure that this specific spec searches in the correct root folder for this file?

Answer №1

After grappling with this issue for quite some time, I finally managed to find a solution. Docker is still a bit foreign to me, and the CircleCI documentation didn't provide much clarity in certain areas.

For anyone facing a similar problem, here's what worked for me: I removed

image: selenium/standalone-chrome:3.5.3
from my configuration file and instead opted for a Ruby image that bundled everything I needed - circleci/ruby:2.4-node-bowsers.

build:
  docker:
    - image: circleci/ruby:2.4-node-bowsers
      environment:
        RAILS_ENV: test
    - image: circleci/postgres:10.2
        environment:
          POSTGRES_USER: user
          POSTGRES_DB: database
          POSTGRES_PASSWORD: ""

And just like that, problem solved!

Answer №2

Expanding on the solution provided by the original poster, I had to make some modifications to my circleci config.yml file in order to ensure that Capybara and Selenium work seamlessly together:

  - run:
      name: Download Selenium
      command: |
        curl -O http://selenium-release.storage.googleapis.com/3.5/selenium-server-standalone-3.5.3.jar
  - run:
      name: Start Selenium
      command: |
        java -jar selenium-server-standalone-3.5.3.jar -log selenium.log
      background: true

I chose not to leave a comment on the OP's post as the code formatting may not have displayed correctly.

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 the complexities of managing parent and child iframes

I am encountering a situation where I have a parent iframe with a button that, when clicked, should open a child iframe. While I can successfully switch to the parent iframe, I am facing difficulties interacting with the child iframe. What would be the rec ...

Are there alternative, more dependable methods for executing a click command on an element in Headless Chrome using Selenium?

For the past two days, I have been struggling with a frustrating issue involving the click() command in Headless Chrome. Specifically, I have been trying to click on an Anchor (a) element with a href tag, and despite trying various suggestions found in dif ...

What is the best method for inputting keys into a search box element using Selenium-Java?

Here is the method I have implemented for sending keys within my parent class: public void sendKeysFunction(WebElement element, String value) { waitUntilVisible(element); scrollTElement(element); element.clear(); element.sen ...

Navigating through the cookie clutter: The ultimate guide to clearing Internet Explorer cookies for Selenium automation

Our automation process involves using the IE browser with Selenium webdriver. To ensure that our test cases start from page 1, we need to clear the cookies from the Registry beforehand. Can you assist me in accomplishing this task? ...

Encountering org.openqa.selenium.firefox.NotConnectedException while using Selenium Java 3.0.1 with Firefox version 51.0.1

Encountering org.openqa.selenium.firefox.NotConnectedException while using selenium java 3.0.1 with firefox version 51.0.1. Attempting to utilize the Gecko driver. This is my code public class Gecko { String driverPath = "/home/hema/Downloads/Softwa ...

Is there a way for me to utilize driver.find_element_by_id without having to utilize driver = webdriver.Chrome()?

Is there a way to utilize driver.find_element_by_id method in Selenium with Python without explicitly defining the Chrome WebDriver? import time from selenium.webdriver.common.keys import Keys from selenium import webdriver from selenium import selenium ...

determining a precise match with Selenium through text-based criteria

Suppose I have a piece of HTML that looks like this: <span class="select2-selection__rendered" id="select2-plotResults-container" role="textbox" aria-readonly="true" title="50">50</span> Now, if I want to locate it using a method similar to ...

Issue with setting capabilities in Firefox Selenium causing user agent to remain unchanged

This code was functioning smoothly, however, upon transitioning from Chrome to Firefox, it has started throwing an error. I am seeking assistance in resolving this issue FirefoxOptions options = new FirefoxOptions(); options.addArguments("--incog ...

Encountering difficulty logging in using python selenium due to the error message "NoSuchElementException error

I've attempted to find the submit button using both id and xpath, but none of them seem to work. I double-checked in the page source and confirmed that the id is correct. It's puzzling why this issue persists even when providing the accurate id o ...

"Encountering a strange issue where submitting a form with Jquery and AJAX in Rails does not work as expected, causing the index

Currently facing a unique issue with a jQuery/Ajax HTML update form. The application in question is a single-page TODO App that utilizes a Rails controller, where all changes to the DOM are made through jQuery/Ajax. After rendering the TODOs on the page v ...

Guide to automatically running a Chrome extension that interacts with the main webpage?

I am looking for a way to automate testing for a specific chrome extension. While I have successfully used selenium-python to automate tasks on the parent web-page, I am facing a challenge automating the chrome-extension itself. Selenium is not designed t ...

Using Python with Selenium to interact with a "disabled" input field on a website (specifically Bet365)

In my quest to simplify my sports betting process, I am looking to automate the filling of stake and clicking "place bet". So far, I have successfully automated the login, match/bet type search, and selection. However, sending keys to the stake input field ...

Locating and Exiting a Popup Box in Firefox with Selenium and C#

Problem: I am encountering issues with my Selenium script where it is unable to recognize and close a dialog box that appears when redirecting to a URL containing a file download. The dialogue box in question can be seen in the attached image. Despite ded ...

Guide to selecting an element with a combination of text and a random number using Selenium with JavaScript

<a id="Message4217" class="btn-sm btn-danger Message" data-id="4217"><span class="icon-adjustment icon-trash"></span> Delete</a> The objective is to remove a message base ...

I am encountering issues with Selenium not functioning properly on Windows 10 when using the syntax driver.findElement(By.cssSelector

I'm encountering problems with the CSS selector while using Selenium on Windows 10. It appears that the tag is incorrect. How can I resolve this issue? import java.util.concurrent.TimeUnit; import org.openqa.selenium.By; import org.openqa.selenium.By ...

What is the best way to utilize Selenium alongside Python3 and xpath to interact with an image within an html table?

Is there a way to utilize Selenium with Python3 and xpath in order to click on an image within an html table? The specific webpage I am referencing is: . The image I am attempting to click on using Selenium is the green plus sign that appears when a pdb co ...

What is the process for running selenium-based tests/scripts for an enterprise project or application?

One fundamental question that arises is how Selenium scripts are executed in an enterprise/project/application. These scripts are typically written in Java using locators and various tests are created. The tests are organized through TestNG and can be run ...

What are some effective ways to switch proxies in order to bypass CAPTCHA when conducting web scraping?

Recently, I created a Python script that utilizes Selenium for web scraping purposes. This script is designed to run for extended periods of time. Initially, I managed to scrape data from a specific website successfully by cycling through a pool of 1,000 d ...

What steps should I take to address a situation in which a Protractor test becomes stuck indefinitely?

I've encountered an issue with a test case that was previously running successfully but is now getting stuck indefinitely during execution. This problem occurs each time the test attempts to click on a specific element, causing the test to hang withou ...

I am in search of understanding the criteria for determining when an ISearchContext can be considered

I've been scouring different sources for information on this particular topic, and while I did find a similar answer here, I'm looking for a bit more detail. Here's my code: var element = myWebDriver.FindElement("User_Login"); var finalele ...