我想只有文字「發送到爲XXXXX邀請」,我不希望得到什麼內部獲得與Java +硒一些文本的webdriver
<button class="action" data-ember-action="" data-ember-action-3995="3995">
Visualizar perfil
</button>
我得到的文本這樣:
String pessoapopu = driver.findElement(By.className("artdeco-toast-message")).getText();
System.out.println(pessoapopu);
頁面結構:
<div class="artdeco-toast-inner" data-ember-action="" data-ember-action-3994="3994">
<li-icon aria-hidden="true" type="success-pebble-icon" class="artdeco-toast-icon"><svg viewBox="0 0 24 24" width="24px" height="24px" x="0" y="0" preserveAspectRatio="xMinYMin meet" class="artdeco-icon"><g class="large-icon" style="fill: currentColor">
<g id="success-pebble-icon">
<g>
<circle class="circle" r="9.1" stroke="currentColor" stroke-width="1.8" cx="12" cy="12" fill="none" transform="rotate(-90 12 12)"></circle>
<path d="M15.667,8L17,9.042l-5.316,7.36c-0.297,0.395-0.739,0.594-1.184,0.599c-0.455,0.005-0.911-0.195-1.215-0.599l-2.441-3.456l1.416-1.028l2.227,3.167L15.667,8z" fill="currentColor"></path>
<rect style="fill:none;" width="24" height="24"></rect>
</g>
</g>
<g id="Layer_1">
</g>
</g></svg></li-icon>
<p class="artdeco-toast-message">
Invitation sent to xxxxx
<button class="action" data-ember-action="" data-ember-action-3995="3995">
Visualizar perfil
</button>
</p>
</div>
等待元素是可見的,並嘗試相同的代碼。一個猜測。 –
@Paulo,你作爲輸出得到了什麼?包含按鈕文字的完整文字?或任何錯誤? – NarendraR
@Tuks 我得到全文,即使按鈕裏面有什麼,這是與我無關的文字。 –