Unable to choose the option from the modal that functions similarly to a drop-down menu

I need to choose a field that functions similarly to a dropdown box, but does not actually display as one. The select field reveals its values in a pop-up with values and sub-values that I need to select.

Challenges :

I'm struggling to locate the object and cannot successfully select a value from the field.

I attempted to use a CSS selector to identify the object: "div[class='mailval'][title='Breast > Both']". However, this method did not work.

Here is the HTML Code :

<div class="rowDiv ">
   <label for="bodypart">Body Part</label>
   <div id="bodypart_box_1">
       <div style="position:absolute;left:185px;z-index: 20">
           <ul class="parent">
               <li>
                   <div id="main" class="mailval">events=Object { click=[1]}handle=function()
                       <input id="bodypart_1" class="bodypart" type="text" onfocus="if($(this).hasClass('disabled')){$(this).blur();}" readonly="readonly" value="Select One" name="bodypart_1" title="">
                       <input id="actualBodypart_1" type="hidden" value="Breast" name="actualBodypart_1">
                   </div>
                   <ul id="bodyPartList_1" class="top sub bodyPartList" style="display: none;">olddisplay="block"
                       <li>
                           <div class="mailval fly" title="Breast" originaltitle="Breast">Breast</div>events=Object { click=[1], mouseover=[1]}handle=function()
                           <ul>
                               <li>
                                   <div class="mailval" title="Breast > Both" originaltitle="Breast > NULL > Both">Both</div>events=Object { click=[1], mouseover=[1]}handle=function()
                               </li>
                               <li>
                                   <div class="mailval" title="Breast > Left" originaltitle="Breast > NULL > Left">Left</div>events=Object { click=[1], mouseover=[1]}handle=function()
                               </li>
                               <li>
                                   <div class="mailval" title="Breast > Right" originaltitle="Breast > NULL > Right">Right</div>events=Object { click=[1], mouseover=[1]}handle=function()
                               </li>
                           </ul>
                       </li>
                   </ul>
               </li>
           </ul>
           <div style="clear:both"></div>
       </div>
       <p id="bodypart-error" class="errorMessage ml161px pa ie7ErrorFix" style="top:140px !important"></p>
   </div>

Answer №1

When utilizing a class attribute in a selector, it is important that it is preceded by a "."

Here is an example of how your selector can be rewritten:

div[title='Breast > Both'].mailval

You can also use an id attribute, which should be preceded by a "#"

#bodyPartList_1 > div div[title='Breast > Both'].mailval

For more information on selectors, refer to this resource

EDIT: Based on your HTML, the popup only appears when hovered over or clicked. You can achieve this with the use of JavascriptExecutor.

((JavascriptExecutor)driver).executeScript("$('#bodyPartList_1 > .mailval.fly').click();");

Once the popup is displayed, you can select the desired value...

new WebDriverWait(driver,20).until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("div[title='Breast > Both'].mailval"))).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

Starting the animation only when the slide is visible

Struggling to add animations dynamically as a HTML/CSS developer who avoids JS but uses jQuery occasionally? Sound familiar? Well, I have. Recently, I managed to create a CSS-3 animation for the images in a Bootstrap carousel. Check out the code below: ...

After updating from version 4.2.3 to 5.1.3, a cucumber runner class encountered an initialization error

After upgrading my test automation project from cucumber 4.2.3 to 5.1.3, I encountered an issue with the runner class initialization. When running in parallel with version 4.2.3, everything was fine. However, once upgraded to 5.1.3, the runner class threw ...

CSS Troubleshoot: Unable to Change Background of Current Menu Page Item

I've been attempting to add a small graphic using CSS to indicate the current page the viewer is on, but for some reason, it's not highlighting properly. Below is my code: HTML: <ul class="side-nav"> <a href="http://www.cieloazulsant ...

Ensure that the elements are visible post-click, then proceed to print the necessary elements using Selenium with Python

I'm having an issue where I want to wait for the element to be visible after a click and then print the necessary element, but it's not waiting unless I use time.sleep. I'd like to utilize WebDriverWait(driver, 20).until(EC.visibility_of_e ...

Utilizing SVNKit to retrieve a comprehensive list of revisions that have been merged from one branch to another

