Issues encountered with Element clicking in Span Div CSS dropdown frame using Selenium Web Driver

I am facing a challenge with a sophisticated epiphany web application that is only compatible with IE. The user interface involves multiple frames, one of which contains a Button that, upon being clicked, reveals a set of menu options. Here is the HTML code for the menu:

<div class="FWDropdownMenu" id="test_dropdown">
<div class="DropdownMenuFrame">
<table>
<tbody>
<tr>
<td>
<span class="eABCD" id="e1">
<div class="DropdownMenuItem" id="test2_dropdown" onclick=return eTop.Fire(1,this,event)">
<table>
<tbody>
<tr>
<td>
<div>Option 1</div>
</td>

In an attempt to click on 'Option 1', I used the following approach to locate the element:

List<WebElement> options = driver.findElements(By.tagName("table")
                            .tagName("td").id("e1"));    

Although the Webdriver successfully locates the element, it fails to click on it. An error message stating "element not visible" pops up, even though the options are visibly displayed on the screen after clicking the menu. Unfortunately, I am still unable to interact with them.

Any suggestions or ideas on how to resolve this issue?

Answer №1

After some experimentation, I have discovered a solution that may be beneficial to others in the future:

WebElement element = driver.findElement(By.id("test2_dropdown"));
JavascriptExecutor executor = (JavascriptExecutor)driver;
executor.executeScript("arguments[0].click();", element);

In order to click the button, this method utilizes javascript. Because of the way my application is designed, selenium was unable to click the element directly. By leveraging internal javascript, I was able to successfully achieve the task.

A big thank you to Stackoverflow for providing invaluable guidance!

Answer №2

It appears that the correct element locator was not used in this case. Based on your question, you are trying to click on 'Option 1' but using the id 'e1' to select the element. This will target the following HTML element:

<span class="eABCD" id="e1">

A simpler locator method would be to use the following code:

driver.findElement(By.xpath("//div[contains(text(),'Option 1')]")).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

grab the content from a text editor and insert it into a div element

Currently, I am trying to extract text from my content editable div and place it in another div (similar to the one seen on stack overflow). However, I am encountering a frustrating issue. 1. My content div seems to be lagging behind. When I type in my ed ...

Having trouble with bootstrap carousel malfunctioning on Firefox browser?

I'm experiencing an issue with the carousel slider on my website. It seems to only be working in Chrome and not in Mozilla Firefox. You can view the live site at: Below is the code I have used for the carousel: <header id="myCarousel" class="car ...

What is the best way to center an <h1> element and align a <p> element to the right within a single div?

My goal is to create a div using Bootstrap 4 that contains an <h1> aligned in the center, with a <p> tag aligned to the right. You can see exactly what I'm aiming for here: https://i.sstatic.net/dhgqX.jpg I am looking for a solution using ...

The sidebar's bottom gets concealed beneath the page's window

I seem to be facing an issue with the sidebar where the bottom section is not visible. Interestingly, when I remove the top navbar, everything works fine. Despite my efforts to troubleshoot and apply various solutions, none of them seem to work for me. Do ...

Creating a static CSS lightbox with scrolling content

I am trying to create a CSS lightbox for an image gallery, where the images displayed in the lightbox need to be large so their content is easily readable. The lightbox container is fixed in its position, but I require the images to be scrollable along the ...

Can pyvirtualdisplay effectively utilize Xvfb, and is there a limit to the number of Xvfb instances that can be opened by pyvirtualdisplay

I tried using the code below to open multiple Xvfb for testing purposes, but encountered a few issues: A. Some of the Xvfb processes were showing status Z or SL, sometimes Z+ or SL+. However, the Python process was running normally. What could this mean? ...

Introducing a new div element completely disrupts the overall layout

Take a look at the code I have provided below. http://jsfiddle.net/xymgwonu/3/ Everything was working perfectly fine until I introduced a new div with the class name <div class="bubble"></div>. This caused some issues with the overall design. ...

Using SWIG to link Cygwin DLLs

I'm attempting to follow the SWIG Java example outlined here. However, this example involves using cygwin for compilation, and requires a C source file for the process. Instead of a C source file, I would like to provide an already compiled dll file n ...

While Xpath can be successfully located within Elements and Console, it encounters difficulty when attempting to be located during application execution

I'm currently enhancing my skills with Selenium Webdriver along with ChromeDriver, focusing on XPath. Below is the code snippet that I attempted to run: WebDriver driver; String baseURL = "http://youtube.com"; System.setProperty("webdr ...

Unable to establish connection with Parse server in Android Studio API 28 due to input/output failure

My AndroidManifest.xml file <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.parse.starter" android:targetSandboxVersion=" ...

When handling HTTP requests, the @RequestBody annotation is causing the JSON data to be null

I have encountered an issue with my Java Spring API and React front end setup. Despite being able to send a PUSH request successfully, the fields in the SQL database remain null. This problem persists even when using Postman for the request, indicating tha ...

The MDL card is not properly aligned at the top of its parent element

I am currently utilizing the mdl framework to design my web application. <div class="demo-card-wide mdl-card mdl-shadow--2dp mdl-cell mdl-cell--top mdl-cell--6-col"> ... <div class="demo-card-wide mdl-card mdl-shadow--2dp mdl-cell m ...

The current code lacks any form of line breaks

While attempting to edit a CSS file in Sublime Text 2, I noticed that all the code is displayed without any line breaks. This makes it difficult to read and work with. Is there a way to fix this issue and format the code into readable sections? ...

Anticipating the identification, but encountered the phrase "[Under 18]" instead

I am attempting to run this query, which works fine in phpMyAdmin but is giving me an Exception when used in my method: Error: expecting IDENT, found ''[Under 18]'': line 1:53: expecting IDENT, found ''[Under 18]'' ...

Django: Selenium - encountering stale element reference while browsing

Due to some issues on my Windows PC with the Firefox webdriver, I have switched to using Chrome webdriver for my testing. Before my vacation, my Django Functional Tests were running smoothly. However, upon returning, they are now throwing various errors. ...

Enhance Your Forms with Bootstrap 4 Input Extension

I've been struggling to create a form with Bootstrap 4, specifically setting the value in an input text client-side for a modal form. No matter what I try, it just doesn't seem to work... Here is the form: $('#contact-modal').on(& ...

Is it necessary to only override the monospaced font?

Can the monospace font in Angular Material be customized for just the <code>foo</code> blocks? I want to use a font where the number zero 0 looks distinct from the letter oh O. ...

Switch between webpage design for different devices (mobile/desktop) using javascript, jquery, and bootstrap

I am currently working on a webpage that contains various html elements with bootstrap classes applied to them. <div class="col-xs-12 col-lg-4"></div> My goal is to implement a button that, when clicked, will toggle the viewport/layout change ...

(Bootstrap) Implementing inline block properties to ensure consistent column display

I am currently working on improving the column layout of a website. However, I am facing an issue where there are large blank spaces if the text lengths or image sizes vary. To test out the theme, I have included some sample products in the image below. h ...

Choosing numerous JLabels at random from an array of JLabels

element: Currently facing a challenge with my array containing 256 JLabels. My goal is to select 40 labels at random and give them new names. I attempted using a random integer method, but struggled with converting it to a JLabel. As I am relatively new ...