로 이동 나는 각 행은 확장 된 첫 번째 행과 같은 구문을 포함하는 다음과 같은 HTML을특정 클래스의 모든 요소를 얻기 플러스 앞뒤로 CodedUI
`<table id="tableRepeat44" class="scaledTableGroup">
<tbody>
<tr>
<tr class="grpTableRegRow">
<td class="borderCell" title="Strongly Disagree">
<input id="QID16108TAG1" value="1" name="QID16108TAG" type="radio">
<td class="borderCell" title="Disagree">
<input id="QID16108TAG2" value="2" name="QID16108TAG" type="radio">
<td class="borderCell" title="Somewhat Disagree">
<input id="QID16108TAG3" value="3" name="QID16108TAG" type="radio">
<td class="borderCell" title="Somewhat Agree">
<input id="QID16108TAG4" value="4" name="QID16108TAG" type="radio">
<td class="borderCell" title="Agree">
<input id="QID16108TAG5" value="5" name="QID16108TAG" type="radio">
<td class="borderCell" title="Strongly Agree">
<input id="QID16108TAG6" value="6" name="QID16108TAG" type="radio">
<td class="questionColumn">
<span id="lblsubq16108_7" class="Answer">This is a question. </span>
</td>
</tr>
<tr class="grpTableAltRow">
<tr class="grpTableRegRow">
<tr class="grpTableAltRow">
</tbody>
</table>`
있습니다. 내가 CodedUI를 통해 할 일은 모든 질문 (예 : td : nth-of-type (7)> span || class = "Answer")을 얻은 다음 부모 행으로 이동하여 Agree/Disagree 라디오 버튼 tds에 액세스하여 전달 된 매개 변수를 기반으로 선택을 할 수 있습니다.
나는
HtmlCustom questionsTable = new HtmlCustom(browser);
HtmlControl controls = new HtmlControl(questionsTable);
if (howToAnswer.Trim().ToLower() == "correct")
{
questionsTable.SearchProperties[HtmlCustom.PropertyNames.TagName] = "Tbody";
controls.SearchProperties.Add(HtmlControl.PropertyNames.Class, "Answer");
UITestControlCollection collection = controls.FindMatchingControls();
foreach (UITestControl answers in collection)
{
Debug.Write(answers);
}
}
의 변화를 시도했다 그리고 그것은 테이블의 각 행에 대해 ControlType [Pane] ClassName [HtmlPane] TagName [SPAN], UniqueIdentifier [154] Id [lblsubq16172_7] Name []
결과. 그래서 가까이에 있었지만 .InnerText
에 대한 텍스트를 얻는 방법을 알아낼 수 없었습니다. answers
에 액세스 할 수 없습니다.
마지막으로 다루는 항목은 특정 행에 대한 참조를 유지하면서 앞뒤로 탐색하는 방법일까요?
다음 HtmlSpan theAnswer = (HtmlSpan) 답변을 수행하여 텍스트 문제를 해결했습니다. Debug.WriteLine (theAnswer.InnerText); '그러나 참조를 유지하면서 요소를 탐색하는 방법은 아직 약간 분실 상태입니다. –