Selenium, Python, Can't Click Button by Checking the Table Items Name
<p>I am trying to improve my <code>Selenium</code> skills and for this task, I try to click a button the way that chooses it by table elements name.</p>

<p>For example, in this case, I want to locate <code>EB Trial 2</code> then click the <code>import</code> button which is related to that.</p>

<pre><code>&lt;tr ng-repeat="event in bcEvents" class="ng-scope"&gt;
            &lt;td&gt;
                &lt;div class="dib fxac"&gt;
                    &lt;i class="icon-event fs32 text-light-blue mr15"&gt;&lt;/i&gt;
                    &lt;div class="event-inner"&gt;
                        &lt;a href="" class="link link-underline db ng-binding"&gt;EB Trial2&lt;/a&gt;
                        &lt;span class="db fs-small text-light-blue ng-binding"&gt;11/15/2016&lt;/span&gt;
                    &lt;/div&gt;
                &lt;/div&gt;
            &lt;/td&gt;
            &lt;td ng-switch="bc_source"&gt;
                &lt;!-- ngSwitchWhen: 2 --&gt;&lt;div ng-switch-when="2" class="ng-scope"&gt;
                    &lt;a href="" ng-click="import_bc_event(event)" class="btn btn-icon btn-orange"&gt;
                        &lt;i class="icon icon-eventbrite-icon"&gt;&lt;/i&gt; Import
                    &lt;/a&gt;
                &lt;/div&gt;
                &lt;!-- ngSwitchWhen: 8 --&gt;
                &lt;!-- ngSwitchWhen: A --&gt;
                &lt;!-- ngSwitchWhen: 9 --&gt;
                &lt;!-- ngSwitchWhen: B --&gt;
            &lt;/td&gt;

            &lt;!-- ngIf: bc_source != 2 --&gt;
        &lt;/tr&gt;
</code></pre>

<p>I try to reach it by <code>XPath</code> but it didn't work </p>

<pre><code>driver.find_element_by_xpath("//td[contains(text(),'EB Trial2')]/preceding-sibling::td[1]").click() 
</code></pre>

<p>I can't figured it out how to do it</p>

<p>Can anybody help me about this ?</p>

<blockquote>
  <p>I want to locate EB Trial 2 then click the import button which is related to that</p>
</blockquote>

<p>You should try using <code>xpath</code> as :</p>

<pre><code>driver.find_element_by_xpath(".//td[descendant::a[text()='EB Trial2']]/following-sibling::td//a[normalize-space(.)='Import']").click()
</code></pre>

python osx google-chrome selenium