1

I want to copy a text from a website and store it into a variable so I can add it to a dictionary later. I wanted to know how do I accomplish it?

Here is my source code:

from selenium import webdriver

f = webdriver.Firefox()

f.get("http://hi.com")

g = f.find_element_by_tag_name('h1').getText()

print g 
The_Diver
  • 1,865
  • 4
  • 19
  • 19
  • See if [this](http://stackoverflow.com/questions/11750447/performing-a-copy-and-paste-with-selenium-2) helps – Pynchia Jun 29 '15 at 21:23

1 Answers1

1

What type of text you need to copy from web page?

You need to locate webelement of text you need to capture and simply use getText() on it.

String text = driver.findElement(By.id("some id")).getText();

Vishal Jagtap
  • 896
  • 11
  • 16