The html looks something like this:
<p>
sometext1
<br>
sometext2
<br>
sometext3
</p>
I would like to extract all the text between the paragraph tags, including the <br>
tags.
I tried to use storeText
function, but it stores only the text, without the tags.
I could store the entire HTML source and then extract what I need in Perl, but I was wondering if there is a way to store a block of HTML code using a specific xpath (e.g. store the HTML code for the third table in the webpage inside a variable).
We can extract text from a webpage using Selenium webdriver and save it as a text file using the getText method. It can extract the text for an element which is displayed (and not hidden by CSS).
We can get the text from a website using Selenium webdriver USING the getText method. It helps to obtain the text for a particular element which is visible or the inner text (which is not concealed from the page).
DOM stands for Document Object Model. In simple words, DOM specifies the structural representation of HTML elements. There are four ways through which we can identify and locate a web element using DOM.
innerHTML
i will try with document.getElementById('id').innerHTML
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With