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

Having trouble getting the items to show up on the canvas

I have been struggling to implement JavaScript on a canvas in order to display mice in the holes using the mouse coordinates. Despite trying many different methods and spending close to a month on this project, I still can't seem to get it to work acr ...

What is the best way to display multiple modals in a React app?

I am facing a challenge where I need to render multiple modals based on the number of items in the 'audios' property of an object. Currently, I am using the mui modal library for this functionality. Here are the variables being utilized: const ...

Traversing through links within multiple tabs using Python Selenium and Chrome

Hey there, I'm currently dealing with a situation where my main web page opens in the main tab to accept cookies, while the rest of the links are supposed to loop through and open in separate tabs: links = ['https://www.deviceinfo.me/',&apos ...

Implement a jQuery loop that utilizes the fadeIn effect

Currently, I have a basic jQuery function in place to generate a small image slider: function gridhover() { $(".grid-item .slide-image").each(function(index) { $(this).delay(400*index).fadeIn(300); }); } $( ".grid-item" ).hover(function() ...

How can you include the product price in the cart using the URL on WooCommerce?

After some exploration, I discovered that I can easily add items to my cart using a specific URL: http://yoururl.com/cart/?add-to-cart=ID Although I was able to figure out how to include quantity and attributes in the link, I have not been able to determ ...

Extract all potential outcomes from a search field that has a restriction on search results

Looking to extract all the names from a specific website using Python: Encountering an issue where it only fetches the top 50 results for each search. Experimented with wildcard searches in the last name field to narrow down subsequent searches, but this ...

What is the best way to retrieve an object from a POST request using Angular AJAX calls in a NODEJS environment?

When the button is clicked, a method will be called. The code for this is as follows: .controller('templeDetailsList', function ($scope, $http, $ionicModal) { $scope.starclick = function(){ var newFav = [{ ...

Implementing siteSpeedSampleRate in Google Analytics with AngularJS - a step-by-step guide

I utilized the following link https://github.com/revolunet/angular-google-analytics to incorporate Google Analytics into my AngularJS 1.5 project. However, I'm having trouble setting the siteSpeedSampleRate. I injected the AnalyticsProvider and attemp ...

Sending requests across domains from HTTPS to HTTP with callback functionality, and reversing the process

Prior to our conversation, I had created it using Flash. I uploaded a special file (crossdomain.xml) on the server side (https), while the Flash component was placed on the http server. Although they belong to different domains on the https and http serv ...

Exploring the Usage of sessionStorage within the <template> Tag in Vue.js

Is it possible to access sessionStorage in the script section of a Vuejs component like this? <template> {sessionStorage} </template> Whenever I try to call it this way, I consistently receive the error message "cannot read property &apo ...

Substitute the ajax reply with the text currently displayed

I am facing an issue with the AJAX response in my HTML page. Currently, the response is being appended on top of the existing text instead of replacing it. Here is a snippet of my code: <html> <head> <h2>This is a test</h2> ...

Deciphering unidentified Json data

Having some trouble with an error in my note taker app built using expressjs. Everything was working fine until I tried to save a new note and it's throwing this error: SyntaxError: Unexpected token o in JSON at position 1 at JSON.parse () Here&apos ...

Adjust the size of the font in your Bootstrap Table

I've been utilizing the Bootstrap table feature and it's been fantastic, but I've encountered an issue with changing the font size. I've referred to the example on , however no matter what adjustments I make to the size, it doesn' ...

Modify CSS using Javascript by targeting the class of ".modalDialog > div {}"

I am currently working on a project that involves creating a Modal Layer using CSS. I have successfully implemented the modal layer, but now I need to figure out how to change the width from the default 400px to something else when I open it with Javascrip ...

Confusion surrounding the purpose of an AngularJS controller function

After experimenting with some basic tutorials in AngularJS, I came across a discrepancy in how controllers are declared and used. For instance, in this JSFiddle link - http://jsfiddle.net/dakra/U3pVM/ - the controller is defined as a function name, which w ...

How can I access a method from another JavaScript file (service) in React JS's App.js to make API requests?

Just starting out with React js and trying to utilize REST API data. I've created a separate file named /shared/job-service.js for this purpose. My goal is to call a method from job-service.js in App.js and display the results on the UI. However, I&ap ...

Rearrange the position of the customized google map marker to appear just above the latitude

Can you provide guidance on how to move a customized Google Map marker above a specific latitude and longitude point? You can view the code structure in this JSBIN: Link. I have used three object arrays for reference. Where should I insert the "anchor" i ...

React Error: Unable to iterate over this.state.descriptions

Currently facing an issue while trying to resolve this error https://i.stack.imgur.com/BZ304.png The goal is to generate an automated form using the following function: let descriptionsForm = ( <form> {this.state.descriptions.map((d ...

Positioning 3D objects in Three.js

I am working on a 3D Scene using Three.js with an Earth shape that currently looks like this: https://i.sstatic.net/zXWki.png My goal is to modify it to resemble something like this: https://i.sstatic.net/w4ypV.jpg The coloring, stars, and texture are ...

I am trying to figure out how to dynamically set the deployUrl during runtime in Angular

When working with Angular, the definition of "webpack_public_path" or "webpack_require.p" for a project can be done in multiple ways: By setting the deployUrl in the .angular-cli.json file By adding --deployUrl "some/path" to the "ng build" command line ...