Verify the table column order from selenium
<p>Requirement is to verify the column order of the following table is in the correct order from its column header names. </p>

<p>Therefore, I have written down a method to cover up my requirement, which accepts an array list [String] of the table header names in the required order.</p>

<p>But it apparently does not do my requirement through the soft-Asserts as 'isDisplayed()' method is always returning 'false'.</p>

<p>Can anyone suggest me kindly further points to modify it and to get it fixed?</p>

<p><strong>HTLM Code for the table :</strong> </p>

<pre><code>&lt;table id="examMarkEntryExamList" class="display table table-bordered table-striped dynamic-table display_header_class"&gt;
    &lt;thead&gt;
        &lt;tr&gt;
            &lt;th class="text-center sortable sorted order1"&gt;Academic Year&lt;/th&gt;
            &lt;th class="text-center sortable sorted order1"&gt;Curriculum&lt;/th&gt;
            &lt;th class="text-center sortable sorted order1"&gt;Grade&lt;/th&gt;
            &lt;th class="text-center sortable sorted order1"&gt;Semester/Term&lt;/th&gt;
            &lt;th class="text-center sortable sorted order1"&gt;
                &lt;a class="pagination-cuser-point"&gt;Exam Code&lt;/a&gt;
            &lt;/th&gt;
            &lt;th class="text-center sortable sorted order1"&gt;Actions&lt;/th&gt;
        &lt;/tr&gt;
    &lt;/thead&gt;
    &lt;tbody&gt;
        &lt;tr class="odd"&gt;
            &lt;td&gt;2016-2016&lt;/td&gt;
            &lt;td&gt;LOCAL&lt;/td&gt;
            &lt;td&gt;GRADE11&lt;/td&gt;
            &lt;td&gt;2nd Term&lt;/td&gt;
            &lt;td&gt;G11SecondTerm&lt;/td&gt;
            &lt;td&gt;
        &lt;/tr&gt;
    &lt;/tbody&gt;
&lt;/table&gt;
</code></pre>

<p><strong>Selenium [Java] method to verify the column order</strong></p>

<pre><code>public void verifyColumnOrder(WebDriver driver, String tableId, ArrayList&lt;String&gt; columnHeaderList) {

        SoftAssert softassert = new SoftAssert();
        String relativeXpath = "//table[contains(@id,'"+tableId+"')]/";
        for (String columnHeader : columnHeaderList) {

           relativeXpath = relativeXpath + "/following-sibling::th[contains(.,'" + columnHeader + "')]";
             softassert.assertTrue(driver.findElement(By.xpath(relativeXpath)).isDisplayed());
    }
    softassert.assertAll();
}
</code></pre>