-1
Html:
<input size="24" autocomplete="off" id="P.Gender" name="P.Gender" class=" x-form-text x-form-field x-form-focus" style="width: 125px;" title="" type="text">

<div class="x-layer x-combo-list " id="ext-gen1943" style="position: absolute; z-index: 11000; visibility: visible; left: 377px; top: 232px; width: 148px; height: 60px; font-size: 12px;">
<div class="x-combo-list-inner" id="ext-gen1944" style="width: 148px; height: 60px;">
<div class="x-combo-list-item ">Unknown</div>
<div class="x-combo-list-item ">Male</div>
<div class="x-combo-list-item  x-combo-selected">Female</div>
</div>
</div>

Question: How to select Male/Female/Unknown from above HTML using Selenium webdriver? There is no select class in HTML, so I am not able to use Select.

  • 1
    The description of tag selenium-webdriver says: *When using this tag, also add a tag for the programming language you are using*, so please do. – Gabriel Devillers Nov 27 '18 at 21:49
  • Possible duplicate of [How to select a dropdown value in Selenium WebDriver using Java](https://stackoverflow.com/questions/20138761/how-to-select-a-dropdown-value-in-selenium-webdriver-using-java) – Gabriel Devillers Nov 27 '18 at 21:53
  • @GabrielDevillers That's not an actual SELECT element... it's just designed to look like one so your dup doesn't apply. – JeffC Nov 28 '18 at 03:40
  • See: [How do I do X?](https://meta.stackoverflow.com/questions/253069/whats-the-appropriate-new-current-close-reason-for-how-do-i-do-x) The expectation on SO is that the user asking a question not only does research to answer their own question but also shares that research, code attempts, and results. This demonstrates that you’ve taken the time to try to help yourself, it saves us from reiterating obvious answers, and most of all it helps you get a more specific and relevant answer! See also: [ask] – JeffC Nov 28 '18 at 03:41

1 Answers1

0

You can normally use xpath with contains for selecting male/female/unknowm. Otherwise you can ask your developers to add select tag for these dropdowns if they can make the changes.

Example: //div[contains(text(),'Male')]

Prp
  • 51
  • 5