Get some text with java + selenium WebDriver -


i want text "invitation sent xxxxx", not want what's inside

<button class="action" data-ember-action="" data-ember-action-3995="3995">           visualizar perfil  </button> 

i'm getting text way:

string pessoapopu = driver.findelement(by.classname("artdeco-toast-message")).gettext();                 system.out.println(pessoapopu);  

page structure:

<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 xxxxx         <button class="action" data-ember-action="" data-ember-action-3995="3995">           visualizar perfil         </button>      </p>   </div> 

image

in fact selenium's gettext() method retrieves text in sub elements too, approach, recommended murthi applicable, far know. try approach:

string newline = system.getproperty("line.separator"); string pessoapopu = driver.findelement(by.classname("artdeco-toast-message"))                            .gettext().replaceall(newline, ""); 

or try/ask for more convenient html code.


Comments

Popular posts from this blog

html - How to set bootstrap input responsive width? -

javascript - Highchart x and y axes data from json -

javascript - Get js console.log as python variable in QWebView pyqt -