如何在C#中获得具有相同类名的第3个div值?

时间:2017-07-06 06:06:03

标签: c# html css

如何使用C#在此代码段中获得第3个div

例如,我想在第3个div中获取类名为gwt-Label WBCI的文本。我在获得正确的价值方面遇到了问题,同时也在弄清楚我需要什么代码才能获得它

我的代码现在是这样的,但我的错误值

browser.Div(Find.ByClass("gwt-Label WBCI")).OuterText.ToString();

<ul class="WCVH WKVH" role="list">
  <li class="WIUH" role="listitem">
    <div class="WKUH">
      <label id="labeledImage.POSTED_DATE--uid6-formLabel" data-automation-id="formLabel"></label>
    </div>
    <div class="WMUH">
      <div class="WDBN WMP WDCN" data-automation-id="responsiveMonikerInput" id="labeledImage.POSTED_DATE--uid6">
        <div class="WIBN">
          <ul tabindex="-2" class="WCHJ WHBN" role="list" data-automation-id="selectedItemList">
            <li class="WGHJ" role="presentation">
              <div class="WOGJ WFHJ" tabindex="-2" id="b7e15031a749444a855366b1f1a87a46" data-automation-id="menuItem" aria-label="Posted Today, press delete to clear value." role="listitem" aria-posinset="1" aria-setsize="1">
                <div class="WPGJ">
                  <div class="WACI">
                    <ul class="WCBI WIBI" role="presentation">
                      <li class="WPBI"><img class="gwt-Image WHWI WFPJ WKQJ" src="https://vps-wd5.myworkdaycdn.com/assets/ui-html/update/WorkdayApp/8CB9E57BEDDE62E4F67DEB6E19F5308C.cache.png" draggable="false" data-automation-id="POSTED_DATE_charm" alt="" aria-label=""
                        aria-labelledby="promptOption"></li>
                    </ul>
                    <div class="gwt-Label WBCI" data-automation-id="promptOption" id="promptOption" title="Posted Today" aria-label="Posted Today" data-automation-label="Posted Today" aria-labelledby="labeledImage.POSTED_DATE--uid6-formLabel">Posted Today</div>
                    <ul class="WCBI"></ul>
                  </div>
                </div>
              </div>
            </li>
          </ul>
        </div>
      </div>
    </div>
  </li>
  <li class="WIUH" role="listitem">
    <div class="WKUH">
      <label id="labeledImage.JOB_TYPE--uid7-formLabel" data-automation-id="formLabel"></label>
    </div>
    <div class="WMUH">
      <div class="WDBN WMP WDCN" data-automation-id="responsiveMonikerInput" id="labeledImage.JOB_TYPE--uid7">
        <div class="WIBN">
          <ul tabindex="-2" class="WCHJ WHBN" role="list" data-automation-id="selectedItemList">
            <li class="WGHJ" role="presentation">
              <div class="WOGJ WFHJ" tabindex="-2" id="5c6eda594d0d46609fa4c8e2ff13e731" data-automation-id="menuItem" aria-label="Full time, press delete to clear value." role="listitem" aria-posinset="1" aria-setsize="1">
                <div class="WPGJ">
                  <div class="WACI">
                    <ul class="WCBI WIBI" role="presentation">
                      <li class="WPBI"><img class="gwt-Image WHWI WFPJ WCQJ" src="https://vps-wd5.myworkdaycdn.com/assets/ui-html/update/WorkdayApp/8CB9E57BEDDE62E4F67DEB6E19F5308C.cache.png" draggable="false" data-automation-id="JOB_TYPE_charm" alt="" aria-label="" aria-labelledby="promptOption"></li>
                    </ul>
                    <div class="gwt-Label WBCI" data-automation-id="promptOption" id="promptOption" title="Full time" aria-label="Full time" data-automation-label="Full time" aria-labelledby="labeledImage.JOB_TYPE--uid7-formLabel">Full time</div>
                    <ul class="WCBI"></ul>
                  </div>
                </div>
              </div>
            </li>
          </ul>
        </div>
      </div>
    </div>
  </li>
  <li class="WIUH" role="listitem">
    <div class="WKUH">
      <label id="labeledImage.JOB_REQ--uid8-formLabel" data-automation-id="formLabel"></label>
    </div>
    <div class="WMUH">
      <div class="WDBN WMP WDCN" data-automation-id="responsiveMonikerInput" id="labeledImage.JOB_REQ--uid8">
        <div class="WIBN">
          <ul tabindex="-2" class="WCHJ WHBN" role="list" data-automation-id="selectedItemList">
            <li class="WGHJ" role="presentation">
              <div class="WOGJ WFHJ" tabindex="-2" id="cc054d6cca664a3282855669711520d5" data-automation-id="menuItem" aria-label="T_R_1616417, press delete to clear value." role="listitem" aria-posinset="1" aria-setsize="1">
                <div class="WPGJ">
                  <div class="WACI">
                    <ul class="WCBI WIBI" role="presentation">
                      <li class="WPBI"><img class="gwt-Image WHWI WFPJ WBQJ" src="https://vps-wd5.myworkdaycdn.com/assets/ui-html/update/WorkdayApp/8CB9E57BEDDE62E4F67DEB6E19F5308C.cache.png" draggable="false" data-automation-id="JOB_REQ_charm" alt="" aria-label="" aria-labelledby="promptOption"></li>
                    </ul>
                    <div class="gwt-Label WBCI" data-automation-id="promptOption" id="promptOption" title="T_R_1616417" aria-label="T_R_1616417" data-automation-label="T_R_1616417" aria-labelledby="labeledImage.JOB_REQ--uid8-formLabel">T_R_1616417</div>
                    <ul class="WCBI"></ul>
                  </div>
                </div>
              </div>
            </li>
          </ul>
        </div>
      </div>
    </div>
  </li>
</ul>

0 个答案:

没有答案