Having difficulty in choosing the desired option from the dropdown menu

I seem to be facing a challenge with a dropdown list while trying to select the birth month.

Despite my experience working on other websites, I have been unable to resolve this issue.

I have attempted:

Clicking using different locators. Using Action class for hovering and clicking. Trying to use JavaScript to select the month.

An interesting observation is that while I am able to extract the text of the WebElement, I am unable to click on it.

The URL of the application is: a link!

This issue is encountered specifically when creating an account on Google.

https://i.sstatic.net/ygYlE.png

I was attempting to choose any month from the dropdown list.

I received a TimeOutException when waiting for the box to display the desired month.

Other than that, no errors are reported. The script passes without making the selection.

While I acknowledge this may be a simple question, I would greatly appreciate any assistance in resolving it.

Thank you in advance.

<span id="BirthMonth" class=" form-error" aria-invalid="true">
<div class="goog-inline-block goog-flat-menu-button jfk-select" role="listbox" style="-moz-user-select: none;" aria-expanded="false" tabindex="0" aria-haspopup="true" aria-activedescendant=":0" title="Birthday">
<div class="goog-menu goog-menu-vertical" style="-moz-user-select: none; visibility: visible; left: 0px; top: -82.2333px; display: none;" role="listbox" aria-haspopup="true">
<div id=":1" class="goog-menuitem" role="option" style="-moz-user-select: none;">
<div id=":2" class="goog-menuitem" role="option" style="-moz-user-select: none;">
<div class="goog-menuitem-content">February</div>
</div>
<div id=":3" class="goog-menuitem" role="option" style="-moz-user-select: none;">
<div id=":4" class="goog-menuitem" role="option" style="-moz-user-select: none;">
<div id=":5" class="goog-menuitem" role="option" style="-moz-user-select: none;">
<div id=":6" class="goog-menuitem" role="option" style="-moz-user-select: none;">
<div id=":7" class="goog-menuitem" role="option" style="-moz-user-select: none;">
<div id=":8" class="goog-menuitem" role="option" style="-moz-user-select: none;">
<div id=":9" class="goog-menuitem" role="option" style="-moz-user-select: none;">
<div id=":a" class="goog-menuitem" role="option" style="-moz-user-select: none;">
<div id=":b" class="goog-menuitem" role="option" style="-moz-user-select: none;">
<div id=":c" class="goog-menuitem" role="option" style="-moz-user-select: none;">
</div>
<input id="HiddenBirthMonth" type="hidden" name="BirthMonth">
</span>

Answer №1

Have you attempted using sendkey? I believe utilizing sendkey will resolve the issue.

driver.findElement(By.xpath(".//*[@id='BirthMonth']/div[1]")).sendKeys("april");

Thank you

Answer №2

Give this code a try and it should function properly.

Select(driver.findElement(By.id("BirthMonth"))).selectByVisibleText("February");

If the above code doesn't work, start by clicking on the dropdown list. Next, save all the values from the dropdown into an array or list, then choose the necessary value from that list/array.

Answer №3

To select a specific month, click on the dropdown menu for BirthMonth first and then choose the desired month from the list. Here's an example for selecting June:

driver.findElement(By.cssSelector("#BirthMonth > div")).click();
driver.findElement(By.xpath("//*[contains(text(),'June')]")).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

What is the correct way to chain promises within Promise.all?

