Using selenium for testing JavaScript elements through RSpec results in failures in other segments of the RSpec test

Trying to implement Stripe into my web application has brought me to a frustrating roadblock. Every attempt to test the "Pay with Card" button seems to be thwarted by an ElementNotFound error thrown by rspec.

Research revealed that the root cause of this issue was due to the default driver, rack_test, lacking Javascript support. To address this, I consulted some documentation at https://github.com/jnicklas/capybara#drivers and included :js => true in one of my RSpec scenarios, along with adding the selenium-webdriver gem to my gemfile.

Unfortunately, these adjustments unveiled a new hurdle. Now, during testing, I receive an error indicating an invalid username/password combination, preventing me from advancing to verify if I can successfully click the elusive button! It appears that Selenium is struggling to recognize or validate my user factory.

Frustrated gesture.

Any guidance on overcoming this would be greatly appreciated.

spec/features/user_upgrade_premium_spec.rb:

require 'rails_helper'

describe "Upgrading from Standard to Premium Plan" do
    before do
     @user = create(:user)
     visit root_path
     click_link "Sign In"
     fill_in 'Email', with: @user.email
     fill_in 'Password', with: @user.password
     click_button "Sign In"
     expect(page).to have_content "Signed in successfully."
  end

  scenario "Successful Upgrade", :js => true do
    click_link "My Account"
    click_link "Upgrade Account"

    click_button "Pay with Card"
 

Answer №1

Experiment with the script_timeout setting in the Timeouts section, along with implicit_wait and page_load. Define it on a global level and observe its impact on our current situation!!

@driver.manage.timeouts.script_timeout = 15

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

Tips for correcting a React (functional component) error: "Signup Error: TypeError: Cannot read properties of null (reading 'protocol')"

My partner and I successfully developed a complex multi-step registration form that displays all user input data at the end. However, when the user tries to submit the form to create their account, an error occurs with the message "Signup Error: TypeErro ...

The process of obtaining and sending a token from an HTML page while submitting a form request to a Laravel 5 application involves a few key steps

My application consists of the client side being written in HTML and Angularjs, while the server-side is using Laravel 5. Every time I submit my form, I send the models using $http to a route in my Laravel 5 app, but I continuously encounter the error: pr ...

Working with AngularJS: binding data to dynamically appended HTML elements using JavaScript

Is there a way to connect an angular event and model to an html element that is added through javascript code? To see my code, click here: https://jsfiddle.net/hq7qk48n/13/ <div ng-app> <div ng-controller="MyController"> <input ...

Oops! The connection timed out while trying to format the error in SMTPConnection

Encountering an error with a connection timeout while trying to send emails using nodemailer. Seeking assistance as the console keeps showing this error message: Error: Connection timeout at SMTPConnection._formatError (/home/codabae/Desktop/mailmonster/B ...

Guide on transforming a JSON string into an array of custom objects using the json2typescript NPM module within a TypeScript environment

I am looking to utilize the json2typescript NPM module to convert a JSON string into an array of custom objects. Below is the code I have written. export class CustomObject { constructor(private property1: string, private property2: string, private p ...

Display only the labels of percentages that exceed 5% on the pie chart using Chart JS

I'm currently diving into web development along with learning Chart.js and pie charts. In my project, the pie chart I've created displays smaller percentage values that are hardly visible, resulting in a poor user experience on our website. How c ...

Whenever data is extracted from an Excel sheet using the def function in Python, the output is displayed within a combination of single and double quotes, as well as square brackets

Every time I use a def function in Python Selenium to extract data from an Excel sheet, the output comes wrapped in single or double quotes ("" , '', []). This is not the format I want for my output. Even when I try to read data from an Excel sh ...

Using <span> tags to wrap sentences within <p> tags while maintaining the rest of the HTML formatting

In order to achieve my goal, I have utilized the following code to extract content within tags and encapsulate each sentence in tags for easier interaction. $('p').each(function() { var sentences = $(this) .text() ...

unable to successfully npm install canvas

For my GitHub repository, please visit here This project was actively developed until November of last year, after which I did not commit any changes. Today, I attempted to run the project again but encountered the following error. My current system versi ...

The functionality of the Bootstrap dropdown or radio input type is not functioning correctly

I'm currently utilizing electron([email protected]) along with bootstrap([email protected]). Whenever I attempt to incorporate a dropdown or other components from Bootstrap, they simply do not function. I am unsure of what mistake I might ha ...

By default, the select option in AngularJS will have a value of either an object or null

This block of code is located in the js file: $scope.ListOption = []; $scope.ListOption.push({ Value: "0", Name: Car }); $scope.ListOption.push({ Value: "1", Name: House }); Below is the corresponding HTML code: <select class="form-control" id="Categ ...

When utilizing Selenium, the Chromium-based browser fails to navigate to a new URL

I have developed a basic WFA chromium-based browser. While connecting it with Selenium, the browser opens but fails to navigate to a new URL. The command window displays the following. How can I manipulate the chromium-based browser similar to using the ch ...

I'm having issues with my countdown timer

Here is some of my JavaScript code: var run; var countdown; var count =14; var curImage = 1; function startAdPage() { run = setInterval("changeAd()"5000); countdown = setInterval("startCountdown()",1000); } function changeAd { switch (curImage) { case 1: ...

Tips on incorporating selenium with scrapy for streamlining tasks

I recently learned that using web toolkits like Selenium is necessary for automating web scraping. How can I automate clicking the next button on Google Play Store to scrape reviews for my college project? import scrapy from scrapy.contrib.spiders import ...

selenium pause until webpage is fully loaded with flash animation

I am trying to capture a screenshot of a webpage that contains flash content. Here is the code I am using: ChromeOptions options = new ChromeOptions(); IWebDriver driver = new ChromeDriver(options); ... // Clicking on a button that opens a new browser wi ...

Allow AngularJS to make HTTP POST requests with CORS enabled

I am looking to submit a form to send an HTTP POST request to a server located on a different domain, with CORS enabled in the server script using Node.js. Below is the Angular configuration script: var myApp = angular.module('myApp', ['ng ...

JavaScript isn't functioning properly after UserControl is loaded via Ajax

Thank you, Stilgar for helping me solve my issue. I created a javascript file and placed all my code in it. After adding this file to the UserControl and retrieving the UserControl's html, I used $("#DivID").html(UserControlHTML). Now everything is wo ...

Attempting to implement form validation on my website

Recently watched a tutorial on basic form validation on YouTube, but I'm encountering an issue where the error messages from my JavaScript file are not displaying on the website during testing. I have set up the code to show error messages above the l ...

Looking to verify characters, numbers, and special characters with jQuery's regular expression feature?

Currently, I am facing a challenge in validating the password field to allow characters, numbers, and special characters. It is essential that the password consists of exactly 8 characters. Despite searching online for a solution, I have been unsuccessful ...

Utilizing Angular 2 for Integration of Google Calendar API

I recently attempted to integrate the Google Calendar API with Angular 2 in order to display upcoming events on a web application I am developing. Following the Google Calendar JavaScript quick-start tutorial, I successfully managed to set up the API, inse ...