Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to open a website and fill in input using Selenium WebDriver [closed]

Consider:

from selenium import webdriver
driver.get("http://www.jonessoda.com/contests/back2school")
element = driver.find_element_by_name("fname")
element.send_keys("Ben")

I just started. Will this thing work? (I would check myself, but I don't know how to debug with a web browser.)

like image 412
DarkPirate Avatar asked Aug 27 '14 21:08

DarkPirate


1 Answers

It won't work. You need to instantiate driver before you can use it.

from selenium import webdriver

# add this line
driver = webdriver.Firefox()

driver.get("http://www.jonessoda.com/contests/back2school")
element = driver.find_element_by_name("fname")
element.send_keys("Ben")
like image 179
nakedfanatic Avatar answered Oct 29 '22 23:10

nakedfanatic