Essentially, I retrieve all the rows from a schedule table and then process each individual row. If the row is already in the command table, I skip it. Otherwise, I insert it. Within Promise.all(rows.map(function(row){ I have 2 chained promises: return ...

Engaging Resources for Introducing Children to Javascript Programming

Anyone have recommendations for a physical book designed to help children learn programming using Javascript? I've come across the question "Best ways to teach a beginner to program" on Stack Overflow, but it's more focused on Python and doesn&a ...

Searching for a specific file name within a designated directory and then adding it to an array list

Greetings to all, I am currently facing a challenge with a code that I am working on. The objective of this code is to create a recursive algorithm that will identify all files matching a specified file name. Each string should contain the path to the mat ...

What could be the reason behind the occurrence of an error after deleting certain lines of code

The code below is functioning correctly. obj = { go: function() { alert(this) } } obj.go(); // object (obj.go)(); // object (a = obj.go)(); // window (0 || obj.go)(); // window However, an error arises when I comment out the first two lines. obj ...

What could be causing my React app to consistently reload whenever I save a file in my project?

Hi there, I am currently working on a project using React, GraphQL, Node, and MongoDB. I have been trying to upload images to a folder within my app, but I am facing an issue with the app reloading after saving the file. I attempted to manage a local state ...

The email validation UI dialog is failing to display any dialog

<html> <head> <link rel="stylesheet" href="//code.jquery.com/ui/1.11.1/themes/smoothness/jquery-ui.css"> <script src="//code.jquery.com/jquery-1.10.2.js"></script> <script src="//code.jquery.com/ui/1.11.1/jquery-ui.js"& ...

Refresh the vue-owl-carousel following a dynamic data update

Utilized vue-owl-carousel with dynamic content <script> import carousel from 'vue-owl-carousel' export default { components: { carousel }, } <carousel :items="1"> <img v-for="(img, index) in images" ...

The function that triggers an image slide event in Bootstrap 4 carousel

Currently, I have implemented a bootstrap 4 carousel with 11 slides that are functioning as intended. I now have another div (#div-info) where I would like to display specific text and images based on the active carousel slide. For example, when slide 2 is ...

Guide on how to "attach" the routes of an Angular 2 module to a specific location within the routing structure

Let's consider a scenario where the main routing module is defined as follows: // app-routing.module.ts const appRoutes: Routes = [ { path: 'login', component: LoginComponent }, { path: 'auth', ...

How can I ensure that the Bootstrap datePicker is validated as a required field

I am using the it-date-datepicker as a calendar picker, which is a bootstrap-datepicker version based on ab-datepicker. The issue I am facing is that I need to make this field mandatory. I downloaded jquery.validate.js for this purpose but I can't see ...

Can AJAX be considered a backend tool for retrieving data from servers?

I'm curious to find out if ajax is primarily used as a backend technology for retrieving data or if it's mainly considered a frontend tool. My attempts to research this on Google have not yielded a definitive answer. ...

I'm thinking about transitioning my current React app to Next.js. Do you think it's a good move?

We have recently transitioned our project from react-redux with firebase authentication and solr DB to next.js. Below is the updated folder structure of our app: --src --actions --assets --components --controllers --firebase --redu ...

Retrieving player statistics through the NHL API

I've been struggling for the past two weeks to figure out how to fetch player stats from this NHL API when a player is clicked. You can see an example of what I'm trying to achieve by clicking on this player stats link. Any assistance with this w ...

A guide on accessing a JSON array with a dynamic array name and key pair in Java

{ "title": [ "example" ], "description": [ "first", "second", "third", "fourth", "fifth", ], "category": [ "test" ] } I am new to JSON and need assistance in understanding how to interpret the names and values in this file. ...

Saving the information into a designated MongoDB repository with a particular title

One of my recent projects involved creating a script that pulls data from the Binance API and sends it to MongoDB. This script runs every hour using the Node-Schedule package, fetching three different sets of data based on their symbols (BTCUSDT, ETHUSDT, ...

Checking the image loading functionality with Cypress

I am interested in testing Cypress to verify that an image is successfully loaded onto a page. Here is a snippet of my source code: import React from "react"; export default class Product extends React.Component { render() { return ( <div ...

Include all the items from the directory into the array in the form of an object

https://i.sstatic.net/48gCi.png I am currently dealing with a file structure similar to the one shown in the image, and I have code that reads folders content as follows: var array = [] fs.readdir(__dirname + '/static/katalogi', function (err ...

An issue has been encountered with the wait.unit in Selenium 3.3.1, specifically related to the error message involving java.util.function.Function<? super org.openqa.selenium.WebDriver, V

After upgrading my selenium webdriver to version 3.2.0 from 3.0.1, I noticed the following issue: WebDriverWait wait = new WebDriverWait(Driver, 30); wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("myID")); An error is displayed during co ...

Connect jQuery's resizable controls

Check out this jSFiddle. I am attempting to add event handlers for resizing $('oWrapper_'+num). However, the resizing does not occur. This is because $('#oWrapper_'+num) has not been added to the dom at the time of execution, so the se ...

Incorporating React.js with a server API that doesn't use JavaScript

My upcoming project involves enhancing my current application frontend by implementing React.js. The existing frontend currently utilizes standard REST calls to communicate with a server built using Microsoft technologies, and there are no plans of changin ...