1
내 프로젝트에 아래 HTML 코드가 있습니다. 셀렌의 중첩 된 span 태그에서 텍스트를 가져 오는 방법
<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>
findElement(By.id("tab-oneWay")).getText()
findElement(By.cssSelector(".tab-label")).getText()
간단한 해결책이 없습니다. 다음은 비슷한 스레드입니다. http://stackoverflow.com/questions/28945692/how-to-get-text-from-parent-element-and-exclude-text-from-children-c-selenium 예를 들어 어린이의 텍스트 및 부모의 텍스트에서 remeve – kotoj
스레드 주셔서 감사. 나는 문자열 계산을 피하려고했지만 내가해야만하는 것처럼 보였다. 어쨌든 대답 주셔서 감사합니다. – ankit