Anshita Sen
Anshita Sen

Reputation: 29

How to reomve particular tag and its value firm html content in selenium using java

I want to remove a h1 tag value from body content (html page) for that Im using String h1 = driver.findElement(By.xpath("//div[@class='tab_content active']/h1")).getText(); String content = cont.replace(h1,"");
but by this way it is removing all the matching text from the content and the particular h1 tag can anyone suggest how to do this

Upvotes: 0

Views: 43

Answers (1)

Zakaria Shahed
Zakaria Shahed

Reputation: 2707

String h1 = driver.findElement(By.xpath("//div[@class='tab_content active']/h1")).getText(); 

String content = cont.replace("<h1>"+h1+"</h1>","<h1></h1>");

It will remove the particular h1 tag text

Upvotes: 1

Related Questions