What could be causing my XPath locator to not function properly?

While trying to locate this element

driver.get("https://ivtripadmindev.azurewebsites.net/login");
driver.findElement(By.xpath("//*[@id=\"root\"]/div[2]/div/div/div/div[2]/form/div[1]/input")).sendKeys("5");

Encountering the following Exception enter image description here

I am facing an issue with my Selenium script not being able to find the input field I need to interact with. How can I properly identify and send text to it? (Newbie in automation)

Answer №1

To enhance the code below, I have refined the XPath expression and implemented Selenium's Implicit Wait feature to ensure a more efficient wait period until the page loads and the element is located:

driver.get("https://ivtripadmindev.azurewebsites.net/login");
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(10));
        
driver.findElement(By.xpath("//input[@type='email']")).sendKeys("5");

Necessary imports:

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.By;
import java.time.Duration;

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

Creating additional JSON data similar to JSON using JAXB and Jersey

Working with a datamodel created using JAXB allows me to directly generate XML: <?xml version="1.0" encoding="UTF-8" standalone="yes"?>\ <metadata xmlns="http://musicbrainz.org/ns/mmd-2.0#" xmlns:ext="http://musicbrainz.org/ns/ext#-2.0"> ...

Unable to select the Icon's element

Hello everyone, I'm relatively new to using selenium and I've come across an icon element that I'm having trouble clicking. Below are the details of my issue: I attempted using this relative xpath, but I am still encountering a NoSuchElemen ...

Unable to fetch data from the shared X path

I was faced with the challenge of displaying text from multiple web elements that share a common Xpath. Here is the code snippet I used: List<WebElement> cmtnames =driver.findElements(By.xpath("//*[@id='issue_actions_container'] ...

Today, I am experimenting with HTML5 File Upload using Capybara and Selenium Webdriver in Ruby

I have encountered a problem with a simple modal that allows users to upload a file using a browse button. Due to some unknown issue, possibly related to the fact that it is an HTML5 file input and the browser adds its own functions to it, testing this has ...

Python Selenium: Delay the start of condition checking

I just finished creating a script to log into my local Unifi Camera access using the IP address. The script runs in a loop to handle any failures by returning to the beginning and attempting again. One issue I'm facing is with the last part of the sc ...

Guide to extracting and printing the selected option text from a dropdown menu using Python and Selenium

I am currently working on a Python script to extract a preselected option from a drop-down menu and then save that specific option in a newly created variable. I could use some assistance with retrieving the preselected option. As demonstrated below, the ...

A guide on finding the child label elements with Selenium and Python

I am currently utilizing Selenium in Python to extract all the descendant items under the primary div. Here is the code I have implemented: label_element =driver.find_elements_by_xpath("//div[@style='display:block']/descendant::label") However, ...

Ways to merge SpecFlow unit testing with MTM test cases

Seeking advice on integrating specflow unit tests with MTM test cases. 1) Successfully developed automated unit tests in specflow-C#-BDD format. 2) Have existing manual test cases in MTM. 3) Project checked in TFS and connected to it. Looking to execut ...

Checking for the presence of an element on a read-only page

Attempting to confirm the presence of an element on a non-editable page. Here is the HTML: <select name="sys_readonly.req_item.state" aria-readonly="true" aria-disabled="true" id="sys_readonly.sc_req_item.state"> ...

Encounters SessionNotCreatedException error when executing test in Firefox

I am currently utilizing the following versions: Selenium: 3.6.0 Mozilla: 56.0 Gecko Driver: V 0.19.0 Whenever I execute the testng.xml file for Mozilla Firefox, it throws the subsequent exception: Log: org.openqa.selenium.SessionNotCreatedException ...

Verifying JSON Schema in Java: Ensuring Data Integrity

Back in 2019-09, I developed a JSON Schema (). Does anyone know how to validate it using Java? I need assistance creating a method that will throw an Exception if the validation fails: void validate(Path pathToSchema) throws Exception { // Validate sch ...

Issue with downloading PDF files in headless mode using Java and Selenium

In an attempt to download a PDF from the Chrome browser using Selenium, I encountered the following code: public static void main(String args[]) throws InterruptedException, AWTException, IOException, DocumentException { System.setProperty("webdriver ...

Edge driver combined with the Selenium Web driver automation framework

Encountering a major problem while attempting to execute my Selenium Java automation framework with the Edge web driver. The browser successfully opens, but then nothing happens. I have confirmed that I am using the correct version of the Edge driver for ...

Utilizing Python Selenium WebDriver to launch an Electron-based Application

Trying to skip using Spectron for End2End testing an electron app by leveraging my experience with Selenium Webdriver on Python. After reviewing the Chromedriver get started page and various resources that hint it's possible, I came up with this solut ...

The getText() function will provide a blank string as output

Here is the code snippet from a web page: <td class=" gridCell wrapText " style="height:27px;" headers="a15" data-post="" title=""> <div class="oflowDivM "> <span> <script src="webwb/pzpega_control_text_12877380907.js!!.js" type="text ...

Avoid using Selenium to render the entire webpage

I am having trouble retrieving the complete source code of a web page for scraping purposes. Despite my efforts, I only manage to access a portion of it. Here are some snippets of the code I have been working with: options = Options() options.add_argument ...

Can Selenium successfully scrape data from this website?

I am currently attempting to extract Hate Symbol data (including the name, symbol type, description, ideology, location, and images) from the GPAHE website using Selenium. As one of my initial steps, I am trying to set the input_element to the XPATH of the ...

There are no interactive features shown in the screenshot

I'm capturing a screenshot using the following code: from selenium import webdriver from selenium.webdriver.common.desired_capabilities import DesiredCapabilities dcap = dict(DesiredCapabilities.PHANTOMJS) dcap["phantomjs.page.settings.userAgent"] = ...

Ways to confirm the presence of a browser using Selenium WebDriver

Currently, I am utilizing webdriver to open a Firefox browser and sequentially provide a URL to it using a spreadsheet that contains 5 URLs in various cells of column 1. In the event that I manually close the Firefox browser after two URLs have been open ...

Is it possible to verify if the input data in a login form text box is alphanumeric with Selenium Webdriver?

After transitioning from Selenium RC to Web Driver, I have been tasked with testing a registration form that includes a "login" field. My objective is to validate the form based on two specific criteria: Ensure that the name entered in the Login field ...