Note that there are some explanatory texts on larger screens.

plurals
  1. POSelenium Java and visable table testing
    primarykey
    data
    text
    <p>I am trying to work with a table here and it has my head cooked to a fine crisp. So the test is, load the page and confirm the “Load Schedule” button is there. Also assert that the Table headers are present and contain the expected text. That is complete and working. Here is the HTML off the table before clicking on “Load Schedule”</p> <pre><code>&lt;table id="scheduleTable" class="audit_table"&gt; &lt;thead&gt; &lt;tr&gt; &lt;th class="date-header red_grade"&gt;Kick Off(UTC)&lt;/th&gt; &lt;th class="narrow-header red_grade"&gt;RBallId&lt;/th&gt; &lt;th class="narrow-header red_grade"&gt;GSMId&lt;/th&gt; &lt;th class="narrow-header red_grade"&gt;WBId&lt;/th&gt; &lt;th class="country-header red_grade"&gt;Country&lt;/th&gt; &lt;th class="header red_grade" style="display:none"&gt;Sport&lt;/th&gt; &lt;th class="header red_grade" style="display:none"&gt;SportId&lt;/th&gt; &lt;th class="header red_grade"&gt;League&lt;/th&gt; &lt;th class="header red_grade "&gt;Home&lt;/th&gt; &lt;th class="header red_grade"&gt;Away&lt;/th&gt; &lt;th class="header red_grade"&gt;Languages&lt;/th&gt; &lt;/tr&gt; &lt;/thead&gt; &lt;tbody&gt; &lt;/tbody&gt; &lt;/table&gt; </code></pre> <p>Now when I click the Load Schedule button, a new “tbody” element is added to the page as so:</p> <pre><code>&lt;tbody&gt;&lt;tr class="odd"&gt; &lt;td class="Kickoff"&gt;2013-09-02 14:30:00&lt;/td&gt; &lt;td class="RBallId"&gt;327097&lt;/td&gt; &lt;td class="GSMId"&gt;0&lt;/td&gt; &lt;td class="WBId"&gt;0&lt;/td&gt; &lt;td class="Country"&gt;South Africa-(82)&lt;/td&gt; &lt;td class="Sport" style="display:none"&gt;Soccer&lt;/td&gt; &lt;td class="SportId" style="display:none"&gt;1&lt;/td&gt; &lt;td class="League"&gt;Varsity Football Challenge&lt;/td&gt; &lt;td class="Home"&gt;University of the Western Cape - UWC (students)&lt;/td&gt; &lt;td class="Away"&gt;University of Cape Town - UCT (students)&lt;/td&gt; &lt;td class="Languages"&gt;&lt;/td&gt; &lt;/tr&gt;&lt;tr class="even"&gt; &lt;td class="Kickoff"&gt;2013-09-02 14:45:00&lt;/td&gt; &lt;td class="RBallId"&gt;338082&lt;/td&gt; &lt;td class="GSMId"&gt;0&lt;/td&gt; &lt;td class="WBId"&gt;0&lt;/td&gt; &lt;td class="Country"&gt;Friendly-(20)&lt;/td&gt; &lt;td class="Sport" style="display:none"&gt;Soccer&lt;/td&gt; &lt;td class="SportId" style="display:none"&gt;1&lt;/td&gt; &lt;td class="League"&gt;Friendly INT Women U19&lt;/td&gt; &lt;td class="Home"&gt;Greece U19&lt;/td&gt; &lt;td class="Away"&gt;Turkey U19&lt;/td&gt; &lt;td class="Languages"&gt;&lt;/td&gt; &lt;/tr&gt;&lt;tr class="odd"&gt; &lt;td class="Kickoff"&gt;2013-09-02 15:00:00&lt;/td&gt; &lt;td class="RBallId"&gt;336937&lt;/td&gt; &lt;td class="GSMId"&gt;1421234&lt;/td&gt; &lt;td class="WBId"&gt;0&lt;/td&gt; &lt;td class="Country"&gt;Estonia-(2)&lt;/td&gt; &lt;td class="Sport" style="display:none"&gt;Soccer&lt;/td&gt; &lt;td class="SportId" style="display:none"&gt;1&lt;/td&gt; &lt;td class="League"&gt;Meistriliiga&lt;/td&gt; &lt;td class="Home"&gt;Kalju&lt;/td&gt; &lt;td class="Away"&gt;Kuressaare&lt;/td&gt; &lt;td class="Languages"&gt;&lt;/td&gt; &lt;/tr&gt;&lt;tr class="even"&gt; &lt;td class="Kickoff"&gt;2013-09-02 15:00:00&lt;/td&gt; &lt;td class="RBallId"&gt;331340&lt;/td&gt; &lt;td class="GSMId"&gt;1571623&lt;/td&gt; &lt;td class="WBId"&gt;0&lt;/td&gt; &lt;td class="Country"&gt;Sweden-(48)&lt;/td&gt; &lt;td class="Sport" style="display:none"&gt;Soccer&lt;/td&gt; &lt;td class="SportId" style="display:none"&gt;1&lt;/td&gt; &lt;td class="League"&gt;U21 B-Playoffs&lt;/td&gt; &lt;td class="Home"&gt;Halmstad U21&lt;/td&gt; &lt;td class="Away"&gt;Kalmar U21&lt;/td&gt; &lt;td class="Languages"&gt;&lt;/td&gt; &lt;/tr&gt;&lt;tr class="odd"&gt; &lt;td class="Kickoff"&gt;2013-09-02 15:00:00&lt;/td&gt; &lt;td class="RBallId"&gt;331348&lt;/td&gt; &lt;td class="GSMId"&gt;1571636&lt;/td&gt; &lt;td class="WBId"&gt;0&lt;/td&gt; &lt;td class="Country"&gt;Sweden-(48)&lt;/td&gt; &lt;td class="Sport" style="display:none"&gt;Soccer&lt;/td&gt; &lt;td class="SportId" style="display:none"&gt;1&lt;/td&gt; &lt;td class="League"&gt;U21 B-Playoffs&lt;/td&gt; &lt;td class="Home"&gt;Åtvidaberg U21&lt;/td&gt; &lt;td class="Away"&gt;Gefle U21&lt;/td&gt; &lt;td class="Languages"&gt;&lt;/td&gt; &lt;/tr&gt;&lt;tr class="even"&gt; </code></pre> <p>And so on and on and on. </p> <p>What I want to be able to do, is to check that before I click the button, the only thing visible is the Header, and then when I click the “Load Schedule” button, I want to take the row count and assert that it is > 0. </p> <p>I have tried several examples from here and from Google but haven’t had much joy in getting any off them to work in the manner I wish. </p> <p>I did the below as another method but that failed badly:</p> <pre><code> private boolean isElementPresent(WebDriverBackedSelenium webBrowser, String xpath) { try { driver.getWrappedDriver().findElement(By.xpath("//*[@id=\"scheduleTable\"]/tbody/tr[1]")); return true; } catch (Exception e) { return false; } } </code></pre> <p>As usual I appreciate any time taken to help me out on this one </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload