2016-09-30 7 views
0

WebページにHTMLテーブルがあり、テーブルが空です。以前のテストでデータが削除されたため、データは含まれません。 このテストでは、htmlテーブルが空であることを確認したい、データが入っていないことを確認したいと思います。 これを確認する最も良い方法は何ですか?私は、次のようなXPathを使用することを考えた:Selenium Python htmlテーブルにデータが含まれていないことを確認するには、テーブルが空です

//table[@id="data_configuration_edit_data_object_tab_address_rules_tb_level_rules_locality"]//tr//td//div[text()=""] 

HTMLスニペットがある:

<table id="data_configuration_edit_data_object_tab_address_rules_tb_level_rules_locality" class="GFNQNVHJE border" cellspacing="0" __gwtcellbasedwidgetimpldispatchingfocus="true" __gwtcellbasedwidgetimpldispatchingblur="true" style="min-width: 350px;"> 
<thead aria-hidden="false"> 
    <colgroup> 
     <tbody style="display: none;"/> 
     <tbody> 
      <tr> 
       <td align="center" colspan="2"> 
        <div> 
         <div class="" style="width: 100%; height: 100%; padding: 0px; margin: 0px;" aria-hidden="false"> 
          <div class="" style="width: 100%; height: 100%;" aria-hidden="false"> 
           <div class="gwt-Label">No data to display.</div> 
          </div> 
         </div> 
         <div style="width: 100%; height: 100%; padding: 0px; margin: 0px; display: none;" aria-hidden="true"> 
          <div class="GFNQNVHBE" style="width: 100%; height: 100%; display: none;" aria-hidden="true"> 
           <div class="gwt-Label"></div> 
          </div> 
         </div> 
        </div> 
       </td> 
      </tr> 
     </tbody> 
     <tfoot style="display: none;" aria-hidden="true"/> 
    </table> 

おかげで、<table>でのみ表示されるテキストは、それが空であるときと仮定するとリアズ

答えて

1

"表示するデータがありません。"は、その後、あなたが(読みやすくするためにフォーマットされた)次のようにXPathを簡素化することができます。id = "data_configuration_edit_data_object_tab_address_rules_tb_level_rules_locality @ [//テーブル:

//table[ 
    @id="data_configuration_edit_data_object_tab_address_rules_tb_level_rules_locality" 
     and 
    .='No data to display.' 
] 

xpatheval demo

+1

おかげで、私はまた、これのXpathを使用するために管理しました"] // tr // td // div [contains(text()、"表示するデータがありません ")] –

関連する問題