How can Codeception/Selenium help in testing the tooltip or customValidity message?

I am trying to implement a feature in my Codeception scenario where I want to validate a form submission with user errors, such as confirming a wrong email address, and display a custom tooltip message in the browser.

HTML

<form ... >
    <label>Email *</label>
    <p>
    <input type="email" name="email" id="email placeholder="Please insert your email" required="1" autocomplete="off" />
    <input type="email" name="email_r" id="email_r" placeholder="Please confirm your email" required="1" autocomplete="off" />
    </p>
</form>

JS

MyPlugin.checkMatch = function (idInputReferring, idInputRepeat){
   var inputReferring = document.getElementById( idInputReferring );
   var inputRepeat = document.getElementById( idInputRepeat );
   if (inputReferring.value !== inputRepeat.value) {
        inputRepeat.setCustomValidity( "It must match the previous input" );
        inputRepeat.checkValidity();
        setTimeout(function() {
        inputRepeat.reportValidity();
        }, 1);

    } else {
        inputRepeat.setCustomValidity('');
        inputRepeat.checkValidity();
    }
};

How can I achieve this functionality?

Answer №1

To retrieve the tooltip error message, you can access the validationMessage attribute of the input element.

Answer №2

Here is one approach to check for the validity of a browser tooltip:

$I->executeJS('return document.getElementById("email_r").validity.invalid;');
$I->executeJS('return jQuery("#email_r").validationMessage === "It must match with the previous input"');

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

How should callbacks be established for communication between a React app and an iframe using postMessage?

I'm encountering an issue with my website's communication with a third-party iframe. The site has three methods - login, sign, and get information - all functioning in a similar manner. I embed the third-party iframe and send a message to it usin ...

What is the best way to sort and organize JSON data?

Upon successful ajax call, I receive JSON data structured like this: var videolist = [ { "video_id": 0, "video_name": "Guerrero Beard", "timelength": 15 }, { "video_id": 1, "video_name": "Hallie Key", "timelength": 8 }, { ...

Sequentially loading Bootstrap columns as the page loads

Is there a way to load columns one by one with a time gap when the page is loaded? Here's the code snippet that can achieve this: setTimeout(function() { $("#box1").removeClass("noDisplay"); },1000); setTimeout(function() { ...

The jQuery datatable offers a convenient date function that allows for date manipulation in milliseconds format

Recently, I have been working on updating the task owner ID using a lookup field selection in my code. The tasks are displayed based on the selected date from a datepicker value under the query in the controller. However, I encountered an issue where the a ...

Is it possible to execute JavaScript within an Android application?

Is there a way to utilize the javascript provided by a website on an Android device to extract and analyze the emitted information? Here is the javascript code: <script type="text/javascript" src="http://pulllist.comixology.com/js/pulllist/5b467b28e73 ...

Angular: merging animations with scope updates

If you're curious to see some code, check it out here: some code My inquiry pertains to using Angular to blend a change in data triggered by a click with a fade in/fade out animation. I've managed to implement content changes on click and anima ...

`Generating an ever-changing masonry layout on a website using live data`

I'm currently working on a new web project and I want to incorporate a masonry view for the images on the homepage. The plan is to host this project on Azure, using blob storage for all the images. My idea is to organize the images for the masonry vi ...

The method piSession.buildPageInteractionSession is not valid

Hey there! I am facing an issue with a simple AJAX call to a PHP file. The request should be sent to the server and return back in an HTML input field. Unfortunately, I have not been able to resolve this error so far. Below is the code snippet: HTML: ...

What strategies can be employed to minimize redundant re-rendering of React components while utilizing the useEffect hook?

Hey everyone, I'm facing a challenge in my React/Electron project where I need to minimize renders while using the useEffect hook to meet my client's requirements. Currently, I have a container/component structure with an index.js file that house ...

How can I use Selenium to verify if the data I input into the search button is being displayed on the webpage?

While attempting to choose a value from a dropdown using a selenium script, an error was encountered in the console stating: "Exception in thread "main" enter code here org.openqa.selenium.support.ui.UnexpectedTagNameException: Element should have b ...

What is the reason for Backbone including model details within {model: {model_property: value,...}} when saving a model?

I am currently developing an application using node.js and backbone.js. However, I have encountered an issue where saving a model results in the JSON being nested inside a model dictionary. node = new NodeModel({prop1:"value1", prop2:"value2"}); node.save ...

Encountered an unusual occurrence where the service for /content/chromedriver exited unexpectedly, resulting in a status code of -6 while utilizing ChromeDriver in Google Colab with

Recently, I attempted to use headless Chrome browser with Selenium for web scraping purposes. I downloaded the headless Chrome browser using wget and unzipped it in my working directory. !wget "http://chromedriver.storage.googleapis.com/2.25/chromedriver_ ...

Add both single (' ') and double (" ") quotes within the `document.querySelector` code

Given an array of attributes like the following: let elementsArray = [ '[name="country_code"]', '[name="user_tel_code"]', '[name="countryCode"]' ]; If I aim to iterate through them using a ...

Error in three.js: Attempting to access the 'rotation' property of an undefined object

As I try to animate a cube in my scene, I keep encountering an error that reads: "TypeError: Cannot read property 'rotation' of undefined." function animate() { requestAnimationFrame( animate ); render(); } ...

Generating consecutive numerical values within the auto table JSPDF column VusJs

columns: [ { header: 'No', dataKey: 'Index', }, { header: 'No Registrasi', dataKey: 'no_register' }, { header: 'Kode Partai', dataKey: 'kode_partai' }, ...

Retrieving a compilation of items found within text selected by the user on a website

Imagine a scenario in which a webpage contains the following structure: <p> <span class="1">Here's some text</span> <span class="2">that the user</span> <span class="3">could select.</span> </p> I ...

Tips for selecting and utilizing a drop-down menu in JavaScript

Having an issue with the drop-down list functionality. It seems to only work with the first option selected and not with all of them. Any assistance would be greatly appreciated. Thank you in advance. var form1 = document.getElementById('form1' ...

Enhance the functionality of Woocommerce email notifications by incorporating a customized VAT field

I have exhausted all options and tried various email hooks without success. I inherited an outdated PHP code that was developed by someone else, which I updated for new woocommerce hooks (since the code is 4 years old). Everything is functioning smoothly e ...

Run a chunk of HTML with dynamic PHP elements using JavaScript

Within a single .php file, there is a combination of HTML, PHP, and JavaScript. The JavaScript section is crucial for detecting the browser; if the browser is not Internet Explorer, JavaScript will trigger the HTML block containing PHP. Here is the JavaS ...

Using CSS to position elements absolutely while also adjusting the width of the div

In one section of my website, I have a specific div structure. This structure consists of two divs stacked on top of each other. The first div is divided into two parts: one part with a width of 63% and another part with a button. Beneath the first div, t ...