Reputation: 93
I have looked at the Selenium documentation and can not find an example of clicking on an element. I inspected an element named attatchments.
Everytime I attempt to click the element Python gives me an error usually one of these:
{'using': by, 'value': value})['value'] File "C:\Python27\lib\site-packages\selenium-2.24.0-py2.7.egg\selenium\webdriver\remote\webdriver.py", line 155, in execute self.error_handler.check_response(response) File "C:\Python27\lib\site-packages\selenium-2.24.0-py2.7.egg\selenium\webdriver\remote\errorhandler.py", line 147, in check_response raise exception_class(message, screen, stacktrace) NoSuchElementException: Message: u'Unable to locate element: {"method":"name","selector":"add individuals"}'
Here is the code I am trying:
driver.find_element_by_name("attatchments")
elem.click()
Upvotes: 0
Views: 2503
Reputation: 699
If you know element id then you can get it as
element = driver.find_element(by=By.ID, value="element_id")
Or
element = driver.find_element_by_id("element_id")
and then use element.click()
You can go through this link to know the methods in Webdriver class: http://selenium.googlecode.com/svn/trunk/docs/api/py/webdriver_remote/selenium.webdriver.remote.webdriver.html
Upvotes: 0