第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

使用 Selenium 選擇第一個(gè)值

使用 Selenium 選擇第一個(gè)值

catspeake 2021-07-29 10:00:24
我想選擇以下代碼的第一個(gè)值:<select class="form-control input-sm">    <option value="PARENT-CHILD">Parent-Child (1:Many)</option>    <option value="PRIMARY-SECONDARY">Primary-Secondary (1:Many)</option    <option value="ASSOCIATED-TO">Associated To (Many:Many)</option></select>代碼嘗試:driver.findElement(By.xpath("//*[@id=\"popover162353\"]/div[2]/div/form/div/div[1]/div[1]/select")).click();new Select(driver.findElement(By.xpath("//*[@id=\"popover162353\"]/div[2]/div/form/div/div[1]/div[1]/select"))).selectByVisibleText("Parent-Child (1:Many)");網(wǎng)址:<div class="popover-content"><div>    <div class="editableform-loading" style="display: none;"></div>    <form class="form-inline editableform" style="">        <div class="control-group form-group">            <div>                <div class="editable-input">                    <select class="form-control input-sm">                        <option value="PARENT-CHILD">Parent-Child (1:Many)</option>                        <option value="PRIMARY-SECONDARY">Primary-Secondary (1:Many)</option>                        <option –value="ASSOCIATED-TO">Associated To (Many:Many)</option>                    </select>                </div>                <div class="editable-buttons">                    <button type="submit" class="btn btn-primary btn-sm editable-submit"><i class="glyphicon glyphicon-ok"></i></button>                    <button type="button" class="btn btn-default btn-sm editable-cancel"><i class="glyphicon glyphicon-remove"></i></button>                </div>            </div>            <div class="editable-error-block help-block" style="display: none;"></div>        </div>    </form></div>
查看完整描述

3 回答

?
慕的地6264312

TA貢獻(xiàn)1817條經(jīng)驗(yàn) 獲得超6個(gè)贊

下拉是使用選擇和選項(xiàng)標(biāo)簽進(jìn)行的。您可以使用 selenium 中的 select 類。


Select dropdown = new Select(driver.findElement(By.cssSelector("select.form-control.input-sm")))  


dropdown.selectByVisibleText("Primary-Secondary (1:Many)");  

或使用 value 屬性。


dropdown.selectByValue("PRIMARY-SECONDARY");  

編輯:


您可以嘗試使用此代碼:


Select dropdown = new Select(new WebDriverWait(driver,10).until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("select.form-control.input-sm")))); 

dropdown.selectByVisibleText("Primary-Secondary (1:Many)");  


查看完整回答
反對(duì) 回復(fù) 2021-08-04
?
飲歌長嘯

TA貢獻(xiàn)1951條經(jīng)驗(yàn) 獲得超3個(gè)贊

已經(jīng)提到了很多方法,您可以使用不同的方法,例如


    WebElement dropdownEle = driver.findElement(By.xpath("//select[@class='form-control input-sm']"));

    Select Dropdown = new Select(dropdownEle);

    Dropdown.selectByIndex(1);

    //Dropdown.selectByValue("Parent-Child (1:Many)");

    //Dropdown.selectByValue("Primary-Secondary (1:Many)");

您可以使用selectByIndex(index)orselectByValue(value)或selectByVisibleText(text),但最好的使用方式是使用selectByValue(value)


查看完整回答
反對(duì) 回復(fù) 2021-08-04
?
慕沐林林

TA貢獻(xiàn)2016條經(jīng)驗(yàn) 獲得超9個(gè)贊

你可以試試這個(gè)


WebElement temp = wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//select[@class='form-control input-sm']")));

Select findValue= new Select(temp);

findValue.selectByValue("PARENT-CHILD");


查看完整回答
反對(duì) 回復(fù) 2021-08-04
  • 3 回答
  • 0 關(guān)注
  • 393 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)