lundi 11 janvier 2016

Getting the text from the Element -- exclude the text of inner element

I've a HTML as Below

<div class="someClass">
     LNAME, FNAME MNAME
    <a class="button" onclick="#">This is Button</a>
</div>

I want to get the text inside the div.someClass i.e LNAME, FNAME MNAME.

But I'm getting following

LNAME, FNAME MNAME 
This is Button

I'm using driver.findElement(By.cssSelector("div.someClass")).getText();

I'm aware that above code is giving me the text of div.someClass element as a whole.

How can I extract the value of just div.someClass but not inner element. For example I've given, I want output as

LNAME, FNAME MNAME

Aucun commentaire:

Enregistrer un commentaire