通过两个child div的属性识别一个div
Identify a div by the properties of two child divs
我正在尝试确定符合两个条件(类别和位置)的行 div。这将允许我对与 xpath 匹配的那些行执行 storeXpathCount - 因此我可以确认显示的行数正确。
我有以下 HTML:
<div class="cs_course_list_row cs_default">
<div class="cs_course_category">Cat 1150 31397 A</div>
<div class="cs_course_location">Loc 1150 31397 A </div>
</div>
我想根据内部 div 中的内容来识别 div 和 class 'cs_course_list_row'。这是我尝试过的(在许多其他排列中):
//div[contains(@class,'cs_course_list_row') and contains[div(contains(.,'Loc 1150 31397 A'))] and contains[div(contains(.,'Cat 1150 31397 A'))]]
注意第二个 div 中 'Loc 1150 31397 A' 之后的 space,因此使用 'contains' 而不是 =
感谢您的帮助...
尝试以下 XPath
以匹配所需 div
//div[contains(@class,'cs_course_list_row') and ./div[normalize-space()='Loc 1150 31397 A'] and ./div[normalize-space()='Cat 1150 31397 A']]
我正在尝试确定符合两个条件(类别和位置)的行 div。这将允许我对与 xpath 匹配的那些行执行 storeXpathCount - 因此我可以确认显示的行数正确。
我有以下 HTML:
<div class="cs_course_list_row cs_default">
<div class="cs_course_category">Cat 1150 31397 A</div>
<div class="cs_course_location">Loc 1150 31397 A </div>
</div>
我想根据内部 div 中的内容来识别 div 和 class 'cs_course_list_row'。这是我尝试过的(在许多其他排列中):
//div[contains(@class,'cs_course_list_row') and contains[div(contains(.,'Loc 1150 31397 A'))] and contains[div(contains(.,'Cat 1150 31397 A'))]]
注意第二个 div 中 'Loc 1150 31397 A' 之后的 space,因此使用 'contains' 而不是 =
感谢您的帮助...
尝试以下 XPath
以匹配所需 div
//div[contains(@class,'cs_course_list_row') and ./div[normalize-space()='Loc 1150 31397 A'] and ./div[normalize-space()='Cat 1150 31397 A']]