У меня есть динамическая таблица с одним столбцом / полем под названием «ссылочные идентификаторы».Таблица динамическая, а столбец - нет.Я хочу захватить все ссылочные идентификаторы в виде строк.
Ниже приведен фрагмент ячейки, в которой находится строка «ссылочный идентификатор».Если щелкнуть эту ячейку, она будет сортировать динамическую таблицу в порядке возрастания или убывания (в зависимости от количества нажатий).
РЕДАКТИРОВАТЬ: включил весь заголовок таблицы ниже
<th tabindex="0" scope="col" id="NUMBER_headerCell_2" aria-sort="none" class="PagingGridLayout---align_start headCell_2" abbr="Reference ID">
<div id="NUMBER_column2_header" class="GridHeaderCell---grid_header_text">Reference ID<span class="GridHeaderCell---accessibilityhidden">Sortable column, activate to sort ascending</span></div>
</th>
Я проверил код и скопировал Xpath.Я пытался просто посмотреть, смогу ли я щелкнуть ячейку ссылочного идентификатора, чтобы она отсортировала список.
reports = browser.find_element_by_xpath("//*[@id='NUMBER_headerCell_2']")
reports.click()
Однако я получаю сообщение об ошибке:
NoSuchElementException: Сообщение:нет такого элемента: Невозможно найти элемент:
Я немного почесал голову здесь.Не уверен, что делать.Любая помощь приветствуется.:)
<thead>
<tr>
<th class="PagingGridLayout---checkbox">
<div class="CheckboxGroup---choice_group CheckboxGroup---no_label CheckboxGroup---align_start" role="group">
<div class="CheckboxGroup---choice_wrapper">
<div class="CheckboxGroup---choice_pair">
<input id="NUMBER_headerCell_selection_0" type="checkbox" value="0">
<label for="NUMBER_headerCell_selection_0" class="CheckboxGroup---choice_label"><span class="CheckboxGroup---accessibilityhidden">Select all rows</span></label>
</div>
</div>
</div>
</th>
<th tabindex="0" scope="col" id="NUMBER_headerCell_0" aria-sort="none" class="PagingGridLayout---align_start headCell_0" abbr="Task Name">
<div id="NUMBER_column0_header" class="GridHeaderCell---grid_header_text">Task Name<span class="GridHeaderCell---accessibilityhidden">Sortable column, activate to sort ascending</span></div>
</th>
<th tabindex="0" scope="col" id="NUMBER_headerCell_1" aria-sort="descending" class="PagingGridLayout---align_start headCell_1" abbr="Created On">
<div id="NUMBER_column1_header" class="GridHeaderCell---grid_header_text">Created On<span class="GridHeaderCell---accessibilityhidden">Sortable column, sorted descending, activate to sort ascending</span></div>
</th>
<th tabindex="0" scope="col" id="NUMBER_headerCell_2" aria-sort="none" class="PagingGridLayout---align_start headCell_2" abbr="Reference ID">
<div id="NUMBER_column2_header" class="GridHeaderCell---grid_header_text">Reference ID<span class="GridHeaderCell---accessibilityhidden">Sortable column, activate to sort ascending</span></div>
</th>
<th tabindex="0" scope="col" id="NUMBER_headerCell_3" aria-sort="none" class="PagingGridLayout---align_start headCell_3" abbr="Assigned">
<div id="NUMBER_column3_header" class="GridHeaderCell---grid_header_text">Assigned<span class="GridHeaderCell---accessibilityhidden">Sortable column, activate to sort ascending</span></div>
</th>
<th tabindex="0" scope="col" id="NUMBER_headerCell_4" aria-sort="none" class="PagingGridLayout---align_start headCell_4" abbr="Status">
<div id="NUMBER_column4_header" class="GridHeaderCell---grid_header_text">Status<span class="GridHeaderCell---accessibilityhidden">Sortable column, activate to sort ascending</span></div>
</th>
<th tabindex="0" scope="col" id="NUMBER_headerCell_5" aria-sort="none" class="PagingGridLayout---align_start headCell_5" abbr="Task">
<div id="NUMBER_column5_header" class="GridHeaderCell---grid_header_text">Task<span class="GridHeaderCell---accessibilityhidden">Sortable column, activate to sort ascending</span></div>
</th>
<th tabindex="0" scope="col" id="NUMBER_headerCell_6" aria-sort="none" class="PagingGridLayout---align_start headCell_6" abbr="Date">
<div id="NUMBER_column6_header" class="GridHeaderCell---grid_header_text">Date<span class="GridHeaderCell---accessibilityhidden">Sortable column, activate to sort ascending</span></div>
</th>
<th tabindex="0" scope="col" id="NUMBER_headerCell_7" aria-sort="none" class="PagingGridLayout---align_start headCell_7" abbr="Delivery">
<div id="NUMBER_column7_header" class="GridHeaderCell---grid_header_text"> Delivery<span class="GridHeaderCell---accessibilityhidden">Sortable column, activate to sort ascending</span></div>
</th>
<th tabindex="0" scope="col" id="NUMBER_headerCell_8" aria-sort="none" class="PagingGridLayout---icon PagingGridLayout---center headCell_8" abbr="">
<div id="NUMBER_column8_header" class="GridHeaderCell---grid_header_text"><span class="GridHeaderCell---accessibilityhidden">Sortable column, activate to sort ascending</span></div>
</th>
</tr>
</thead>
РЕДАКТИРОВАТЬ 2: Я думаю, что таблица находится в поле:
<div class="FieldLayout---field_layout"><div class="FieldLayout---accessibilityhidden"><span class="FieldLayout---field_label" id="303211e777b0011ec20d46df049f3362"></span></div><div class="FieldLayout---input_below"><div><div class="PagingGridLayout---scrollable_content"><table class="PagingGridLayout---table PagingGridLayout---scrollable PagingGridLayout---striped" aria-labelledby="303211e777b0011ec20d46df049f3362"><thead><tr><th tabindex="0" scope="col" id="303211e777b0011ec20d46df049f3362_headerCell_0" aria-sort="none" class="PagingGridLayout---align_start headCell_0" abbr="Task Name"><div id="303211e777b0011ec20d46df049f3362_column0_header" class="GridHeaderCell---grid_header_text">Task Name<span class="GridHeaderCell---accessibilityhidden">Sortable column, activate to sort ascending</span></div></th><th tabindex="0" scope="col" id="303211e777b0011ec20d46df049f3362_headerCell_1" aria-sort="ascending" class="PagingGridLayout---align_start headCell_1" abbr="Created On"><div id="303211e777b0011ec20d46df049f3362_column1_header" class="GridHeaderCell---grid_header_text">Created On<span class="GridHeaderCell---accessibilityhidden">Sortable column, sorted ascending, activate to sort descending</span></div></th><th tabindex="0" scope="col" id="303211e777b0011ec20d46df049f3362_headerCell_2" aria-sort="none" class="PagingGridLayout---align_start headCell_2" abbr="Reference ID"><div id="303211e777b0011ec20d46df049f3362_column2_header" class="GridHeaderCell---grid_header_text">Reference ID<span class="GridHeaderCell---accessibilityhidden">Sortable column, activate to sort ascending</span></div></th><th tabindex="0" scope="col" id="303211e777b0011ec20d46df049f3362_headerCell_3" aria-sort="none" class="PagingGridLayout---align_start headCell_3" abbr="Assigned To"><div id="303211e777b0011ec20d46df049f3362_column3_header" class="GridHeaderCell---grid_header_text">Assigned To<span class="GridHeaderCell---accessibilityhidden">Sortable column, activate to sort ascending</span></div></th><th tabindex="0" scope="col" id="303211e777b0011ec20d46df049f3362_headerCell_4" aria-sort="none" class="PagingGridLayout---align_start headCell_4" abbr="Status"><div id="303211e777b0011ec20d46df049f3362_column4_header" class="GridHeaderCell---grid_header_text">Status<span class="GridHeaderCell---accessibilityhidden">Sortable column, activate to sort ascending</span></div></th><th tabindex="0" scope="col" id="303211e777b0011ec20d46df049f3362_headerCell_5" aria-sort="none" class="PagingGridLayout---align_start headCell_5" abbr="Task Type"><div id="303211e777b0011ec20d46df049f3362_column5_header" class="GridHeaderCell---grid_header_text">Task Type<span class="GridHeaderCell---accessibilityhidden">Sortable column, activate to sort ascending</span></div></th><th tabindex="0" scope="col" id="303211e777b0011ec20d46df049f3362_headerCell_6" aria-sort="none" class="PagingGridLayout---align_start headCell_6" abbr="Due Date"><div id="303211e777b0011ec20d46df049f3362_column6_header" class="GridHeaderCell---grid_header_text">Due Date<span class="GridHeaderCell---accessibilityhidden">Sortable column, activate to sort ascending</span></div></th><th tabindex="0" scope="col" id="303211e777b0011ec20d46df049f3362_headerCell_7" aria-sort="none" class="PagingGridLayout---align_start headCell_7" abbr="State Delivery Region"><div id="303211e777b0011ec20d46df049f3362_column7_header" class="GridHeaderCell---grid_header_text">State Delivery Region<span class="GridHeaderCell---accessibilityhidden">Sortable column, activate to sort ascending</span></div></th><th tabindex="0" scope="col" id="303211e777b0011ec20d46df049f3362_headerCell_8" aria-sort="none" class="PagingGridLayout---icon PagingGridLayout---center headCell_8" abbr=""><div id="303211e777b0011ec20d46df049f3362_column8_header" class="GridHeaderCell---grid_header_text"><span class="GridHeaderCell---accessibilityhidden">Sortable column, activate to sort ascending</span></div></th></tr></thead><tbody><tr class=""><td class=""><div><p class="LinkGroup---link_group LinkGroup---align_start elements---global_p"><a href="https://nbnco.appiancloud.com/suite/sites/order-management/task/5654916" class="elements---global_a">Review Detailed Design</a></p></div></td><td class=""><p class="ParagraphText---richtext_paragraph ParagraphText---default_direction ParagraphText---align_start elements---global_p">20/06/2019</p></td><td class=""><div><p class="LinkGroup---link_group LinkGroup---align_start elements---global_p"><a href="https://nbnco.appiancloud.com/suite/sites/order-management/page/home/record/lQBVF6bMMOMdjxUR6YqrUD8u9p8k-hS8unK9V9i437Bur4yN7zdzNRJSMWAdApXIql8ccBvoZkua3wEEaLPwmfrIt4hML7WksA3M31Jis9t50K6rVQ/view/summary" class="elements---global_a">ROR000000003458</a></p></div></td><td class=""><p class="ParagraphText---richtext_paragraph ParagraphText---default_direction ParagraphText---align_start elements---global_p">RD Demand Deployment Design</p></td><td class=""><p class="ParagraphText---richtext_paragraph ParagraphText---default_direction ParagraphText---align_start elements---global_p">In Progress</p></td><td class=""><p class="ParagraphText---richtext_paragraph ParagraphText---default_direction ParagraphText---align_start elements---global_p">EE ORD</p></td><td class=""><p class="ParagraphText---richtext_paragraph ParagraphText---default_direction ParagraphText---align_start elements---global_p">04/07/2019</p></td><td class=""><p class="ParagraphText---richtext_paragraph ParagraphText---default_direction ParagraphText---align_start elements---global_p">VIC-TAS</p></td><td class=""><div data-thumbnail="false" class="ImageGroup---image_gallery ImageGroup---default_direction ImageGroup---center"><img class="DocumentImage---image DocumentImage---icon" src="https://nbnco.appiancloud.com/suite/rest/a/content/latest/ioBVF6bMMOMdjxUR68quAKs_DZLlxmi4D-ulyeD5psPvbhNnRNXNp4Jt80/custom/o;maxWidth=25;maxHeight=25" aria-label="20/06/2019 04:48 GMT+00:00; 04/07/2019 04:48 GMT+00:00; 7; 2; 8; 11 days 20 hours 45 minutes until due date" alt="20/06/2019 04:48 GMT+00:00; 04/07/2019 04:48 GMT+00:00; 7; 2; 8" tabindex="0"></div></td></tr><tr class=""><td class=""><div><p class="LinkGroup---link_group LinkGroup---align_start elements---global_p"><a href="https://nbnco.appiancloud.com/suite/sites/order-management/task/4574874" class="elements---global_a">Review Detailed Design</a></p></div></td><td class=""><p class="ParagraphText---richtext_paragraph ParagraphText---default_direction ParagraphText---align_start elements---global_p">21/06/2019</p></td><td class=""><div><p class="LinkGroup---link_group LinkGroup---align_start elements---global_p"><a href="https://nbnco.appiancloud.com/suite/sites/order-management/page/home/record/lQBVF6bMMOMdjxUR6YqrUD8u9p8k-hS8unK9V9i437Bur4yN7zdzNRJSMWAdApXIql8ccBvoZkua3wEEaDBwWfrznT7V5_klxQu2CFX6LKxUlnS4dc/view/summary" class="elements---global_a">ROR000000001920</a></p></div></td><td class=""><p class="ParagraphText---richtext_paragraph ParagraphText---default_direction ParagraphText---align_start elements---global_p">RD Demand Deployment Design</p></td><td class=""><p class="ParagraphText---richtext_paragraph ParagraphText---default_direction ParagraphText---align_start elements---global_p">In Progress</p></td><td class=""><p class="ParagraphText---richtext_paragraph ParagraphText---default_direction ParagraphText---align_start elements---global_p">EE ORD</p></td><td class=""><p class="ParagraphText---richtext_paragraph ParagraphText---default_direction ParagraphText---align_start elements---global_p">05/07/2019</p></td><td class=""><p class="ParagraphText---richtext_paragraph ParagraphText---default_direction ParagraphText---align_start elements---global_p">VIC-TAS</p></td><td class=""><div data-thumbnail="false" class="ImageGroup---image_gallery ImageGroup---default_direction ImageGroup---center"><img class="DocumentImage---image DocumentImage---icon" src="https://nbnco.appiancloud.com/suite/rest/a/content/latest/ioBVF6bMMOMdjxUR68quAKs_DZLlxmi4D-ulyeD5psPvbhNnRNXNp4Jt80/custom/o;maxWidth=25;maxHeight=25" aria-label="21/06/2019 04:38 GMT+00:00; 05/07/2019 04:38 GMT+00:00; 7; 2; 8; 12 days 20 hours 35 minutes until due date" alt="21/06/2019 04:38 GMT+00:00; 05/07/2019 04:38 GMT+00:00; 7; 2; 8" tabindex="0"></div></td></tr><tr class=""><td class=""><div><p class="LinkGroup---link_group LinkGroup---align_start elements---global_p"><a href="https://nbnco.appiancloud.com/suite/sites/order-management/task/4618136" class="elements---global_a">Review Detailed Design</a></p></div></td><td class=""><p class="ParagraphText---richtext_paragraph ParagraphText---default_direction ParagraphText---align_start elements---global_p">21/06/2019</p></td><td class=""><div><p class="LinkGroup---link_group LinkGroup---align_start elements---global_p"><a href="https://nbnco.appiancloud.com/suite/sites/order-management/page/home/record/lQBVF6bMMOMdjxUR6YqrUD8u9p8k-hS8unK9V9i437Bur4yN7zdzNRJSMWAdApXIql8ccBvoZkua3wEEaPExWfrqRY8d7Vgkjhl0wj8YwGA6aNQ1m4/view/summary" class="elements---global_a">ROR000000002132</a></p></div></td><td class=""><p class="ParagraphText---richtext_paragraph ParagraphText---default_direction ParagraphText---align_start elements---global_p">RD Demand Deployment Design</p></td><td class=""><p class="ParagraphText---richtext_paragraph ParagraphText---default_direction ParagraphText---align_start elements---global_p">In Progress</p></td><td class=""><p class="ParagraphText---richtext_paragraph ParagraphText---default_direction ParagraphText---align_start elements---global_p">EE ORD</p></td><td class=""><p class="ParagraphText---richtext_paragraph ParagraphText---default_direction ParagraphText---align_start elements---global_p">05/07/2019</p></td><td class=""><p class="ParagraphText---richtext_paragraph ParagraphText---default_direction ParagraphText---align_start elements---global_p">VIC-TAS</p></td><td class=""><div data-thumbnail="false" class="ImageGroup---image_gallery ImageGroup---default_direction ImageGroup---center"><img class="DocumentImage---image DocumentImage---icon" src="https://nbnco.appiancloud.com/suite/rest/a/content/latest/ioBVF6bMMOMdjxUR68quAKs_DZLlxmi4D-ulyeD5psPvbhNnRNXNp4Jt80/custom/o;maxWidth=25;maxHeight=25" aria-label="21/06/2019 06:03 GMT+00:00; 05/07/2019 06:03 GMT+00:00; 7; 2; 8; 12 days 22 hours 0 minutes until due date" alt="21/06/2019 06:03 GMT+00:00; 05/07/2019 06:03 GMT+00:00; 7; 2; 8" tabindex="0"></div></td></tr></tbody></table></div></div></div></div>