Is it possible to use Selenium to interact with a button on a modal window?

I am attempting to automate the login process using chimpjs with cucumber and selenium, but I am encountering an issue due to the modal used for login. Every time I try to click on the login button within the modal, I receive the following error message:

 Error: unknown error: Element is not clickable at point (764, 42). Other element would receive the click: <div class="login-overlay " style="display: block; opacity: 0.969096;">...</div>

Despite taking the necessary steps in selenium to wait for the modal to appear before entering the username and password, clicking on the login button fails consistently.

module.exports = function() {
  this.Given(/^I am on the website homepage$/, function () {
    client.url('example.com');
  });

  this.When(/^I click the login button$/, function () {
    client.click('.navbar__link--login');
  });

  this.Then(/^I see the login screen$/, function () {
    client.waitForExist('.login-overlay');
  });

  this.Then(/^I enter my username in the email field$/, function () {
    client.setValue('#username', '<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="5835213d35393134183d35393134763b3735">[email protected]</a>');
  });

  this.Then(/^I enter my password in the password field$/, function () {
    client.setValue('#password', '<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="4b26322e262a22270b2e262a222765282426">[email protected]</a>');
  });

  this.Then(/^And I click the login button$/, function () {
    client.click('.login-btn');
  });

};

All steps pass successfully except for the final one. Could this be due to the use of a modal for login? Is there a specific way to click buttons within modals using selenium? Am I overlooking something obvious?

Solution: After struggling to click on the element directly, I discovered that I could perform a form submission using the client.submitForm(selector) method. This workaround resolved the issue, allowing me to pass the final step. Additionally, I updated the final step text to 'And I submit the login form' for clarity. More information on the form submit option can be found here:

Answer №1

It appears that the issue is related to an overlay element named "login-overlay" covering the control.

To address this, try hiding it:

client.execute("arguments[0].style.display = 'none';", client.element('.login-btn'));

This approach has not been verified yet.

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 through 2 identical iframes in Python Selenium with the same ID but different source URLs

I am facing a challenge trying to navigate to the iframe with the ID: "ifrBetslipHolder". There are two iframes with the same ID but different sources. Every time I attempt to switch to the iframe, I end up on the first one by default. Even when I use fi ...

Ensure that the assistant stays beneath the cursor while moving it

I am currently working on creating a functionality similar to the 'Sortable Widget', but due to some constraints, I cannot use the premade widget. Instead, I am trying to replicate its features using draggable and droppable elements: $(".Element ...

I successfully merged two arrays (decks of cards) without using recursion, but I'm curious to understand where I went wrong with the recursive approach

Currently, I am working on a function that shuffles two arrays together using recursion. The goal is to combine the top and bottom halves of a deck of cards into a single array with elements interleaved. For example: The first element should come from the ...

Verify the functionality of the input fields by examining all 6 of them

I'm facing a challenge with a validation function in my project that involves 6 input fields each with different answers. The inputs are labeled as input1 to input6 and I need to verify the answers which are: 2, 3, 2, 2, 4, and 4 respectively. For e ...

Issues with AngularJS email validation specifically related to domain names are causing errors

Hello, I'm currently working on an AngularJS application where I'm implementing email validation. I'm facing an issue where I expect an error message to appear when I enter 'test@test', but it's not working as intended. Here ...

When combining Socket.io 1.0 with express 4.2, the outcome is a lack of socket connection

According to the title, I am attempting to integrate socket.io 1.0.4 with express 4.2, but all requests with "/?EIO" are resulting in a 404 error. Below are my file configurations: ./bin/www : #!/usr/bin/env node var debug = require('debug')(& ...

Verifying the date displayed using Java in Selenium

I am attempting to retrieve the date in a specific format to validate if it follows MM/dd/yyyy HH:mm. I've attempted: element.getAttribute("value") but it returns "yyyy-MM-ddTHH:mm" which does not match the UI display. Furthermor ...

Ensure that the query is properly separated from the body when making an Axios request

While working on my code, I encountered an issue when making a PUT request to the backend of the application using Axios. The problem arose when the method in the user service, responsible for handling the request, returned a null response. Here is the met ...

Transfer both files and text strings to PHP using FormData

Is there a way to send strings to PHP using Ajax form data? I recently came across this code at . I am trying to figure out how to pass string data to PHP using the code provided above. I want to integrate this code into my website to enable users to upl ...

Screen boundary bouncing effect upon reaching the edge

Currently, I am working on an animated project using canvas. I have successfully implemented the functionality to control the image (ship.png) with the arrow keys for different directions. However, I am facing challenges with creating a bounce effect when ...

How can I iterate over items using v-for in VueJS?

Currently, I am facing an issue with using v-for to iterate through data containing titles and icons. While looping through the data, I can only obtain one icon at a time. My query is regarding how I can retrieve more than one icon during the loop. You ca ...

Obtaining the current value with each keystroke

While working with vue.js, I'm building a table that contains an input field called quantity. However, when I start typing the first word, it shows 'empty' on the console. If I type 3, it displays empty; and if I type 44, it prints 4. I am ...

File corruption during S3 uploads linked to streaming method

My recent project involved creating a chat server using rails, socket.io, and node where users can send images to each other. I have been attempting to integrate Amazon s3 into this system and below are the key code snippets from both the client and server ...

The intervals in hooks seem to be malfunctioning and not updating the date and time as expected

I am trying to continuously update the date and time every minute using React hooks. However, I am facing difficulty in updating the time properly. const Link = (props) => { let date = new Date(); const [dateTime, setDateTime] = useState({ cu ...

Enhance the navigational experience in Vue Router by eliminating the hash from specific

I implement Vue.js and the Vue Router. By default, URLs will have #/ added to them. However, I need certain pages to be served as PHP while others are rendered by the Vue Router. For Instance I would like the following scenarios to be functional: exam ...

How can I use jQuery to determine the total count of JPG files in a directory

How can I use jQuery to count the number of jpg image files in my document? Here is the command to count the image files: $('#div').html($('img').length ); However, this counts all image files with the 'img' tag. Is there ...

Unable to launch the Express application on a 64-bit Windows 7 operating system

After successfully installing Node for Windows/64bit and being able to run the server with an example from the Node homepage, I encountered an issue when setting up an Express app. Despite installing Express using the command npm install -g express and r ...

Dealing with alerts in selenium RC when a page is loading

When using my application, an alert pops up upon page load after visiting a specific page. I've attempted to handle this alert in Selenium RC by clicking on a button that redirects to a new page, checking for the presence of an alert, getting the aler ...

Managing a promise and using async/await functions

Having an issue with my node and express function router.post('/', async (req, res) => { const playlist = new Playlist({ song: req.body.song, artist: req.body.artist }) try { const newPlaylist = await play ...

Troubleshooting: Issue with revalidate functionality in NextJS getStaticProps

I'm working on a NextJS site that uses getStaticProps to fetch data from Firestore. My code looks like this: return { props: { allPosts: posts, }, revalidate: 60, } As far as I know, this should refresh the data from firebase eve ...