Selenium WebDriver: извлечение заголовков динамических таблиц и соответствующих значений ячеек - PullRequest
0 голосов
/ 07 сентября 2018

enter image description here

Это B2W. В таблице сотрудников столбцы для SHOP с описанием задачи могут меняться в зависимости от задания и задачи. У меня есть функция в VBA, которая извлекает все данные из всех таблиц и сохраняет их в соответствующие таблицы в Access. Однако мне нужно знать, сколько часов каждый сотрудник работал над каждым заданием. Иногда есть только одна задача. На изображении показан журнал поля с 1 заданием, 6 заданиями и одним накладным действием (PTO). Не все сотрудники будут работать над всеми задачами, как вы можете видеть. Но я хочу иметь возможность хранить сотрудника, задачу / накладные расходы и часы для этой задачи в отдельных строках для каждой задачи или действия накладных расходов. Кажется, я не могу обернуть голову, чтобы вытащить текст и соответствующий текст. HTML выглядит так:

<div id="PageContent_PageContent_EmployeesSection">
<fieldset id="employees" class="collapsingSection">
    <h2>
        <span id="PageContent_PageContent_EmployeesHeading">Employees</span>
    </h2>
    <div class="end-cap">&nbsp;</div>
    <input type="hidden" name="ctl00$ctl00$PageContent$PageContent$IsEmployeesCollapsed" id="PageContent_PageContent_IsEmployeesCollapsed" value="F" />
    <div class="box collapseContent">
        <div id="EmployeeBox" class="box-inner resize">
            <div>
                <table class="grid" cellspacing="0" cellpadding="5" rules="rows" id="PageContent_PageContent_EmployeeGrid" style="border-width:0px;width:100%;border-collapse:collapse;">
                    <thead>
                        <tr class="gridHeader">
                            <th class=" Locked" scope="col">Name</th>
                            <th scope="col">Type</th>
                            <th scope="col">Start</th>
                            <th scope="col">Stop</th>
                            <th class="numericColumn" scope="col">Work Hours</th>
                            <th class="numberHeader numericColumn" scope="col">
                                <span Title="SHOP JOB&#10;CLEAN-UP">
                                    <div class="DblHdr">
                                        <div class="DblHdrTopLeft"></div>
                                        <div>
                                            <div class="DblHdrBottomRight">SHOP|A80000
                                                <br/>CLEAN-UP
                                            </div>
                                        </div>
                                    </div>
                                </span>
                            </th>
                            <th class="numberHeader numericColumn" scope="col">
                                <span Title="SHOP JOB&#10;DELIVERY/PICKUP">
                                    <div class="DblHdr">
                                        <div class="DblHdrTopLeft"></div>
                                        <div>
                                            <div class="DblHdrBottomRight">SHOP|A80250
                                                <br/>DELIVERY/P...
                                            </div>
                                        </div>
                                    </div>
                                </span>
                            </th>
                            <th class="numberHeader numericColumn" scope="col">
                                <span Title="SHOP JOB&#10;GENERAL IMPROVEMENTS">
                                    <div class="DblHdr">
                                        <div class="DblHdrTopLeft"></div>
                                        <div>
                                            <div class="DblHdrBottomRight">SHOP|A80150
                                                <br/>GENERAL IM...
                                            </div>
                                        </div>
                                    </div>
                                </span>
                            </th>
                            <th class="numberHeader numericColumn" scope="col">
                                <span Title="SHOP JOB&#10;INVENTORY CONTROL">
                                    <div class="DblHdr">
                                        <div class="DblHdrTopLeft"></div>
                                        <div>
                                            <div class="DblHdrBottomRight">SHOP|A80100
                                                <br/>INVENTORY ...
                                            </div>
                                        </div>
                                    </div>
                                </span>
                            </th>
                            <th class="numberHeader numericColumn" scope="col">
                                <span Title="SHOP JOB&#10;LOADING/UNLOADING">
                                    <div class="DblHdr">
                                        <div class="DblHdrTopLeft"></div>
                                        <div>
                                            <div class="DblHdrBottomRight">SHOP|A80050
                                                <br/>LOADING/UN...
                                            </div>
                                        </div>
                                    </div>
                                </span>
                            </th>
                            <th class="numberHeader numericColumn" scope="col">
                                <span Title="217022, SEC1934-272C(223)TI, MULTIPLE LOCATIONS, TULSA&#10;Signals - Mast Arm Mounted">
                                    <div class="DblHdr">
                                        <div class="DblHdrTopLeft"></div>
                                        <div>
                                            <div class="DblHdrBottomRight">217022|K10000
                                                <br/>Signals - ...
                                            </div>
                                        </div>
                                    </div>
                                </span>
                            </th>
                            <th class="numberHeader numericColumn" scope="col">
                                <span Title="SHOP JOB&#10;PTO">
                                    <div class="DblHdr">
                                        <div class="DblHdrTopLeft"></div>
                                        <div>
                                            <div class="DblHdrBottomRight">SHOP|A50000
                                                <br/>PTO
                                            </div>
                                        </div>
                                    </div>
                                </span>
                            </th>
                            <th class="numberHeader numericColumn" scope="col">Total Hours</th>
                            <th class="LastCol Notes" scope="col">Notes</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr class="row_dd">
                            <td class="DescriptionColumn Locked">
                                <a id="PageContent_PageContent_EmployeeGrid_Name_0" href="EmployeeView.aspx?objectID=a39dcdb9-cfcc-4416-949d-a8e00102e5db">EMP#0'SNAME-PRIVATE</a>
                            </td>
                            <td>
                                <span id="PageContent_PageContent_EmployeeGrid_LaborType_0">Laborer</span>
                            </td>
                            <td>
                                <span id="PageContent_PageContent_EmployeeGrid_Start_0" class="time1">6:00 AM</span>
                            </td>
                            <td>
                                <span id="PageContent_PageContent_EmployeeGrid_Stop_0" class="time1">2:30 PM</span>
                            </td>
                            <td class="numericColumn">
                                <span id="PageContent_PageContent_EmployeeGrid_WorkHours_0" class="number">8.50</span>
                            </td>
                            <td class="number numericColumn">
                                <span id="PageContent_PageContent_EmployeeGrid_Account0_0" class="number">3.00</span>
                            </td>
                            <td class="number numericColumn">
                                <span id="PageContent_PageContent_EmployeeGrid_Account1_0" class="number"></span>
                            </td>
                            <td class="number numericColumn">
                                <span id="PageContent_PageContent_EmployeeGrid_Account2_0" class="number">3.00</span>
                            </td>
                            <td class="number numericColumn">
                                <span id="PageContent_PageContent_EmployeeGrid_Account3_0" class="number"></span>
                            </td>
                            <td class="number numericColumn">
                                <span id="PageContent_PageContent_EmployeeGrid_Account4_0" class="number">2.50</span>
                            </td>
                            <td class="number numericColumn">
                                <span id="PageContent_PageContent_EmployeeGrid_Account5_0" class="number"></span>
                            </td>
                            <td class="number numericColumn">
                                <span id="PageContent_PageContent_EmployeeGrid_Account6_0" class="number"></span>
                            </td>
                            <td class="number numericColumn">
                                <span id="PageContent_PageContent_EmployeeGrid_Total_0" class="number LastCol">8.50</span>
                            </td>
                            <td class="LastCol Notes">
                                <span id="PageContent_PageContent_EmployeeGrid_Notes_0" class="note GridNoteLabel">30 Min Lunch</span>
                            </td>
                        </tr>
                        <tr class="row_dd">
                            <td class="DescriptionColumn Locked">
                                <a id="PageContent_PageContent_EmployeeGrid_Name_1" href="EmployeeView.aspx?objectID=bb18a5f1-94ba-4797-9f22-a80800fbfe89">EMP#1'SNAME-PRIVATE</a>
                            </td>
                            <td>
                                <span id="PageContent_PageContent_EmployeeGrid_LaborType_1">Warehouse</span>
                            </td>
                            <td>
                                <span id="PageContent_PageContent_EmployeeGrid_Start_1" class="time1">5:45 AM</span>
                            </td>
                            <td>
                                <span id="PageContent_PageContent_EmployeeGrid_Stop_1" class="time1">3:00 PM</span>
                            </td>
                            <td class="numericColumn">
                                <span id="PageContent_PageContent_EmployeeGrid_WorkHours_1" class="number">9.25</span>
                            </td>
                            <td class="number numericColumn">
                                <span id="PageContent_PageContent_EmployeeGrid_Account0_1" class="number">7.25</span>
                            </td>
                            <td class="number numericColumn">
                                <span id="PageContent_PageContent_EmployeeGrid_Account1_1" class="number"></span>
                            </td>
                            <td class="number numericColumn">
                                <span id="PageContent_PageContent_EmployeeGrid_Account2_1" class="number">2.00</span>
                            </td>
                            <td class="number numericColumn">
                                <span id="PageContent_PageContent_EmployeeGrid_Account3_1" class="number"></span>
                            </td>
                            <td class="number numericColumn">
                                <span id="PageContent_PageContent_EmployeeGrid_Account4_1" class="number"></span>
                            </td>
                            <td class="number numericColumn">
                                <span id="PageContent_PageContent_EmployeeGrid_Account5_1" class="number"></span>
                            </td>
                            <td class="number numericColumn">
                                <span id="PageContent_PageContent_EmployeeGrid_Account6_1" class="number"></span>
                            </td>
                            <td class="number numericColumn">
                                <span id="PageContent_PageContent_EmployeeGrid_Total_1" class="number LastCol">9.25</span>
                            </td>
                            <td class="LastCol Notes">
                                <span id="PageContent_PageContent_EmployeeGrid_Notes_1" class="note GridNoteLabel">2 Hour Lunch</span>
                            </td>
                        </tr>
                        <tr class="row_dd">
                            <td class="DescriptionColumn Locked">
                                <a id="PageContent_PageContent_EmployeeGrid_Name_2" href="EmployeeView.aspx?objectID=2e1de5a2-b68d-4f5a-b9eb-a85e00fff88f">EMP#2'SNAME-PRIVATE</a>
                            </td>
                            <td>
                                <span id="PageContent_PageContent_EmployeeGrid_LaborType_2">Warehouse</span>
                            </td>
                            <td>
                                <span id="PageContent_PageContent_EmployeeGrid_Start_2" class="time1">6:00 AM</span>
                            </td>
                            <td>
                                <span id="PageContent_PageContent_EmployeeGrid_Stop_2" class="time1">2:00 PM</span>
                            </td>
                            <td class="numericColumn">
                                <span id="PageContent_PageContent_EmployeeGrid_WorkHours_2" class="number">8.00</span>
                            </td>
                            <td class="number numericColumn">
                                <span id="PageContent_PageContent_EmployeeGrid_Account0_2" class="number">2.00</span>
                            </td>
                            <td class="number numericColumn">
                                <span id="PageContent_PageContent_EmployeeGrid_Account1_2" class="number"></span>
                            </td>
                            <td class="number numericColumn">
                                <span id="PageContent_PageContent_EmployeeGrid_Account2_2" class="number">4.00</span>
                            </td>
                            <td class="number numericColumn">
                                <span id="PageContent_PageContent_EmployeeGrid_Account3_2" class="number">2.00</span>
                            </td>
                            <td class="number numericColumn">
                                <span id="PageContent_PageContent_EmployeeGrid_Account4_2" class="number"></span>
                            </td>
                            <td class="number numericColumn">
                                <span id="PageContent_PageContent_EmployeeGrid_Account5_2" class="number"></span>
                            </td>
                            <td class="number numericColumn">
                                <span id="PageContent_PageContent_EmployeeGrid_Account6_2" class="number"></span>
                            </td>
                            <td class="number numericColumn">
                                <span id="PageContent_PageContent_EmployeeGrid_Total_2" class="number LastCol">8.00</span>
                            </td>
                            <td class="LastCol Notes">
                                <span id="PageContent_PageContent_EmployeeGrid_Notes_2" class="note GridNoteLabel">30 Min Lunch</span>
                            </td>
                        </tr>
                        <tr class="row_dd">
                            <td class="DescriptionColumn Locked">
                                <a id="PageContent_PageContent_EmployeeGrid_Name_3" href="EmployeeView.aspx?objectID=33f1af77-7817-478c-b470-a80800fbfe5a">EMP#3'SNAME-PRIVATE</a>
                            </td>
                            <td>
                                <span id="PageContent_PageContent_EmployeeGrid_LaborType_3">Foreman</span>
                            </td>
                            <td>
                                <span id="PageContent_PageContent_EmployeeGrid_Start_3" class="time1">6:00 AM</span>
                            </td>
                            <td>
                                <span id="PageContent_PageContent_EmployeeGrid_Stop_3" class="time1">2:00 PM</span>
                            </td>
                            <td class="numericColumn">
                                <span id="PageContent_PageContent_EmployeeGrid_WorkHours_3" class="number">8.00</span>
                            </td>
                            <td class="number numericColumn">
                                <span id="PageContent_PageContent_EmployeeGrid_Account0_3" class="number"></span>
                            </td>
                            <td class="number numericColumn">
                                <span id="PageContent_PageContent_EmployeeGrid_Account1_3" class="number"></span>
                            </td>
                            <td class="number numericColumn">
                                <span id="PageContent_PageContent_EmployeeGrid_Account2_3" class="number"></span>
                            </td>
                            <td class="number numericColumn">
                                <span id="PageContent_PageContent_EmployeeGrid_Account3_3" class="number"></span>
                            </td>
                            <td class="number numericColumn">
                                <span id="PageContent_PageContent_EmployeeGrid_Account4_3" class="number"></span>
                            </td>
                            <td class="number numericColumn">
                                <span id="PageContent_PageContent_EmployeeGrid_Account5_3" class="number"></span>
                            </td>
                            <td class="number numericColumn">
                                <span id="PageContent_PageContent_EmployeeGrid_Account6_3" class="number">8.00</span>
                            </td>
                            <td class="number numericColumn">
                                <span id="PageContent_PageContent_EmployeeGrid_Total_3" class="number LastCol">8.00</span>
                            </td>
                            <td class="LastCol Notes">
                                <span id="PageContent_PageContent_EmployeeGrid_Notes_3" class="note GridNoteLabel">30 Min Lunch</span>
                            </td>
                        </tr>
                        <tr class="row_dd">
                            <td class="DescriptionColumn Locked">
                                <a id="PageContent_PageContent_EmployeeGrid_Name_4" href="EmployeeView.aspx?objectID=a242141d-7c34-46c4-a1db-a80800fbfe76">EMP#4'SNAME-PRIVATE</a>
                            </td>
                            <td>
                                <span id="PageContent_PageContent_EmployeeGrid_LaborType_4">Warehouse</span>
                            </td>
                            <td>
                                <span id="PageContent_PageContent_EmployeeGrid_Start_4" class="time1">5:30 AM</span>
                            </td>
                            <td>
                                <span id="PageContent_PageContent_EmployeeGrid_Stop_4" class="time1">3:30 PM</span>
                            </td>
                            <td class="numericColumn">
                                <span id="PageContent_PageContent_EmployeeGrid_WorkHours_4" class="number">10.00</span>
                            </td>
                            <td class="number numericColumn">
                                <span id="PageContent_PageContent_EmployeeGrid_Account0_4" class="number">3.00</span>
                            </td>
                            <td class="number numericColumn">
                                <span id="PageContent_PageContent_EmployeeGrid_Account1_4" class="number"></span>
                            </td>
                            <td class="number numericColumn">
                                <span id="PageContent_PageContent_EmployeeGrid_Account2_4" class="number">3.00</span>
                            </td>
                            <td class="number numericColumn">
                                <span id="PageContent_PageContent_EmployeeGrid_Account3_4" class="number">1.00</span>
                            </td>
                            <td class="number numericColumn">
                                <span id="PageContent_PageContent_EmployeeGrid_Account4_4" class="number">3.00</span>
                            </td>
                            <td class="number numericColumn">
                                <span id="PageContent_PageContent_EmployeeGrid_Account5_4" class="number"></span>
                            </td>
                            <td class="number numericColumn">
                                <span id="PageContent_PageContent_EmployeeGrid_Account6_4" class="number"></span>
                            </td>
                            <td class="number numericColumn">
                                <span id="PageContent_PageContent_EmployeeGrid_Total_4" class="number LastCol">10.00</span>
                            </td>
                            <td class="LastCol Notes">
                                <span id="PageContent_PageContent_EmployeeGrid_Notes_4" class="note GridNoteLabel">30 Min Lunch</span>
                            </td>
                        </tr>
                        <tr class="row_dd">
                            <td class="DescriptionColumn Locked">
                                <a id="PageContent_PageContent_EmployeeGrid_Name_5" href="EmployeeView.aspx?objectID=52a28556-fd96-4d16-8261-a80800fbfe82">EMP#5'SNAME-PRIVATE</a>
                            </td>
                            <td>
                                <span id="PageContent_PageContent_EmployeeGrid_LaborType_5">Warehouse</span>
                            </td>
                            <td>
                                <span id="PageContent_PageContent_EmployeeGrid_Start_5" class="time1">5:30 AM</span>
                            </td>
                            <td>
                                <span id="PageContent_PageContent_EmployeeGrid_Stop_5" class="time1">2:30 PM</span>
                            </td>
                            <td class="numericColumn">
                                <span id="PageContent_PageContent_EmployeeGrid_WorkHours_5" class="number">9.00</span>
                            </td>
                            <td class="number numericColumn">
                                <span id="PageContent_PageContent_EmployeeGrid_Account0_5" class="number"></span>
                            </td>
                            <td class="number numericColumn">
                                <span id="PageContent_PageContent_EmployeeGrid_Account1_5" class="number"></span>
                            </td>
                            <td class="number numericColumn">
                                <span id="PageContent_PageContent_EmployeeGrid_Account2_5" class="number"></span>
                            </td>
                            <td class="number numericColumn">
                                <span id="PageContent_PageContent_EmployeeGrid_Account3_5" class="number"></span>
                            </td>
                            <td class="number numericColumn">
                                <span id="PageContent_PageContent_EmployeeGrid_Account4_5" class="number">2.00</span>
                            </td>
                            <td class="number numericColumn">
                                <span id="PageContent_PageContent_EmployeeGrid_Account5_5" class="number">7.00</span>
                            </td>
                            <td class="number numericColumn">
                                <span id="PageContent_PageContent_EmployeeGrid_Account6_5" class="number"></span>
                            </td>
                            <td class="number numericColumn">
                                <span id="PageContent_PageContent_EmployeeGrid_Total_5" class="number LastCol">9.00</span>
                            </td>
                            <td class="LastCol Notes">
                                <span id="PageContent_PageContent_EmployeeGrid_Notes_5" class="note GridNoteLabel">30 Min Lunch</span>
                            </td>
                        </tr>
                    </tbody>
                    <tfoot>
                        <tr class="gridFooter">
                            <td class=" Locked">&nbsp;</td>
                            <td>&nbsp;</td>
                            <td>&nbsp;</td>
                            <td>&nbsp;</td>
                            <td class="numericColumn">
                                <span id='empworkhourtotal' class='number'>52.75</span>
                            </td>
                            <td class="numberHeader numericColumn">
                                <span class='number'>15.25</span>
                            </td>
                            <td class="numberHeader numericColumn">
                                <span class='number'>0.00</span>
                            </td>
                            <td class="numberHeader numericColumn">
                                <span class='number'>12.00</span>
                            </td>
                            <td class="numberHeader numericColumn">
                                <span class='number'>3.00</span>
                            </td>
                            <td class="numberHeader numericColumn">
                                <span class='number'>7.50</span>
                            </td>
                            <td class="numberHeader numericColumn">
                                <span class='number'>7.00</span>
                            </td>
                            <td class="numberHeader numericColumn">
                                <span class='number'>8.00</span>
                            </td>
                            <td class="numberHeader numericColumn">
                                <span class='number LastCol'>52.75</span>
                            </td>
                            <td class="LastCol Notes">&nbsp;</td>
                        </tr>
                    </tfoot>
                </table>
            </div>
        </div>
    </div>
</fieldset>

В настоящее время я просто извлекаю общее количество часов для каждого сотрудника, но мне бы очень хотелось вытащить задачу или накладные действия (то есть заголовки столбцов с классом "DblHdrBottomRight") и количество часов для каждого из этих задач на одного работника. Кто-нибудь видел что-нибудь подобное раньше?

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...