I'm currently attempting to extract a specific text element from a web application. Unfortunately, I am unable to provide the HTML code, but the relevant portion resembles the following structure:
<div id ="user">
<div class="large columns">
<label for="object.disabled" class="readOnlyClass hide-label">
Text1
</label>
<div id="123x435q" class="readOnlyClass hide">
<input class="disabled-field" id="123x435qs" type="text" value="07/20/2017" disabled="">
</div>
<div class="class1">
<div>Text2</div>
"
07/10/2017
"
</div>
</div>
My attempt involves using element.getText().trim() with xpath of //*[@id='user']/div[2]
The result I obtain is: Text2 07/10/2017
My goal is to isolate just the text '07/10/2017'. Therefore, I experiment with the xpath of //*[@id='user']/div[2]/text()[2]
Running this command in Chrome console: $x(//*[@id='user']/div[2]/text()[2]) yields the expected '07/10/2017' result. However, executing it via Selenium returns: Text1.
This leads me to two inquiries: 1. Why does path/text() return Text1 in Selenium but not in Chrome console? 2. How can I refine the element retrieval to solely retrieve the date text within the class1 div node without capturing the Text2 as well?