Uncovering the secret span values with javascript

While testing the page, I encountered a span element that is acting like a drop down select menu. The Selenium code designed for "select" elements does not seem to work properly, resulting in the following error:

TC failed with error:
org.openqa.selenium.support.ui.UnexpectedTagNameException:
Element should have been "select" but was "span"

Here is the Outer HTML snippet:

<img id="s_2_1_193_0_icon" class="applet-form-combo" data-allowdblclick="true" src="images/janna/down.gif" alt="Combobox Field" style="display: inline;">
<span role="status" aria-live="polite" class="ui-helper-hidden-accessible">
    20 results are available, use up and down arrow keys to navigate.
</span>

Answer №1

Utilize the attribute style when targeting hidden web elements. A sample code snippet is provided below:

driver.findElement(By.cssSelector("span[style*='hidden']"));

//double check the locator

For JavaScript, consider the following approach:

JavascriptExecutor executor = (JavascriptExecutor)driver); executor.executeScript(“arguments[0].setAttribute(‘style’, ‘visibility: visible;’);”, element); executor.executeScript(“arguments[0].click();", element);

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

Closing DatabaseClient and TransactionalOperator with Spring and R2DBC

When working in my Spring Boot application, I can set up DatabaseClient and TransactionalOperator like this: @Autowired public App(ConnectionFactory factory) { DatabaseClient dc = DatabaseClient.create(factory); TransactionalOperator to = Transact ...

Issue with "Access-Control-Allow-Origin" header missing in express and react application

I've decided to work on a Node/Express project to improve my JavaScript skills, but I'm facing an issue with 'Access-Control-Allow-Origin'. For some reason, I can't do a get request from the front end and despite looking at other p ...

Creating an array of Java objects

I've been going over this code multiple times: public class triple { public double x=0; public double y=0; public double z=0; public triple(double a, double b, double c){ this.x=a; this.y=b; this.z=c; } } ...

Match the test choices with the corresponding `radio` buttons

Looking for help with my quiz application. How can I align text vertically with radio buttons? Take a look at the code here on Codepen. One issue I'm facing is the alignment of long label texts, particularly in questions 9, 12 & 14. I've tried va ...

python script to click a button within an iframe

Having trouble accessing a website using Python selenium. Can't seem to click on the button. Any assistance would be greatly appreciated. Please see my code below: from selenium import webdriver from time import sleep path_to_chromedriver = "chr ...

The words are a blank canvas in babel/js and react. How can I bring them to life?

https://i.sstatic.net/IdOon.jpg The words are written in white on this page. I didn't accomplish anything yesterday, but everything seemed fine. Is there anyone who can offer assistance? ...

Validating the absence of a string within an ArrayList

Currently, I am working on an arraylist and facing a certain issue. [Bibek Gurung, 9.808112115E9, , <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="671306150c0f1e0627000a06b08071e060616">[email protected]</a>] I ...

Is it possible to invoke a helper function by passing a string as its name in JavaScript?

I'm encountering a certain issue. Here is what I am attempting: Is it possible to accomplish this: var action = 'toUpperCase()'; 'abcd'.action; //output ===> ABCD The user can input either uppercase or lowercase function ...

Table with checkboxes for row selection

Hey there, I've just set up a table with some values. My goal is to select all checkboxes with the first checkbox and uncheck them. print "Content-type: text/html; charset=iso-8859-1\n\n"; my $script = qq{ \$('#id').change(fu ...

What is the method for incorporating dynamic query parameters using strings in Angular 7?

I am currently faced with the challenge of having multiple dropdown fields on my screen. When a dropdown value is selected, I need to pass it in the query parameter to create a dynamic query parameter. However, the code I have tried so far does not seem to ...

Is it Necessary to Wait for my Script Tag in React when Utilizing a CDN?

My current project involves the use of a CDN to load a script, which I am implementing through the useEffect hook directly in my component. Here is the simplified code snippet: React.useEffect(() => { const script = document.createElement('scri ...

Only match the character if it is not at the beginning of the line and if another character is not on the

Is there a way to only match the character "=" in a string if it is not at the beginning of a line and no other character, for example "$", appears on the same line? The equal sign should not be at the beginning of a line No other character, such as "$", ...

Vanilla JavaScript: toggling text visibility with pure JS

Recently, I started learning javascript and I am attempting to use vanilla javascript to show and hide text on click. However, I can't seem to figure out what is going wrong. Here is the code snippet I have: Below is the HTML code snippet: <p cla ...

What is the best way to retain multiple values passed through Output() and EventEmitter() in Angular?

In my Angular application, I have implemented custom outputs to transmit user-selected values between components. Currently, the functionality allows for the selected value from checkbox items to be sent to a sub-component, where it is displayed in the con ...

The operation of executing `mongodb - find()` does not exist as a function

I am having trouble printing all documents from the "members" collection. I attempted to use the find() function, but encountered an error stating that find() is not a function. Here is a snippet from member_model.js located in the models/admin folder: v ...

Steps for setting up node-openalpr on a Windows 10 system

While attempting to install npm i node-openalpr, an error is occurring: When using request for node-pre-gyp https download, I encounter a node-pre-gyp warning and error message. The package.json for node-openalpr is not node-pre-gyp ready, as certain pr ...

After following the official guide, I successfully installed Tailwind CSS. However, I am facing issues with utilizing the `bg-black` className for styling the background,

Following the installation guide for Tailwind CSS, I ran the command npm install -D tailwindcss postcss autoprefixer npx tailwindcss init -p. Despite this, the background className (bg-black) is not working as expected. Here are the file paths: Directory ...

Utilizing Python to Analyze COVID-19 Data from CSV Files on Github

If you're looking for CSV files containing daily reports of COVID-19, you can find them at this link: https://github.com/CSSEGISandData/COVID-19/tree/master/csse_covid_19_data/csse_covid_19_daily_reports What's the optimal way to collect all th ...

Trouble with Arraylist not updating after calling notifyDataSetChanged() in Android Java application

I encountered an issue while trying to clear an arraylist using "arraylist.clear" and then reload it with new data by calling "adapter.notifyDataSetChanged()". Even though the arraylist size shows that there are items present, the list does not display any ...

Storing data on the client side within an Angular application for

The issue at hand Our front-end application is built using Angular.js and served from an Express server. Several users have reported encountering sporadic problems with the application, which seem to be resolved when they clear their browser's cache ...