如何计算Protractor Jasmine中没有id的行数?

时间:2017-03-13 15:44:04

标签: automation protractor automated-tests jasmine-node

由于我刚开始探索量角器,我对如何计算量角器中的行数没有任何了解。有人可以帮我找到吗?

登录页面后,我应该匹配行数。我尝试过的所有内容都会产生超时错误。

Failed: Timed out waiting for Protractor to synchronize with the page after
11 seconds. Please see https://github.com/angular/protractor/blob/master/docs/fa
q.md
Stack:
ScriptTimeoutError: asynchronous script timeout: result was not received in
11 seconds

以上是我收到的错误消息..

  <table class="table table-bordered">
                      <thead>
                          <tr>

                              <th>Data Source</th><th>Server Name</th>
                              <th>Latest Source Refresh Date</th>
                              <th>QA Last Completed</th>
                              <th>Ran By</th>
                              <th><label><input type="checkbox">&nbsp;Include in QA</label></th>
                          </tr>
                      </thead>
                      <tbody>
                          <!--template bindings={}--><tr class="success">

                              <td>Austria</td><td>CDTSSQL580P.WHSVC_AT_M_IMS_1</td>
                              <td>
                                 <!--template bindings={}--><span> Mar 08, 17</span>
                                 <!--template bindings={}--> 

                              </td>
                              <td>Mar 02, 17, 11:28 AM</td>
                              <td>ims</td>
                              <td>
                                  <!--template bindings={}--><input type="checkbox">
                                  <!--template bindings={}-->
                              </td>
                          </tr><tr class="success">

                              <td>Bulgaria</td><td>CDTSSQL807P.WHSVC_BG_M_IMS_1</td>
                              <td>
                                 <!--template bindings={}--><span> Feb 22, 17</span>
                                 <!--template bindings={}--> 

                              </td>
                              <td>Feb 15, 17, 12:15 PM</td>
                              <td>ims</td>
                              <td>
                                  <!--template bindings={}--><input type="checkbox">
                                  <!--template bindings={}-->
                              </td>
                          </tr><tr class="success">

                              <td>Czech</td><td>CDTSSQL484P.WHSVC_CZ_M_IMS_1</td>
                              <td>
                                 <!--template bindings={}--><span> Mar 12, 17</span>
                                 <!--template bindings={}--> 

                              </td>
                              <td>Feb 15, 17, 4:44 AM</td>
                              <td>ims</td>
                              <td>
                                  <!--template bindings={}--><input type="checkbox">
                                  <!--template bindings={}-->
                              </td>
                          </tr><tr class="success">

                              <td>Germany</td><td>CDTSSQL826P.WHSVC_DE_M_IMS_1</td>
                              <td>
                                 <!--template bindings={}--><span> Mar 11, 17</span>
                                 <!--template bindings={}--> 

                              </td>
                              <td>Feb 15, 17, 4:40 AM</td>
                              <td>ims</td>
                              <td>
                                  <!--template bindings={}--><input type="checkbox">
                                  <!--template bindings={}-->
                              </td>
                          </tr><tr class="success">

                              <td>Italy</td><td>CDTSSQL350P.WHSVC_IT_M_IMS_1</td>
                              <td>
                                 <!--template bindings={}--><span> Mar 05, 17</span>
                                 <!--template bindings={}--> 

                              </td>
                              <td>Feb 15, 17, 4:45 AM</td>
                              <td>ims</td>
                              <td>
                                  <!--template bindings={}--><input type="checkbox">
                                  <!--template bindings={}-->
                              </td>
                          </tr><tr class="success">

                              <td>Serbia</td><td>CDTSSQL826P.WHSVC_SR_M_IMS_1</td>
                              <td>
                                 <!--template bindings={}--><span> Feb 20, 17</span>
                                 <!--template bindings={}--> 

                              </td>
                              <td>Feb 15, 17, 4:46 AM</td>
                              <td>ims</td>
                              <td>
                                  <!--template bindings={}--><input type="checkbox">
                                  <!--template bindings={}-->
                              </td>
                          </tr><tr class="success">

                              <td>Slovakia</td><td>CDTSSQL807P.WHSVC_SK_M_IMS_1</td>
                              <td>
                                 <!--template bindings={}--><span> Mar 11, 17</span>
                                 <!--template bindings={}--> 

                              </td>
                              <td>Feb 15, 17, 4:46 AM</td>
                              <td>ims</td>
                              <td>
                                  <!--template bindings={}--><input type="checkbox">
                                  <!--template bindings={}-->
                              </td>
                          </tr><tr class="success">

                              <td>Turkey</td><td>CDTSSQL484P.WHSVC_TR_M_IMS_1</td>
                              <td>
                                 <!--template bindings={}--><span> Mar 06, 17</span>
                                 <!--template bindings={}--> 

                              </td>
                              <td>Feb 15, 17, 4:46 AM</td>
                              <td>ims</td>
                              <td>
                                  <!--template bindings={}--><input type="checkbox">
                                  <!--template bindings={}-->
                              </td>
                          </tr><tr class="success">

                              <td>UK</td><td>CDTSSQL807P.WHSVC_UK_M_IMS_1</td>
                              <td>
                                 <!--template bindings={}--><span> Mar 08, 17</span>
                                 <!--template bindings={}--> 

                              </td>
                              <td>Feb 15, 17, 4:46 AM</td>
                              <td>ims</td>
                              <td>
                                  <!--template bindings={}--><input type="checkbox">
                              <!--template bindings={}-->
                          </td>
                      </tr>
                  </tbody>
              </table>

2 个答案:

答案 0 :(得分:1)

 element.all(by.css('tbody tr')).then(function(totalRows) {
    console.log(totalRows.length);  
    //OR Any expect(...)
 });

答案 1 :(得分:0)

您可以使用count()中的ElementArrayFinder方法获取给定定位器的元素数。

expect(element.all(by.css("table tbody tr")).count()).toBeGreaterThan(0);

要避免ScriptTimeOutError,请增加conf.js中的脚本超时值。将以下值添加到配置文件中。 allScriptsTimeout : 60000