How to test React JS dropdown with Selenium and java?

0 votes

I have a code which populates dynamically using React JS. How can I select a value from this dropdown?

Below is the HTML code. The div which has "Year" text is the dropdown, but when as soon as I click on the Year, it gives me few options like 2015,2014,2013 etc. But I am not sure how to access these values using Selenium.

<div class="fitment-box__first-select" data-reactid=".2.0.0.0.0.2.1"><span data-reactid=".2.0.0.0.0.2.1.0">My vehicle was made in</span><div class="Select fitment-box__select-year" data-reactid=".2.0.0.0.0.2.1.1"><input type="hidden" name="year" value="" data-reactid=".2.0.0.0.0.2.1.1.0"><div class="Select-control" data-reactid=".2.0.0.0.0.2.1.1.1"><div class="Select-placeholder" data-reactid=".2.0.0.0.0.2.1.1.1.0:$placeholder">Year</div><div class="Select-input " tabindex="0" data-reactid=".2.0.0.0.0.2.1.1.1.1">&nbsp;</div><span class="Select-arrow-zone" data-reactid=".2.0.0.0.0.2.1.1.1.4"><span class="Select-arrow" data-reactid=".2.0.0.0.0.2.1.1.1.4.0"></span></span></div></div></div>
May 14, 2018 in Selenium by Martin
• 4,210 points
2,020 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes

Below code will help you:

Actions act = new Actions(this.getDriver());

act.moveToElement(element).click().build().perform();

act.click(elementValue).build().perform();

Use action class in this

answered May 14, 2018 by Samarpit
• 5,130 points

Related Questions In Selenium

0 votes
1 answer

How to create a test case with TestNG in Selenium?

Hey Deepak, to create a Test Case ...READ MORE

answered 1 day ago in Selenium by Abha
• 5,840 points
12 views
0 votes
1 answer

Python & Selenium: How to find and click on YouTube's Like button

Use the CSS Selector button to like: #watch8-sentiment-actions ...READ MORE

answered Mar 26, 2018 in Selenium by nsv999
• 5,030 points
430 views
0 votes
1 answer
0 votes
1 answer

How to handle drop downs using Selenium WebDriver in Java

First, find an XPath which will return ...READ MORE

answered Mar 27, 2018 in Selenium by nsv999
• 5,030 points
1,214 views
0 votes
1 answer

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,030 points
60 views
0 votes
1 answer
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,130 points
432 views
0 votes
1 answer

How to use such xpath to find web elements

It's much simpler to use: #MyDiv123 > div.super or ...READ MORE

answered Jun 14, 2018 in Selenium by Samarpit
• 5,130 points
49 views
0 votes
1 answer

How to get next sibling element using XPath and Selenium for Java?

Below code will help you: Try following-sibling axis : WebElement ...READ MORE

answered May 15, 2018 in Selenium by Samarpit
• 5,130 points
3,737 views
0 votes
1 answer

How to login a forum using Selenium with Python

You should try to directly log in ...READ MORE

answered Apr 27, 2018 in Selenium by Samarpit
• 5,130 points
151 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.