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
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?
Answers:
Try this one instead
//div[contains(.,'Midway')]
I have a web page with a time zone drop-down where I want to access the options
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?
Try this one instead
//div[contains(.,'Midway')]