Guide to finding the alert tag element within the outer div container

When trying to locate elements on this particular page and place them in Objects (DomElement) for testing purposes, I encountered an issue with the reg-error-yid element. This element is nested inside the yid-field-suggestion div, and despite my attempts to use getElementById, byName, byXPath, getFirstByXPath, as well as changing from webClient to WebDriver and utilizing

driver.findElement(By.className("oneid-error-message"))
, none of these methods proved successful.

The registered message element:

<div id="reg-error-yid" class="oneid-error-message" data-error="messages.IDENTIFIER_EXISTS" role="alert">A Yahoo account already exists with this email address. <a href="https://login.yahoo.com/?intl=xa&amp;lang=en-JO&amp;src=ym&amp;.intl=xa&amp;specId=yidReg&amp;.done=https%3A%2F%2Fmail.yahoo.com&amp;nr=1&amp;step=2&amp;.crumb=qP.UnkGzfkR&amp;login=abtallaldigital">Sign in</a>.</div>

My code snippet:

final HtmlPage page1 = webClient.getPage("https://login.yahoo.com/account/create?specId=yidReg&lang=en-JO&src=ym&done=https%3A%2F%2Fmail.yahoo.com&display=login&intl=xa");

             final DomElement firstName = page1.getElementById("usernamereg-firstName");
             final DomElement emailAddress = page1.getElementById("usernamereg-yid");
             final DomElement takenMsg = page1.getElementById("reg-error-yid");

Answer №1

I'm uncertain about what you're looking for. Unfortunately, I can't provide any input at this time.

However, if you're attempting to analyze the document, you may want to consider using Jsoup for that purpose.

The select method is often more convenient and straightforward compared to using getElementById, byName, byXPath.

org.jsoup.nodes.Document doc = Jsoup.connect("https://login.yahoo.com/account/create?specId=yidReg&lang=en-JO&src=ym&done=https%3A%2F%2Fmail.yahoo.com&display=login&intl=xa").get();
org.jsoup.select.Elements takenMsgs = doc.select("div[id=reg-error-yid]");
org.jsoup.select.Element takenMsgFirst = doc.select("div[id=reg-error-yid]").first;

You might explore the possibility of converting org.jsoup.select.Elements to

com.gargoylesoftware.htmlunit.html.DomElement

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 values into keys and vice versa in JavaScript: A comprehensive guide

I have an array of Objects where I want to convert the first value into a key and the second value into a value. Please review the question below along with my desired output: [ { "name": "Unknown", "value": "R ...

Passing parameters to jQuery and Ajax functions is not supported in HTML JavaScript

My HTML login code seems to be experiencing issues when I pass 'formID' and 'divID' as parameters in a JavaScript & jQuery function. <?php session_start(); <html> <head> <script src="js/jquery.min.js">< ...

Transform the string property extracted from the API into a JSON object

When making a request to an API, the data returned to the front end is in the following format: { name: 'Fred', data: [{'name': '"10\\" x 45\\" Nice Shirts (2-pack)"', 'price' ...

Creating a personalized audio player using HTML

I have created a design for an audio player that I would like to implement using the HTML audio player element. https://i.sstatic.net/vJpGg.jpg When I tried <audio></audio>, it just displayed the default player: https://i.sstatic.net/nyNj8.j ...

Video playback disabled on hover in Chrome browser

I have added videos to a search results page. When the user hovers over the video, I want to show a preview of it in a separate container and start playing the video. $(".videoSearchResults video").mouseenter(function () { var container = document.cre ...

Exploring the dynamic attributes of an Object in React

My task involves checking for the presence of a placeholder in the "all" string within the alertDetails object. I specifically need to access the email, sms, and fax properties which are generated dynamically based on user input (this code is part of an al ...

Watching the Event Emitters emitted in Child Components?

How should we approach utilizing or observing parent @Output() event emitters in child components? For instance, in this demo, the child component utilizes the @Output onGreetingChange as shown below: <app-greeting [greeting]="onGreetingChange | a ...

Javascript is experiencing a decrease in the variability of its content

I currently have multiple pages structured like this: <body> <table><tr><td align="center" width="100%"> --PAGE HTML-- </td></tr></table> </body> For a temporary period, I need to change the str ...

Having difficulties executing the jacoco code coverage tool

I am working on a Maven project (link) and I need to perform code coverage analysis on it. After running the command mvn test -Pcoverage jacoco:prepare-agent jacoco:report on the main project pom file, I encountered an issue where the code coverage report ...

Styling elements using the nth-child selector in JavaScript

I am trying to apply a CSS class based on the combined height of the 2nd and 3rd child elements. For example, if the height of the 2nd child plus the height of the 3rd child equals a certain value, I want to add a specific class. Here is my JavaScript cod ...

The onKeyUp event in Material-UI components does not seem to be functioning as

I am experiencing an issue with a material-ui component Grid where the onKeyUp event does not seem to be triggering as expected. Here is the code snippet: <Grid item xs={12} onKeyUp={handleClickOnKeyUp} sx={{cursor: "pointer"}} onClick= {ha ...

Troubleshooting connection timeout issues with Spring's RestTemplate feature

I'm currently working on setting up a timeout for an external web service call. I am using Spring Rest Template to make the call within my service. For testing the connection timeout, I have intentionally stopped the external web service and brought ...

Creating a structure for a nested JSON object in TypeScript

I'm working with a nested JSON object and defining an interface for it. interface Menu { [key: string]: string[] | Menu; } const menuRoles: Menu = { site: { only: [], category: { only: ['manager', 'h ...

Exploring the world of backgrounds in THREE.js

My objective is to overlay 3D objects onto a panorama. I have successfully positioned the objects with the correct perspective, but now I am seeking a method to incorporate a useBackground shader similar to those found in software like Maya and Max into th ...

A guide to implementing bounds with dynamic markers in react-leaflet

I have a functional react component that currently displays two static markers within a bounding box that fits both markers inside. However, I am trying to figure out how to pass an array of latitude and longitude values to dynamically display the markers ...

Is there a way to block form submissions for users who have disabled JavaScript?

Our inquiry form mandates users to input basic information such as their name, location, contact details, and a comment or question. Unfortunately, we have been receiving numerous incomplete forms where essential fields are left blank. It has come to our ...

Sending a Variety of Data to PHP: A Guide to Posting Multiple Data Types

Struggling with a dilemma at the moment, Currently, I am successfully sending JSON data to a PHP page, but I also need to include a variable in the same post request and I'm unsure of how to do so. Below is the code I'm currently using: $.ajax ...

Show two columns horizontally using JavaScript

Hey, I'm working on a project where I need to display data from an array in an HTML output table. However, I'm facing an issue with displaying the table on the same page after clicking the submit button. Using document.write redirects me to anoth ...

Remove properties that are not part of a specific Class

Is there a way to remove unnecessary properties from the Car class? class Car { wheels: number; model: string; } const obj = {wheels:4, model: 'foo', unwanted1: 'bar', unwantedn: 'kuk'}; const goodCar = filterUnwant ...

Challenges arise with CSS alignment when adding d3.js charts to a webpage

I'm puzzled by the empty space that appears between the left column (highlighted in the image) and the header. This peculiar gap only seems to occur when the middle column is filled with a chart. I've scrutinized the code using Chrome Developer t ...