Automatically trigger the Submit button click with this selector

I'm having trouble automating the clicking of a 'Submit' button that only becomes clickable after a specific action is taken. In this case, the user needs to click the TOS checkbox before the button can be clicked. I've been unable to find a selector that allows me to automate the clicking of the Submit button. Once the Submit button is clicked, a confirmation window pops up.

My setup involves using Protractor as the test runner in Webstorm. The test currently passes, but the Submit button isn't actually being clicked and no new account is created. I want to add an assertion, but I need help locating the element so it can be clicked. Both XPath and CSS selectors don't seem to work when automation is initiated.

This is the code snippet I've been trying to modify:

element(by.xpath('//*[@id="formHolderId"]/div/div/div[3]/span/button[2]')).click();

Before checking the TOS checkbox, the Inspect Element displays the following:

<button data-ng-click="modalOptions.ok(formData)" data-ng-disabled="formHolder.$invalid || formHolder.formHolder.$invalid" data-ng-if="modalOptions.actionButtonText" type="submit" class="btn btn-sm btn-submit ng-binding ng-scope ng-click-active" disabled="disabled">
        Submit</button>

After checking the TOS checkbox, Inspect Element shows:

<button data-ng-click="modalOptions.ok(formData)" data-ng-disabled="formHolder.$invalid || formHolder.formHolder.$invalid" data-ng-if="modalOptions.actionButtonText" type="submit" class="btn btn-sm btn-submit ng-binding ng-scope ng-click-active">
        Submit</button>

Even though the Submit button has disabled="disabled" attribute when the TOS checkbox is unchecked, I'm still unable to make it clickable one way or another.

Answer №1

To activate the button, check the TOS box first and then find it by text and click on it:

var submitButton = element(by.xpath("//button[contains(., 'Submit')]"));
submitButton.click();

If you are unable to activate the button for any reason and cannot click on it using element.click(), you can imitate the click by running javascript:

browser.executeScript("arguments[0].click();", submitButton.getWebElement());

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

Converting the jQuery $.xajax loadmore feature into a custom XMLHttpRequest JavaScript function

I'm facing challenges while trying to create a XMLHttpRequest loadmore function as compared to using $.ajax. I am uncertain about what I might be missing in my code. Below is the function that is based on a previously working $.ajax version that I ha ...

What causes Selenium ITakeScreenshot to capture a black screen from an IE window?

While working with a Class Library.dll that contains SpecFlow tests written in C# / Selenium, I encountered an issue where using the standard code to capture a screenshot resulted in just a black window. This was puzzling as previous builds and .dll files ...

Keep the footer at the bottom of the screen without needing to define a 100vh in Material UI

In the process of developing my react app with MUI framework, I encountered various challenges in creating a sticky footer at the bottom of my screen. After exploring different solutions, one approach that I found most satisfactory is as follows: export de ...

Sending Data from Browser to Node.js using Ajax

I've been struggling to send an AJAX post request to my Node server built with Express for a while now. Despite reading various solutions on similar issues, I couldn't figure out which files to edit. Initially, I attempted using `http.createServe ...

Launching an embedded webpage in a separate tab within the main browser window

In my current setup, I have implemented an iframe within the main window. The iframe includes a form where users can input data and submit it. Currently, I achieve the submission with the following code: var openURL = '/results/finalpage'; windo ...

ReactJS and JavaScript offer a convenient solution for extracting the most recent date from an array of date fields during the selection process

I have a table in ReactJS that displays an array of items. Each item has the following fields: id, requested_date, and location Additionally, there is another field called "date" which is located outside of the array. This "date" should always display th ...

Error message: "Issue encountered with locating Node import module while operating within a docker

I've created a React app along with a Node.js server that includes the following imports: import express from 'express' import compression from 'compression' import cookieParser from 'cookie-parser' import bodyParser from ...

Seamless changes with graceful fades while transitioning between classes

Is it more efficient to handle this in CSS than using jQuery? I'm not entirely sure. If anyone has a solution, that would be greatly appreciated. However, I am currently facing an issue with the jQuery method I have implemented. It successfully fades ...

Creating multiple instances of an object

When using Javascript, I am trying to create an object in the following way: var testObject = { value: "this is my initial value", setup: function() { value: "foo" } }; Now, my goal is to instantiate this object and have different val ...

Automate Citrix web tasks using Selenium or similar tools for efficient and streamlined processes

Are there any methods for implementing selenium or a similar tool on Citrix web systems? I have been relying on pyautogui, but it seems to be quite ineffective by itself. Any suggestions on how to enhance pyautogui would be greatly appreciated. ...

Guide on adding markers using Google Maps API based on specific criteria

Hi there, I need assistance in developing the following requirements. In my database, there is parking lot information. Let's say each parking lot has two attributes: id and address. Via a spring controller, I am passing a list of parking lots t ...

The collapsible list feature that includes the use of plus and minus signs is malfunctioning

Below is the script that I wrote to address this issue, but for some reason the + and - swapping is not functioning correctly. $('.showCheckbox').click(function(e) { var dynamicBox = $(this).attr('val'); var collapseSign = $(th ...

How can I add divs to an HTML page with a Javascript animated background?

I am currently facing an issue with my JavaScript animated background, consisting of just 3 pictures. I am trying to display some Div elements on it with content inside. Here is the code snippet I have right now: In my CSS file, I have defined styles for ...

Having difficulty positioning the dropdown above the other elements in the body

Below, you'll notice that the dropdown menu isn't positioned correctly over other body elements like the timer. I'm utilizing bootstrap for the dropdown and redcountdown js for the timer. Here is the HTML: <div class="col-md-6 m-t-1 ...

Exploring network performance using Chrome DevTools

I am currently using version 4.0.0-alpha5 of the Selenium Webdriver NuGet package. The code I have only seems to work when the DevTools are open in Chrome Version 98, which confuses me. It should technically work regardless, but it consistently only works ...

The D3.js text element is failing to show the output of a function

I'm having an issue with my chart where the function is being displayed instead of the actual value. How can I make sure the return value of the function is displayed instead? The temperature values are showing up correctly. Additionally, the \n ...

Locate the element using xpath with a dynamic variable included

I am looking to extract the 'Code' information from . The xpaths for 'Code' are listed below: ABP //*[@id="post-2"]/div/table/tbody/tr[1]/td[1] AX1 //*[@id="post-2"]/div/table/tbody/tr[2]/td[1] It's noted that the xpath patter ...

"Silent Passageway: Connecting Node JS to ASW RDS MySQL Through a Secret

I am currently collaborating on a project with a partner. The backbone of our project is node js, and we are using an AWS RDS MySQL DB for our database. Our main challenge lies in establishing effective communication with the DB through SSH within NodeJS. ...

Conceal dynamically generated div elements created with ngIf

I am currently working on initializing this div using ngOnInit in Angular ngOnInit(): void { let optTemp = ''; for (let data of arrOption) { optTemp = optTemp + '<option>' + data.trim() + '</option> ...

Executing a series of HTTP requests sequentially using Angular 5

I need some guidance on sending an array of HTTP requests in sequential order within my application. Here are the details: Application Entities : Location - an entity with attributes: FanZone fanZone, and List<LocationAdministrator> locationAdmins ...