I have below HTML code in my project.
<button id="tab-oneWay" class="" data-initial-tab="true" type="button" data-section-id="#section-oneWay">
<span class="tab-label">
One Way
<span class="visuallyhidden"> Tab 1 of 2</span>
</span>
</button>
I have to find only the text 'One Way'. I have tried below codes but it is returning 'One Way Tab 1 of 2'.
findElement(By.id("tab-oneWay")).getText()
findElement(By.cssSelector(".tab-label")).getText()
I am new in selenium so not sure how to find this. Any help on this would be great ! Thanks in advance