我有一張表,我需要選擇排序升序和降序按鈕。在HTML看起來像這樣選擇表上的排序按鈕
<table id="results" class="list-table" width="100%" cellspacing="0" cellpadding="0">
<tbody>
<tr class="header-row ">
<th>
<th id="field_app_job_title" class="app_job_title ">
<th id="field_app_full_name" class="app_full_name ">
<th id="field_app_individual_workflow_states" class="v0_workflow_state_definition_id_sort ">
<th id="field_app_workflow_state_entrance_reason" class="v0_workflow_state_entrance_reason_sort ">
<span class="controls">
<span class="move_left"></span>
<span class="move_right" style="display: none;"></span>
<span class="sort_asc"></span>
<span class="sort_desc"></span>
<span class="remove"></span>
</span>
Workflow State Entrance Reason
</th>
<th class="action-menu"></th>
</tr>
我曾嘗試以下:
within_table 'results' do
find('Workflow State Entrance Reason').click_link('sort_asc')
end
或
within_table 'results' do
find('v0_workflow_state_entrance_reason_sort').click_link('sort_asc')
end
即使這樣,但沒有一個位於該元件爲止。
within_table 'results' do
('input[id^="field_app_workflow_state_entrance_reason"]').click_link('sort_asc')
end
建議?
不幸的是,在每列中都有這些sort_asc的倍數。我有6或7列,這是每個頂部。所以試圖看看如何才能從標題爲「工作流程狀態入口原因」的列中選擇那些。感謝HTML代碼的正面評價。我在QA,不寫這部分。 –
你的HTML代碼是無效的,但是如果你在每個'th'列中都有'span'元素,那麼你可以使用'find(「。class-of-thsort_asc」)。click'甚至'find(「 ...「,文本:」工作流程...「),點擊」 – smefju