Purpose: In order to ensure quality control, it is imperative that all qualified revisions are merged up to higher revisions. Example: Release_10 --> Release_11 Utilizing TortoiseSVN makes it simple to identify which revisions have been merged by sel ...

There seems to be an issue with the <mat-form-field> where normal input functions correctly, but encounters an error when trying to use mat

I've searched through other inquiries, but none have provided the solution I am looking for. <mat-form-field> <mat-select matInput placeholder="Favorite food"> <mat-option *ngFor="let food of foods" [value]="food.value"> ...

Getting the badge value of a button in Angular JS is a simple process that involves accessing

How can I retrieve the badge value of a Button? This badge represents data-text-as-pseudo-element and I am new to Angular. Can someone guide me on how to achieve this? <style type="text/css">[data-text-as-pseudo-element]::before { content: ...

Expanding and collapsing DIV elements using JavaScript upon clicking navigation menu items

At present, the current code unfolds the DIVs whenever a user clicks on a menu item. This results in the DIV folding and unfolding the same number of times if clicked repeatedly on the same link, without staying closed. My desired functionality is to have ...

The element is currently not visible, resulting in a TimeoutException being raised within the selenium.common.exceptions.TimeoutException class, along with the message

Here is the page I am referring to. When trying to select a specific country and click on it, I encounter an error in executing the next line of code. raise TimeoutException(message, screen, stacktrace) selenium.common.exceptions.TimeoutException s ...

Using JavaScript's document.write method to display HTML code, along with a variable retrieved from a Flash application

Can I ask two questions at once? Firstly, how can I achieve the following? document.write(' <div id="jwplayer"> <center> <div id='mediaplayer'></div> <script type="text/javascript"> jwplayer('mediapl ...

Placing the error message for validation in its appropriate position

My login form has a layout that looks like this: https://i.stack.imgur.com/i7rCj.png If I enter incorrect information, it displays like this: https://i.stack.imgur.com/ItNJn.png The issue is that when the error message appears, it causes the login form ...

Is there a way to keep a div element anchored at the top of the page until I reach the bottom and then have it stick to the bottom as I continue

I have a question that I hope is clear enough! On my webpage, there is a div at the top that I want to move to the bottom when I scroll and reach the end of the page. Hopefully, you understand what I'm trying to achieve! If anyone has any ideas, I&ap ...

The box on my form is leaking my background color outside the 1px border, but only in Internet Explorer

While experimenting with background gradients and borders one day just for the fun of it, I made an interesting observation in Internet Explorer. The issue I encountered was that the background color was overflowing outside the radius border, but this onl ...

jQuery mCustomScrollbars does not correctly resize the height of the div on the initial load

Need help with resizing the height of a div. Currently, I am setting the height of the div using JavaScript, but it only takes effect after refreshing the page (F5). Is there a way to make it work without needing a refresh? Check out the code snippet be ...

Is it possible to create a single CSS style class that can be used for various section tiles on a website?

I am currently working on a website that includes different section titles such as About, Projects, Contact, and more. To make these titles stand out against the background image, I have decided to fill them with white. The text color of the titles is dar ...

What is the method to establish the table format in HTML using several for each loops?

I need to arrange the table structure for product plans as follows: +------------------+---------------+---------------+ | product1 | product2 | product3 | +------------------+---------------+---------------+ | product1plan1 | product ...

Converting a JSONArray object into jQuery format

Within my Java code, there exists a JSONArray object labeled colorList that stores a collection of different colors. For example, the array may be constructed like so: ["Red", "Yellow", "Blue"] I am seeking guidance on how to transfer this information ...

Utilize the CSS content property to embed an image without causing it to distort in size

Struggling to swap out one image for another without stretching it? In my demo, I replaced an elephant with a lion using only CSS - no changes allowed to the HTML. Unfortunately, the lion image ends up stretched. Even adding background-size: cover doesn&ap ...

Guide on inserting a row into a table class without unique values using jQuery

I have gathered information on stackoverflow regarding how to use jQuery to add a row to a table. $('.myTable').find('tbody:last').append('WHATEVER CODE'); Although this method seems to be effective, I have come across the i ...

Seamless changes with graceful fades while transitioning between classes

Is it more efficient to handle this in CSS than using jQuery? I'm not entirely sure. If anyone has a solution, that would be greatly appreciated. However, I am currently facing an issue with the jQuery method I have implemented. It successfully fades ...