I'm currently experimenting with JAVA and Selenium to automate testing for a WebApplication

Is it possible for someone to choose an item from the drop-down list called "Furniture Type"? I have managed to click on the furniture type using the following code:

driver.findElement(By.xpath("(//select)[1]")).click();

However, I am struggling to actually select an option from the drop-down list. I have tried using the Select class, but so far I haven't found a solution.

The URL in question is: .

The exception message I keep receiving is "no such element exception".

Answer №1

It is essential to begin by inspecting the path using developer tools or a browser extension that serves a similar purpose, or by recording it using Selenium IDE. In the specific scenario mentioned, there appears to be no select element on the page; rather, the Furniture Type is represented as an input with type=text, and the available options are input elements with type=radio. Furthermore, (//select)[1] does not constitute a valid xpath.

To locate it, you can use the following:

WebElement typeBox = driver.findElement(By.id("Furniture_Type_searchBox"));

Given that Furniture Type is an input with type=text, you can then interact with it in the following manner:

typeBox.sendKeys("");

This action should trigger a drop-down menu, from which you need to select a radio button option (such as 'Bed Set') by doing the following:

WebElement radio = driver.findElement(
    By.xpath("//div[@class='attr-container']//input[@lblval='Bed Set']"));

Subsequently, you can click on it to make your selection:

radio.click();

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

To choose an item from the context menu with Selenium, typing in sendKeys isn't effective

When attempting to select an option from a context menu, using sendKeys(Keys.ARROW_DOWN) has not been effective. Instead of navigating the context menu, it simply scrolls the page up and down, leaving the menu open. Actions action = new Actions(driver); a ...

What is the method for retrieving the font size of elements in the native view using appium?

Can the font size of text in the native view be retrieved using appium? I am aware of using driver.findElement(By.id("by-id")).getCssValue("font-size"); for web views. Is there a similar method for native views? ...

Utilizing Node Js and Selenium webdriver, what is the process of dragging and dropping an element from its current position to a new position just below it?

After multiple attempts, I have come to realize that the following code is ineffective. driver.findElement(By.xpath(xpath)).then(function (element1) { driver.findElement(By.xpath(xpath)).then(function (element2) { ...

Selenium Test Case Execution Encountered a Null Pointer Exception

I am new to Selenium Java programming. I encountered an error when trying to run the script below using TestNG. Error Message "java.lang.NullPointerException: Cannot invoke "org.openqa.selenium.WebDriver.findElement(org.openqa.selenium.By)&quo ...

Tutorial on activating the "enable-unsafe-localhost" setting in Chrome using Selenium

Can you guide me on how to enable the "allow-insecure-localhost" flag in selenium driver? selenium: 3.12.0, Python:3.6.5 Here is the code snippet for creating a Chrome driver: def create_driver(): options = Options() if sys.platform == "darwin ...

The radio button cannot be interacted with as Selenium cannot find any other unique identifier for it

While examining the code of the button, I landed on this specific section: <input type="radio" name="chosen" value="UniqueNameExample"> I am attempting to locate an element within this code that I can interact with by c ...

Utilizing Selenium WebDriver in Java to locate and interact with two distinctive table cells

I need assistance with using Selenium Webdriver in Java to extract data from a table. Specifically, I am trying to retrieve the last cell on the first row and the last cell of the last row. Currently, I am able to access one of them successfully. WebEleme ...

Encountering an issue when trying to choose the start date

When attempting to select the From-Date on "opensource-demo.orangehrmlive.com" Dashboard > Apply leave, I encountered an issue where I was unable to click on the from-date textbox. driver.findElement(By.id("applyleave_txtFromDate").click(); Select secMon ...

PhantomJS and HTMLUnitDriver are experiencing difficulty locating elements using their id or xpath

I am currently facing a challenge in implementing a browserless solution within my cloud environment due to the lack of Chrome/Firefox installations. Even when using headless Chrome/Firefox solutions, I am encountering difficulties as they still require br ...

The click function does not function properly in Firefox headless mode when executed on a Linux operating system

When attempting to log in to my application, I am facing an issue where clicking the login button does not trigger any action. However, the button does appear focused with dots around it. Additionally, ExpectedConditions.waitUntilElementIsClickable returns ...

Python Selenium Error: session ID is not valid

After attempting to initiate the web driver, randomly putting it to sleep, and then closing it, I encountered an error with the message "invalid session id." Can anyone offer a solution to this issue? Please The code snippet in question is as follows: ...

The inner div node cannot be located by C# Selenium using xpath strategy

Looking to access the second inner div node. This is the current structure: <div class = "bPageBlock brandSecondaryBrd bDetailBlock secondaryPalette" id="ep"> <div class ="pbHeader"></div> <div class ="pbBody"></div> ...

Uh oh, JMeterThread encountered an issue: Test failed due to org.openqa.selenium.WebDriverException - driver server took too long to start

My current setup involves using chromedriverVersion: 83.0.4103.39 and Chrome version =83.0.4103.97 for efficient execution on Jmeter. However, after a few hours of testing, I encounter an error message stating "ERROR o.a.j.t.JMeterThread: Test failed! or ...

Getting artist identification numbers from the API - classifying them as either long or int?

Hey there, I'm just starting out with programming so please bear with me as I try to figure things out! Currently, I'm working on retrieving artist IDs from a music website's API. I've included a snippet of my code below: JSONObject j ...

Protractor unexpectedly giving back a promise instead of the expected attribute value

I'm facing a challenge where I am attempting to extract the value of an HTML attribute and store it in a variable named url_extension. However, instead of getting the desired value, I keep receiving a Promise object. Below is my code snippet: (Please ...

Getting the dataLayer Object with Selenium: A Comprehensive Guide

I've been attempting to retrieve the datalayer object from a website using Java with Selenium WebDriver. I have been utilizing jsExecutor.executeScript to pass the "windows.dataLayer" command to the Chrome Console Tab and then parsing the data to an A ...

Interference with Element Click in Python Selenium

Having trouble with clicking a cookie button in my code. Despite using explicit wait 'element_to_be_clickable', I'm receiving an error message. Any insights on why this element can't be clicked? PATH = 'C:\Program Files (x86)& ...

Python's Selenium now has a Firefox web driver option available

I'm having trouble using Selenium 3.0.1 with Firefox 48 on OS X in Python 3. When I try to initialize the Firefox webdriver, it throws an error. from selenium import webdriver driver = webdriver.Firefox() The error message is as follows: ---------- ...

Having trouble clicking the image button because the web element cannot be found?

Here is the HTML link for the website: ...could someone please assist with this question? I have been unable to successfully click the Go button, even after trying the classname and xpath methods. Can anyone provide guidance on how to click that button? ...

Element could not be found inside the pop-up dialog

I have been attempting to find those buttons displayed here: https://i.stack.imgur.com/5M1qd.png Here is the HTML for them: https://i.stack.imgur.com/238no.png I've experimented with different methods, but unfortunately, nothing has succeeded. ...