亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

使用 Selenium/Katalon 在 html 表上進行迭代

使用 Selenium/Katalon 在 html 表上進行迭代

小怪獸愛吃肉 2022-07-20 19:24:56
    我正在嘗試遍歷 HTML 表以從中獲取值,但我沒有得到想要的結果。這是 HTML 代碼:<div class="o_sale_order table-responsive">  <table class="o_list_view table table-sm table-hover table-striped o_list_view_ungrouped">    <thead>      <tr>        <th width="1" class="o_list_record_selector">          <div class="custom-control custom-checkbox">            <input type="checkbox" id="checkbox-868" class="custom-control-input">            <label for="checkbox-868" class="custom-control-label"></label></div>        </th>        <th class="o_column_sortable" data-original-title="" title="">Quotation Number</th>        <th class="o_column_sortable" data-original-title="" title="">Quotation Date</th>        <th class="o_column_sortable" data-original-title="" title="">Customer</th>        <th class="o_column_sortable" data-original-title="" title="">Salesperson</th>        <th class="o_column_sortable" style="text-align: right;" data-original-title="" title="">Total</th>        <th class="o_column_sortable" data-original-title="" title="">Status</th>      </tr>    </thead>    <tbody class="ui-sortable">      <tr class="o_data_row">        <td width="1" class="o_list_record_selector">          <div class="custom-control custom-checkbox">            <input type="checkbox" id="checkbox-869" class="custom-control-input">            <label for="checkbox-869" class="custom-control-label"></label></div>        </td>        <td class="o_data_cell o_readonly_modifier o_required_modifier">SO107</td>        <td class="o_data_cell o_required_modifier">03/04/2019 17:40:46</td>        <td class="o_data_cell o_required_modifier">AA</td>        <td class="o_data_cell">Administrator</td>        <td class="o_data_cell o_list_number o_monetary_cell o_readonly_modifier">          <span class="o_field_monetary o_field_number o_field_widget o_readonly_modifier" name="amount_total">305.00&nbsp;€</span></td>        <td class="o_data_cell o_readonly_modifier">Quotation Sent</td>      </tr>
查看完整描述

2 回答

?
侃侃爾雅

TA貢獻1801條經驗 獲得超16個贊

您可以直接在內部的第一列中找到所有表格單元格SOxxx。


List<WebElement> first_cloumns = driver.findElements(

                     By.cssSelector("div.o_sale_order tbody td:nth-child(1)"));



List<String> values = first_cloumns

                            .stream() // require JDK 8 and higher

                            .map(td -> td.getText())

                            .collect(Collectors.toList());


查看完整回答
反對 回復 2022-07-20
?
當年話下

TA貢獻1890條經驗 獲得超9個贊

試試這個 xpath。它將返回所有包含 SO 值的單元格


By.xpath("//table//td[contains(text(),'SO')]");


List<WebElement> rows = driver.findElements(By.xpath("//table//td[contains(text(),'SO')]"));


查看完整回答
反對 回復 2022-07-20
  • 2 回答
  • 0 關注
  • 102 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號