1

当我单击箭头时,将出现下拉菜单。这些项目在 table->ul->li-->options 内。我尝试使用 xpath 和 id 但我无法选择项目

这是我的java代码

        Select droplist3 = new Select(driver.findElement(By.xpath("//*[@id='q1']")));   
        droplist3.selectByVisibleText("What is the name of your first  elementary/primary school? (3-20 characters)");


        driver.findElement(By.xpath("//*[@id='a1']")).sendKeys("abc");
        Select droplist4 = new Select(driver.findElement(By.xpath("//*[@id='newq2']")));   
        droplist4.selectByVisibleText("When is your mother's birthday? (format: YYYY-MM-DD");
        driver.findElement(By.xpath("//*[@id='a2']")).sendKeys("cde");

这是html页面代码..

         <input type="text" waistate="haspopup-true,autocomplete-list"                                                                        wairole="textbox"  dojoattachpoint="textbox,focusNode"                      dojoattachevent="onkeypress: _onKeyPress,compositionend" class="dijitReset" autocomplete="off" role="textbox" aria-haspopup="true" aria-autocomplete="list" id="q1" tabindex="0" aria-invalid="false" aria-required="true" value="select one" aria-owns="q1_popup">

                 <input type="hidden" name="q1" value="QD-46f03ce0-05616">                                                                                                              

这里选项代码...

      <ul id="q1_popup" class="dijitReset dijitMenu xwtComboBoxPopup" style="top:      -9999px; overflow: hidden; width: 422px; height: 198px; visibility: hidden; position: absolute;" tabindex="-1"   dojoattachevent="onmousedown:_onMouseDown,onmouseup:_onMouseUp,onmouseover:_onMouseOver,onmouseout:_onMouseOut" widgetid="q1_popup">

           <li id="q1_popup_prev" class="dijitMenuItem dijitMenuPreviousButton" wairole="option"  dojoattachpoint="previousButton" role="option" style="display: none;">Previous choices</li>

          <li id="q1_popup0" class="dijitReset dijitMenuItem" role="option">select one</li>

           <li id="q1_popup1" class="dijitReset dijitMenuItem" role="option">What is the name of your first elementary/primary school? (3-20 characters)</li>

            <li id="q1_popup2" class="dijitReset dijitMenuItem" role="option">What is the name of your high school/secondary school? (3-20 characters)</li>

              <li id="q1_popup3" class="dijitReset dijitMenuItem" role="option">What was the name of your first pet? (3-20 characters)</li>

             <li id="q1_popup4" class="dijitReset dijitMenuItem" role="option">What is your dream car? (3-20 characters)</li>
             <li id="q1_popup5" class="dijitReset dijitMenuItem" role="option">What is your father's first name? (3-20 characters)</li>

             <li id="q1_popup6" class="dijitReset dijitMenuItem" role="option">What is the first vehicle you drove? (3-20 characters)</li>

         <li id="q1_popup7" class="dijitReset dijitMenuItem" role="option">What was your favorite toy as a child? (3-20 characters)</li>
         <li id="q1_popup8" class="dijitReset dijitMenuItem" role="option">What is your favorite food? (3-20 characters)</li>
         <li id="q1_popup9" class="dijitReset dijitMenuItem" role="option">When is your mother's birthday? (format: YYYY-MM-DD)</li>

         <li id="q1_popup10" class="dijitReset dijitMenuItem" role="option">When is your father's birthday? (format: YYYY-MM-DD)</li>

           <li id="q1_popup_next" class="dijitMenuItem dijitMenuNextButton" wairole="option" dojoattachpoint="nextButton" role="option" style="display: none;">More choices</li>

        </ul>
4

0 回答 0