jeudi 29 janvier 2015

AttributeError: 'module' object has no attribute when running python selenium script


I'm running into an issue when trying to use webdriver.find_element_by for CSS, xpath, or element id.


When running the python script, i see it open the page but then i see it fail with the following:



Traceback (most recent call last):
File "selectnext.py", line 12, in <module>
webdriver.find_element_by_xpath("//*[@id='container']")
AttributeError: 'module' object has no attribute 'find_element_by_xpath'


Heres the code i'm using:



import selenium
from selenium import webdriver
from selenium.webdriver.common.keys import Keys

path_to_chromedriver = '/Users/username/bin/chromedriver'
browser = webdriver.Chrome(executable_path = '/Users/username/bin/chromedriver')

url = 'url here'
browser.get(url)
webdriver.find_element_by_xpath("//*[@id='container']")


I get the same error regardless if i use css, xpath, or element id, but i can't for the life of me figure out why. I know its something i'm doing wrong and would love some assistance in this!





Aucun commentaire:

Enregistrer un commentaire