Uable to access element in dropdown using xpath

Question:

I have a web page with a time zone drop-down where I want to access the options
enter image description here

The HTML is as follows:

            <li>
              <div id="ember2503" class="artdeco-dropdown__item artdeco-dropdown__item--is-dropdown ember-view" tabindex="0"><!---->
                (UTC-11:00) Midway Island, Samoa
              </div>
            </li>

I want to select the option using the text attribute.
Using text attribute will allow me to access the option by just having a variable ‘capital’s name’.

I tried to access this with text() attribute but it is not visible.
Here is the XPath:

//div[contains(text(),'Midway')]

This XPath is not working. Is there any way to access this?

Asked By: faaiz hashmi

||

Answers:

Try this one instead

//div[contains(.,'Midway')]
Answered By: Parolla
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.