I am new to XPath and trying to capture the values "Time: " and "13:45" from the following HTML snippet. Any help or suggestion will be really useful. Thank you!
<div class="inner-box">
<p class="inner-info-blk">
<strong>Time: </strong>
"13:45"
</p>
</div>
I can access the label with in the <strong>...</strong> container with the pattern below but cannot figure out how to get the time value with in the <p ...> container.
Label xpath:
//div[@class="inner-box"]/p[@class="inner-info-blk"]/strong
You can use
text()to get the text from an element.And that would get the text from the
<p>element.UPDATE: As @shailesh has mentioned, the Selenium locator would not evaluate XPath expression that returns a text; nor, to the best of my knowledge, there exists such a method in Selenium that will evaluate arbitrary XPath expression. But just to offer an alternative, you may also use a bit of JS here: