how to get the data from the table with python selenium if the class and xpath are always changing?
<pre><code>&lt;table border="0" cellpadding="0" cellspacing="0" class="A490847cc28c94895bcf96e98abdb2b32209xB"&gt;
                  &lt;tbody&gt;
                   &lt;tr&gt;
                    &lt;td style="vertical-align:top"&gt;
                     &lt;table border="0" cellpadding="0" cellspacing="0" class="A490847cc28c94895bcf96e98abdb2b32206" cols="8" style="border-collapse:collapse;"&gt;
                      &lt;tbody&gt;
                       &lt;tr height="0"&gt;
                        &lt;td style="WIDTH:56.91mm;min-width:56.91mm"&gt;
                        &lt;/td&gt;

                       &lt;/tr&gt;
                       &lt;tr valign="top"&gt;

                        &lt;td class="A490847cc28c94895bcf96e98abdb2b32126c Pe5cd046a24fa44ef80e79727141463c6_1_r7"&gt;
                         &lt;div class="A490847cc28c94895bcf96e98abdb2b32126"&gt;
                          Total Tutorials
                         &lt;/div&gt;
                        &lt;/td&gt;


                        &lt;td class="A490847cc28c94895bcf96e98abdb2b32144c Pe5cd046a24fa44ef80e79727141463c6_1_r7 Pe5cd046a24fa44ef80e79727141463c6_1_r6"&gt;
                         &lt;div class="A490847cc28c94895bcf96e98abdb2b32144"&gt;
                          &lt;div style="WIDTH:19.98mm;"&gt;
                           &lt;div class="A490847cc28c94895bcf96e98abdb2b32141"&gt;
                            &lt;span class="A490847cc28c94895bcf96e98abdb2b32140"&gt;
                             Attendance
                            &lt;/span&gt;
                           &lt;/div&gt;
                           &lt;div class="A490847cc28c94895bcf96e98abdb2b32143"&gt;
                            &lt;span class="A490847cc28c94895bcf96e98abdb2b32142"&gt;
                             %
                            &lt;/span&gt;
                           &lt;/div&gt;
                          &lt;/div&gt;
                         &lt;/div&gt;
                        &lt;/td&gt;
                       &lt;/tr&gt;
                       &lt;tr valign="top"&gt;
                        &lt;td class="A490847cc28c94895bcf96e98abdb2b32149cl Pe5cd046a24fa44ef80e79727141463c6_1_r5" style="HEIGHT:6.35mm;"&gt;
                         &lt;div class="A490847cc28c94895bcf96e98abdb2b32149"&gt;
                          CSFf
                         &lt;/div&gt;
                        &lt;/td&gt;
                        &lt;td class="A490847cc28c94895bcf96e98abdb2b32153cr"&gt;
                         &lt;div class="A490847cc28c94895bcf96e98abdb2b32153"&gt;
                          9
                         &lt;/div&gt;
                        &lt;/td&gt;
                        &lt;td class="A490847cc28c94895bcf96e98abdb2b32157cr"&gt;
                         &lt;div class="A490847cc28c94895bcf96e98abdb2b32157"&gt;
                          7
                         &lt;/div&gt;
                        &lt;/td&gt;
                        &lt;td class="A490847cc28c94895bcf96e98abdb2b32161cl"&gt;
                         &lt;div class="A490847cc28c94895bcf96e98abdb2b32161"&gt;
                          0
                         &lt;/div&gt;
                        &lt;/td&gt;
                        &lt;td class="A490847cc28c94895bcf96e98abdb2b32165cl"&gt;
                         &lt;div class="A490847cc28c94895bcf96e98abdb2b32165"&gt;
                          0
                         &lt;/div&gt;
                        &lt;/td&gt;
                        &lt;td class="A490847cc28c94895bcf96e98abdb2b32169cr"&gt;
                         &lt;div class="A490847cc28c94895bcf96e98abdb2b32169"&gt;
                          4.0000
                         &lt;/div&gt;
                        &lt;/td&gt;
                        &lt;td class="A490847cc28c94895bcf96e98abdb2b32173cr"&gt;
                         &lt;div class="A490847cc28c94895bcf96e98abdb2b32173"&gt;
                          4.0000
                         &lt;/div&gt;
                        &lt;/td&gt;
                        &lt;td class="A490847cc28c94895bcf96e98abdb2b32177cr Pe5cd046a24fa44ef80e79727141463c6_1_r6"&gt;
                         &lt;div class="A490847cc28c94895bcf96e98abdb2b32177"&gt;
                          84.62
                         &lt;/div&gt;
                        &lt;/td&gt;
</code></pre>

<p>I am working with python selenium web driver.I want the loop through the table for the text inside the <code>td</code> inside <code>tr</code> tag <a href="http://stackoverflow.com/questions/11533982/how-to-read-table-data-using-selenium-python">like this</a><br>But problem here is the class name is always changing and xpath and css_selector is also changing.example xpath will be like this <code>.//*[@id='P825048fc6b084257a601fde4805c8c33_1_oReportCell']/table/tbody/tr[2]/td/table/tbody/tr/td/table/tbody/tr[3]/td[8]/div</code> <br>But the <code>id</code> is changing always.so couldn't apply <code>driver.find_element_by_id()</code>.I think regular expressions or BeautifulSoup can be used to solve this.I am beginner to regex.So is there any way this could be solved?</p>

<p>You might be able to use this xpath, not sure if it's 100% correct:</p>

<pre><code>//div[text() = 'CSFf']/ancestor::tr/td[not(descendant::div[text() = 'CSFf'])]/div
</code></pre>

<p>To make it variable:</p>

<pre><code>public String getXpathForTableThing(String searchString) {

    return "//div[text() = '"+searchString+"']/ancestor::tr/td[not(descendant::div[text() = '"+searchString+"'])]/div";
}
</code></pre>

<p>I'm not experienced with python but I'm sure you get the idea and can transform this to a python function.</p>

python regex selenium-webdriver beautifulsoup