Using Selenium for browser automation (Python).
If I understand correctly, the following code would be used
inputElement = driver.find_element_by_name("q") the_text = inputElement.text
How would I go about getting the text on the whole page as opposed to looking within a particular element?
New Selenium IDE There are more than one ways of achieving it. To get the text of the visible on the page we can use the method findElement(By. tagname()) method to get hold of . Next can then use the getText() method to extract text from the body tag.
The getText() method simply returns the visible text present between the start and end tags (which is not hidden by CSS). The getAttribute() method on the other hand identifies and fetches the key-value pairs of attributes within the HTML tags.
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).
Looks like the entire page text can be found in:
driver.page_source
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