fromseleniumimportwebdriverfromselenium.common.exceptionsimportNoSuchElementExceptionfromselenium.webdriver.common.keysimportKeysfromselenium.webdriver.support.uiimportWebDriverWaitimporttime,re#browser initbrowser=webdriver.Firefox()#wait template : 3 secondswait=WebDriverWait(browser,3)#goto googlebrowser.get('http://www.google.com')#verify title using python internal assertassert'Google'inbrowser.title#type cheese in the search area then submitelem=browser.find_element_by_name('q')elem.send_keys('cheese')elem.submit()#wait until we get the search results#see http://seleniumhq.org/docs/04_webdriver_advanced.html for detailswait.until(lambdad:d.title.lower().startswith('cheese'))assert'cheese'inbrowser.title#goto to translate toolsbrowser.find_element_by_link_text('Plus').click()#wait until the menu is displayed (french)#ExpectedConditions.elementsToBeClickable is not available in python#instead we can use is_displayed()#see http://selenium-python.readthedocs.org/en/latest/api.htmlwait.until(lambdad:d.find_element_by_link_text('Traduction').is_displayed())#translate from english to frenchbrowser.find_element_by_link_text('Traduction').click()assert'fromage'inbrowser.find_element_by_id('result_box').text