如何在更改页码后获取表中更新的行数

时间:2016-12-08 12:19:32

标签: selenium

实际上在表中,我正在进行分页。我可以得到第一页中存在的行数。

当我更改页码时,表行计数没有按照第二页进行更新。

如何在更改页码后强制selenium更新计数。页面刷新不是解决方案,因为我需要再次导航到第二页

public Boolean checkMessageIsFailed(String message, String channelNameToCheck, String channelTypeToCheck) {

        UIPublish uiPublish = new UIPublish(driver);

        Boolean isMessageSent = null;

        SimplifyUtils.waitTillElementFound(uiPublish.currentPageNumber, 60);

        //getting the page count
        int pageCount = Integer.parseInt( uiPublish.totalPages.getText());

        for (int j=1; j< pageCount;pageCount++)
        {
            //getting the rows present in the table
            int messagesCount = uiPublish.listOfTextInMessages.size(); 

            for (int i = 0; i < messagesCount; i++) 
            {

                //getting the text from each row to match
                //matching the text of the required message sent with the messages present in the sent messages

                if (uiPublish.listOfTextInMessages.get(i).getText().equalsIgnoreCase(message)) 
                {
                    String currentChannel = driver.findElements(By.xpath("//*[@id='inbox-wrapper']//tr["+ (i + 1)+ "]")).get(i).getAttribute("data-original-title");

                }
            }
            //navigating to naxt page if the condition is not matched
            uiPublish.navigateToNextPage.click();
        }
        return isMessageSent;   
    }

Page number for the table

<div class="grid simple">
  <div class="grid-body no-border email-body">
    <br>
    <div class="row-fluid">
      <div id="email-list" class="table-responsive">
        <form id="schMsgFORM" name="schMsgFORM" action="/viewSentSchMessage.action"
              method="post">
          <table class="table  table-striped table-hover" id="emails">
            <thead>
              <tr>
                <th>
                </th>
                <th>Social Channel
                </th>
                <th>Message
                </th>
                <th>Scheduled Time
                </th>
                <th>Actions
                </th>
              </tr>
            </thead>
            <tbody>
              <tr id="outputWTFrUjUyYlE1d1piNG1XUmNuUFBnUT09">
                <td class="small-cell v-align-middle" style="width: 2%">
                  <div class="checkbox check-success ">
                    <input name="msgcheckbox" id="chkboxWTFrUjUyYlE1d1piNG1XUmNuUFBnUT09"
                           value="WTFrUjUyYlE1d1piNG1XUmNuUFBnUT09" type="checkbox">
                    <label for="chkboxWTFrUjUyYlE1d1piNG1XUmNuUFBnUT09"></label>
                  </div>
                </td>
                <td style="width: 150px">
                  <div class="account-sent">
                    <div class="row">
                      <div class="display-inline">
                        <div class="profile-pic" data-toggle="tooltip" title=""
                             data-original-title="galloway360">
                          <img class="account-profile"
                               src="http://pbs.twimg.com/profile_images/378800000473105984/b0ad2b50b4fb81303d32720afea274ea_normal.png"
                               alt="">
                          <div class="social-icon-pub">
                            <span
                                  class="social-icon-twitter img-responsive social-icon-box">
                            </span>
                          </div>
                        </div>
                      </div>
                    </div>
                  </div>
                </td>
                <td style="width: 50%">
                  <div class="muted message-wrap">
                    <br>
                    Source: Auto 2016/12/08 17:35:30 Message: How's your day?
                  </div>
                  <p class="sch-details">
                    Sent by: Nagarjuna reddy
                    <em>Scheduled from Profile :
                      NA
                    </em>
                  </p>
                </td>
                <td style="width: 15%">
                  <p class="muted m-t-5">
                    2016-12-08 05:35 PM
                  </p>
                  <p class="region">
                    (Asia/Calcutta)
                  </p>
                </td>
                <td style="width: 10%">
                  <a
                     href="/social/editUpdate?s360securetoken=SU0wxc4jrR8DE8Lf5hzKnRYasjg&amp;schMsgId=WTFrUjUyYlE1d1piNG1XUmNuUFBnUT09&amp;pageSource=publish"
                     data-toggle="tooltip" title="" type="button"
                     class="btn btn-success btn-small" data-original-title="Edit">
                    <i class="fa fa-pencil">
                    </i>
                  </a>
                </td>
              </tr>
            </tbody>
          </table>
        </form>
      </div>
    </div>
  </div>
</div>

0 个答案:

没有答案