Error: Unable to locate elements due to a null XPath expression. This issue arises while attempting to input keys using a Method

Encountering an error when using Sendkeys in methods.

public static void inputTask(String task) throws Exception {
    // Entering task name
    GUIFunctions.typeTxtboxValue(driver,By.xpath(ObjRepoProp.getProperty("inputTaskName_XPATH")),task);
    Thread.sleep(5000);
}

However, the Send keys work fine when done directly.

driver.findElement(By.xpath(ObjRepoProp.getProperty("inputTaskName_xpath"))).sendKeys("qaz");

Answer №1

Your call to ObjRepoProp.getProperty() method is using an incorrect key. Here is the corrected code snippet:

    GUIFunctions.typeTxtboxValue(driver, By.xpath(ObjRepoProp.getProperty("enterTaskName_XPATH")), task);

    driver.findElement(By.xpath(ObjRepoProp.getProperty("enterTaskName_xpath"))).sendKeys("qaz");

The key "enterTaskName_xpath" should actually be "enterTaskName_XPATH". The following code should resolve the issue:

    GUIFunctions.typeTxtboxValue(driver, By.xpath(ObjRepoProp.getProperty("enterTaskName_xpath")), task);

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

Issue with running Selenium script from console compared to CRON, encountering Geckodriver error

My Selenium script is set up to run from an SH file. When I manually execute the SH file from the console, everything works perfectly. However, when I schedule the file to run from a Cron job, it fails. This is the content of my SH file: #!/bin/sh expor ...

What is the best way to determine if an image has successfully loaded in Codeception tests?

I need to verify whether the Verisign logo images are loading correctly $I->seeElement('DIV#security IMG.verisign'); However, my current test is passing even when the image is not loaded (e.g. for a 404 error if the file name of the source i ...

selenium AutoIt causing keyboard typing errors

I'm currently using AutoIt to upload Selenium files, but I'm facing an issue where it enters the file path incorrectly during the upload process. https://i.stack.imgur.com/ptGHv.png autoIt = new AutoItX3(); autoIt.WinActivate("Save As" ...

Retrieving availability using the datepicker

My attempts to retrieve the daily price on Homeaway by clicking the next button in the datepicker calendar have not been successful. Here is a snippet of my current code: def handle(self, *args, **options): def homeaway(self): display = Displ ...

Steps to select an option from a drop-down menu that does not have an ID assigned

How can I interact with a drop-down element that appears after clicking on an item? <div class="field loan-selection"> <label class="field__body"> <div class="field__label">Nettokreditbetrag <!-- -->&nbs ...

Using Selenium in Python to effectively capture and analyze network traffic responses

I'm encountering a problem where I can't seem to access the network traffic responses in Firefox using Selenium (Python). While solutions are available for the Chrome webdriver, my specific requirement is to work with the Firefox version. Despite ...

Selenium unable to interact with Javascript pop-up box

I am currently working on automating a feature for our web application, specifically a form of @mentioning similar to Facebook. On the front end, when a user types @ into a text input, the API is called to retrieve the list of users and display them in a b ...

Python Scripting for Selenium Automation

After recently diving into the world of selenium with Python, I decided to put together a sample test script: from selenium import webdriver def browser(): driver= webdriver.Firefox() driver.delete_all_cookies() driver.get(' ...

I'm attempting to retrieve text from an <a> tag with a ::before selector using selenium in python

<ul class="ipc-inline-list ipc-inline-list--show-dividers ipc-inline-list--inline ipc-metadata-list-item__list-content baseAlt" role="presentation"> <li role="presentation" class="ipc-inline-list__item"><a class="ipc-metadata ...

Python and Selenium - Dealing with Authentication Pop-Up without the use of URL username and password parameters

Is there a way to authenticate without exposing parameters in the URL? The solution requires manually handling alerts (switching to alert, authenticating, then switching back to the original window) using Selenium's Alert Class method. Below is the f ...

Can Selenium C# tests retrieve a parameter from a batch or PowerShell script?

My Selenium tests navigate to a specified URL using the code: driver.Navigate().GoToUrl("www.blahwhatever.com"); Currently, I am able to execute these Selenium tests using either a batch file or PowerShell script. Ideally, these scripts would be triggered ...

Revamp Your Workflow with Python: Discover Up-to-Date Guidelines for Automating Selenium Browser Launches

--------Responding to a Post Identified as a Duplicate Question As I am still in the process of learning the basics of programming, I was uncertain about the relevance of the information provided in the other post, particularly since it pertained to the i ...

Encountering problems with the python and selenium code I used to create my Twitter scraper

I have developed a Python script that extracts information like name, tweets, followers, and following from the profiles available in the "view all" section of my Twitter profile page. The script is currently functioning as intended. However, I have encoun ...

When attempting to execute Selenium WebDriver with a customized Firefox profile, an error message is thrown: "WebDriver

Attempting to initiate a selenium test with the given command: selenium-side-runner --server http://127.0.0.1:4444/wd/hub --debug -c "browserName='firefox' moz:firefoxOptions.args=[-profile, /home/seluser. /firefox-profile/myprofile]" --outp ...

Issues arise with radio buttons when using the isSelected() method

I'm struggling with a function designed to toggle the state of a radio button. Here's what it looks like: public void changeRadioState(List<WebElement> radioButtons){ for(WebElement radioButton: radioButtons) { if ( ...

Issue: 1506741262570 Marionette ALERT Port 2828 connection established with Selenium

My goal is to utilize Selenium with Firefox to launch Google. The version of Firefox I am using is 52.3.0 (64-bit). Here is the code snippet I have tried: System.setProperty("webdriver.gecko.driver","C://geckodriver-v0.19.0-win64_2//geckodriver.exe"); ...

Automatically generate an .au3 script using my C# code

I am faced with a challenge of automatically compiling an .Au3 script code and then running it. The script (au3 file) is updated automatically, but in order for the updates to take effect when I run the script, it needs to be compiled first. While there ar ...

Error encountered while using Selenium's By.className() method: IndexOutOfBoundsException - Index: 0, Size: 0

Currently, I am developing an automation tool for a website where the HTML elements do not have IDs. I have heard that xPath and CSS Selector may not be as efficient, so I decided to switch to By.className(). However, I encountered some issues with this ap ...

Navigating through a series of URLs using Selenium

I am encountering difficulties with looping through a list of URLs using selenium. The problem seems to lie within the #Second Part section of my code. Currently, the length of the linklinkfin list is 9, but this number can fluctuate as more URLs are gathe ...

Is there a method to successfully execute this Python Selenium code in headless mode?

Earlier, I had posted a question (Unable to get selenium (python) to download a csv file which doesnt have a link but only appears after i click the download button) regarding an issue I was facing. After some troubleshooting, I discovered that my code was ...