Troubles understanding finding elements in python selenium
Question: I'm trying to follow use find elements from <http://selenium-
python.readthedocs.io/locating-elements.html#locating-elements-by-class-name>;
however, they seem to work only half the time and usually on more simple
sites. I'm wondering why that is. For example, currently i am trying to locate
:

    
    
    <a class="username" title="bruceleenation" href="/profile/u/3618527996"></a> 
    

using :

    
    
    content = driver.find_element_by_class_name('username')
    

but i'm getting nothing. The html is from

<https://gyazo.com/b2a0d389da26bbd325baaa5f915d0569> or

    
    
    <body>
    
        <nav id="nav-sidebar" class="nav-main"></nav>
        <main id="page-content" class="" style="margin-right: 17px; margin-bottom: 0px;">
         <header class="header-logged"></header>
        <section class="page-content-wrapper"></section>
        <section class="media-slider" style="display: block;">
            <div class="close-slider"></div>
            <section id="slider" class="open" style="display: inline-block;">
                <a class="go-back" data-media-id="1322612612609855850_3618527996" title="Back to all media" href="javascript:void(0);"></a>
                <section class="media-viewer-wrapper viewer" data-count-comments="0" data-count-likes="1" data-url-delete="/aj/d" data-url-comment="/aj/c" data-url-unlike="/aj/ul" data-url-like="/aj/l" data-user-id="3618527996" data-media-id="1322612612609855850_3618527996">
                    <section class="mobile-user-info"></section>
                    <section class="desktop-wrapper">
                        <section class="user-image-wrapper">
                            <div class="image-like-click"></div>
                            <a class="user-image-shadow" href="javascript:void(0);">
                                <img class="user-image" alt="" src="https://scontent.cdninstagram.com/t51.2885-15/s640x640/sh0.0…493235_n.jpg?ig_cache_key=MTMyMjYxMjYxMjYwOTg1NTg1MA%3D%3D.2"></img>
                            </a>
                            <section class="image-actions-wrapper dropdown-anchor"></section>
                        </section>
                        <section class="media-viewer-info ui-front">
                            <section class="user-info-wrapper text-translate-parent-wrapper ">
                                <a class="user-avatar-wrapper profile" title="bruceleenation" href="/profile/u/3618527996"></a>
                                <section class="user-info">
                                    <a class="username" title="bruceleenation" href="/profile/u/3618527996">
    
                                        bruceleenation
    
                                    </a>
                                    <p class="full-name"></p>
                                    <div class="media-date-geo">
                                        <span></span>
                                    </div>
                                </section>
    

Any suggestions on what to do? I've tried Xpath as well.
`["//a[@class='username'"]`


Answer: You should try using [`WebDriverWait`](http://selenium-
python.readthedocs.io/waits.html#explicit-waits) to wait until element present
as below :-

    
    
    from selenium import webdriver
    from selenium.webdriver.common.by import By
    from selenium.webdriver.support.ui import WebDriverWait
    from selenium.webdriver.support import expected_conditions as EC
    
    content = WebDriverWait(driver, 10).until( EC.presence_of_element_located((By.CSS_SELECTOR, "a.username[title = 'bruceleenation']")))
    

