Selenium won't click a button with python?
Question: please can someone help me with this,

I can't get selenium to click a button with python. I'm on python 3.4 and
using Firefox 42

the browser opens but that's all

    
    
    from selenium import webdriver
    from selenium.webdriver.common.keys import Keys
    
    driver = webdriver.Firefox()
    driver.get("http://www.speedyshare.com/")
    elem = find_element_by_id_name("selectfilebox")
    elem.click()
    

The browser opens but i get the following error

    
    
    Traceback (most recent call last):
      File "/home/ro/sele.py", line 6, in <module>
        elem = find_element_by_id_name("selectfilebox")
    NameError: name 'find_element_by_id_name' is not defined
    


Answer: It helps to inspect `driver.page_source` to see the HTML _as the driver sees
it_.

    
    
    driver.get("http://www.speedyshare.com/")
    content = driver.page_source
    with open('/tmp/out', 'wb', encoding='utf-8') as f:
        f.write(content)
    

You'll see in /tmp/out:

    
    
    <frameset rows="*"><frame src="http://www30.speedyshare.com/upload_page.php" name="index31" />
    </frameset>
    

Aha. The tag you wish to click is inside a frame. So switch to that frame
first:

    
    
    driver.switch_to.frame("index31")
    

and then you'll be able to find the element by id:

    
    
    elem = driver.find_element_by_id("selectfilebox")
    elem.click()
    

This question is essentially the same as [Selenium Unable to locate element
(Python) WebScraping](http://stackoverflow.com/q/32636453/190597); it's just
hard to know that without first knowing the solution.

