The exception org.openqa.selenium.NoSuchElementException occurs when the specified element cannot be found on the web page

I can't seem to find the correct xpath or locate this element using Selenium. I keep getting this error:

FAILED: homeLoan("John Smith", "[email protected]", "Australia", "1563", "62365896410", "Home Loan", "Buying", "100000", "50000") org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element: {"method":"name","selector":"FullName"}

Here is my Selenium code:

@Test(dataProvider="homeLoan")
public void homeLoan(String fullname, String email, String countryTypes, String postcode, String phone, String loanType, String loanPurposes, String securityValue, String homeLoanAmount) throws Exception {
    // open | https://test-www.loans.com.au/
    driver.get("https://test-www.loans.com.au/");
    // click | link=contact | 
    driver.findElement(By.linkText("contact")).click();
    // type | name=FullName
    **driver.findElement(By.name("FullName")).clear();
    driver.findElement(By.name("FullName")).sendKeys(fullname);**
    // type | name=Email
    driver.findElement(By.name("Email")).clear();
    driver.findElement(By.name("Email")).sendKeys(email);

The html structure suggests that the element I'm looking for might be inside an iFrame:

<body style="overflow:hidden;" onload="iframe_resize();">
<div class="UWP">
<section of HTML>
**<input class="form-control inputbox bg-icon-name" placeholder="Full Name*" data-bind="attr: { name: FieldPrefix() + 'FullName' }, value: FullName, enable: ShowCustomerDetails" required="required" name="FullName" type="text"/>**
<section of HTML>

The highlighted HTML code above is where I need to identify the xpath.

If anyone can provide assistance, it would be greatly appreciated. Thank you in advance.

Answer №1

If you want to find elements, make sure to switch to the frame first before attempting to locate them. Here's an example:

driver.switchTo().frame("UWPIFrame");

Your code should be structured like this:

@Test(dataProvider="homeLoan")
public void homeLoan(String fullname, String email, String countryTypes, String postcode, String phone, String loanType, String loanPurposes, String securityValue, String homeLoanAmount) throws Exception {
    // open | https://test-www.loans.com.au/
    driver.get("https://test-www.loans.com.au/");
    // click | link=contact | 
    driver.findElement(By.linkText("contact")).click();
    //Switch to the frame 
    driver.switchTo().frame("UWPIFrame");
    // type | name=FullName
    driver.findElement(By.name("FullName")).clear();
    driver.findElement(By.name("FullName")).sendKeys(fullname);
    // type | name=Email
    driver.findElement(By.name("Email")).clear();
    driver.findElement(By.name("Email")).sendKeys(email);

Just keep in mind, if you need to locate an Element outside of the iframe, remember to switch back to the default content by using this:

driver.switchTo().defaultContent();

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

It appears that the jQuery this() function is not functioning as expected

Despite all aspects of my simple form and validation working flawlessly, I am facing an issue where 'this' is referencing something unknown to me: $('#contact').validator().submit(function(e){ e.preventDefault(); $.ajax ...

What is the alternative name for DOM elements in TypeScript?

When working with a HTMLImageElement, I can simply reference it like this: let image: HTMLImageElement; ... In Dart, importing the dom is possible using: import 'dart:html' as dom; Using 'dom' as an alias for the "dart:html" package. ...

Django: Implementing Subdirectory Structure for Static Files

My static files are organized as follows: /static base.css /core /css style.css /js stuff.js When accessing these files locally using href="/static/core/css/style.css", everything works correctly. However, when deploying live, ...

tips on locating the next immediate downloadable cell in a table

My table includes cells with colspan and rowspan attributes. <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script> <table border=1 id="mytable" > <tr><td>A1</td> <td> A2 < ...

NewbieCoder is requesting clarification on the JQUERY smoothscrolling code, can anyone assist?

Can anyone provide an explanation of the functionality of the following JavaScript code? Specifically, I would like a breakdown of each line in this smooth scrolling API. $('a').click(function(){ //upon 'a' click, execute th ...

Accessing the text content of the clicked element using vanilla JavaScript

Retrieve an item from the dropdown list and insert it into a button's value. function updateButton() { document.getElementById("ul").classList.toggle("show"); } var dropdown = document.getElementById('ul'); var items = ["HTML", "CSS", "Ja ...

Press the jQuery button to reset all input fields

I have created a table with input fields where class teachers can store their students' data for the principal to review. Each row in the table contains an update and reset button, allowing teachers to save or clear the information entered in the fiel ...

launch hyperlink in bootstrap popup

I have a challenge with showcasing multiple videos in a single modal without creating separate modals for each button. The function I found was effective with an older version of Bootstrap, but it no longer works with Bootstrap 3.3.7. Below is the HTML co ...

Is there a way to retrieve error information from a method without resorting to exceptions, and if possible, also include a specific

Before delving into the issue at hand, let me provide some context: I have already developed a Result class to handle result information. These classes were specifically designed for failures, as a successful result typically does not require any addition ...

Designing draggable tags similar to those on LinkedIn, incorporating a parent div element containing an SVG image and text

Lately, I've been exploring the world of CSS and Angular. Can someone give me a jumpstart on using CSS to design an element like the one shown in this https://i.stack.imgur.com/vcR3Z.png image? Essentially, this outer tag consists of a div element th ...

JavaScript salary calculation function not functioning properly

Once the user inputs the employee's name and the number of hours they worked on the HTML form, the submit button captures this information and stores it in variables for calculating their pay. The script also factors in overtime pay. Despite feeling l ...

The body element is not positioned at the top of the webpage in the HTML/CSS layout

I'm running into an issue with my HTML/CSS. It seems like my body tag has unexpectedly acquired a margin-top of 10px... However, I've searched high and low but can't seem to figure out how to remove it. This is something that has never happe ...

Tomcat conflict with Apache CXF JAX-RS causing operational issues

Having trouble with a rest service not working from tomcat container. Below are excerpts from my pom.xml and classes - any help would be greatly appreciated. http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 <parent> <groupId>or ...

Having trouble removing a particular cookie by name? (Using Selenium WebDriver with C# on Chrome)

I have been encountering an issue with one of my tests that uses a DeleteCookies method to clear cookies. Initially, I was using the following line of code: chromeDriver.Manage().Cookies.DeleteAllCookies(); However, today, one of the tests triggered an e ...

Leverage the data retrieved from FragmentActivity in combination with ViewPager to efficiently populate a custom ListView adapter within a

First, let me give you some background information. I have a service that runs in the background and connects to a server. My app uses this connection to fetch data from the server. I retrieve lists of users and friends and display each list in separate Ac ...

Achieving nested classes in CSS: a comprehensive guide

I am encountering an issue with my CSS while trying to create a dropdown on hover. The problem seems to be related to nested classes inside a div structure. It appears that the dropdown list is not displaying properly, leading me to believe there might be ...

Populate a JComboBox with values from an enum variable

Looking for a way to customize the display of values in a JComboBox? Check out this example where an enum is used: JComboBox<StudyGrade> maxLevelOfStudiesCombo = new JComboBox<StudyGrade>(StudyGrade.values()); The corresponding enum definitio ...

How to center a div with a overlay in CSS?

I have created an overlay with a div on top of it, and I am currently struggling to center the div over the overlay. I have tried adjusting the left and right properties, but nothing seems to be working. .request-estimate { position: absolute; ...

Leverage JSON_EXTRACT for retrieving a JSON value within a customized DTO using Spring JPA Custom Query

Fetching value from a JSON column and returning a custom DTO in Spring JPA is my goal. The structure of the table includes: userId (int) name (string) street (string) zipcode (string) state (string) country (string) meta (JSON) The meta column holds data ...

Two clicks are needed for an AJAX call to be made

Can anyone help me figure out why my function is not displaying the content after one click? It seems to only work after two clicks. Is there a way to fix this so that the information loads and displays with just one click? function getFuncDoc(funcName, ...