Clicking Specific button with Selenium
Question: I am trying to click a particular button with Selenium in Python, but am
having trouble identifying that particular button. For example, if I was on
the google page of [this](https://www.google.com/webhp?sourceid=chrome-
instant&ion=1&espv=2&ie=UTF-8#q=ignominious), and I wanted to have the
translation bar drop down, how would I go about referencing that specific
element. Inspecting it in my browser I see some of what I assume to be its
data as:

    
    
        <div style="clear: both;" aria-controls="uid_0" aria-expanded="false"
         class="_LJ _qxg xpdarr _WGh vk_arc" data-fbevent="fastbutton" jsaction="kx.t;
     fastbutton: kx.t" role="button" tabindex="0" data-ved="0ahUKEwiwn-6K17XLAhVLWD4KHTk9CTkQmDMILzAA">
    

However, from this point I'm not sure how I would use the find element by
functions to reference what I need to in order to call it properly.

    
    
    driver.find_element_by_*("?").click()
    
    import unittest
    from selenium import webdriver
    from selenium.webdriver.common.keys import Keys
    
    #comment
    print ("Let's talk about Python.")
    
    
    driver = webdriver.Firefox()
    
    driver.get("http://www.google.com")
    
    assert "Google" in driver.title
    
    elem = driver.find_element_by_name("q")
    
    elem.send_keys("ignominious")
    elem.send_keys(Keys.RETURN)
    
    driver.find_element_by_*("?").click()
    
    
    assert "No results found." not in driver.page_source
    
    driver.close()
    


Answer: You can use `css_selector` with the class attribute

    
    
    driver.find_element_by_css_selector("._LJ._qxg.xpdarr._WGh.vk_arc").click()
    

Or `class_name` with any one of the classes

    
    
    driver.find_element_by_class_name("_LJ").click()
    # or
    driver.find_element_by_class_name("_qxg").click()
    # or
    driver.find_element_by_class_name("xpdarr").click()
    # or
    driver.find_element_by_class_name("_WGh").click()
    # or
    driver.find_element_by_class_name("vk_arc").click()
    

Sending click to the element child will also work

    
    
    driver.find_element_by_class_name("vk_ard").click()
    

