1. 程式人生 > >Selenium Webdriver選取多選框

Selenium Webdriver選取多選框

程式碼如下:

    WebElement selectElement = driver.findElement(By.name("selectedList"));
    Select selection = new Select(selectElement);
    selection.selectByIndex(1);
    selection.selectByIndex(0);

以下程式碼未測試:

Select s = new Select(Grid.driver().findElementById("id"))
s.selectByVisibleText(text1);
s.selectByVisibleText(text2);

    WebElement select = driver.findElement(By.name("select"));
    List<WebElement> options = select.findElements(By.tagName("option"));
    for(WebElement option : options){
        if(option.getText().equals("Name you want")) {
            option.click();
            break;
        }
    }


相關推薦

Selenium Webdriver選取

程式碼如下: WebElement selectElement = driver.findElement(By.name("selectedList")); Select selection = new Select(selectElement);

Selenium WebDriver如何處理單

可能大家會遇到同樣的問題,用Selenium IDE錄製單選框或多選框後,在指令碼中,如果想根據不同的用例,選擇不同的單選框或多選框的業務流程時,在WebDriver程式碼中如何維護呢?這裡有簡單處理的兩種方法: 方法一: WebElement select = dirve

學習15 單/標簽

con form type code pan content 多選 span div <!doctype html> <html> <head> <meta http-equiv="content-type" content="t

selenium-webdriver定位個元素

nbsp 根據 index 密碼 sys list aix ive word /*<div id="divId"> <input id="userid" type="text" value="liuhaixia" title="用戶名"

bootstrap table保留的分頁

-a sid ids nsa ide handle ons div body           initialize : function(options) { this.options = options.options; this.tableNum=op

樣式

單選 har bsp spl enter log ott min right 主要註意before和after的樣式設置,input要設置id,label要設置for值並且等於相應的input值的id HTML <!DOCTYPE html><html&

checkbox全全不和反

沒有 index ntb -1 點擊事件 ner 空數組 一個 多個 在判斷多選框中的某一個是否被選中時,我們可以用checked的屬性 選中了就返回true,沒被選中就返回false; 這是html代碼: <form action="#"> <la

jQuery操作下拉列表以及單

width http 數組 ini init 獲取多選框的值 asc cli 添加 <!DOCTYPE html> <html> <head> <meta charset="UTF-8">

Android的CheckBox()

left mage set width reset andro XML androi apk 1.布局文件 <LinearLayout xmlns:android="http://schemas.android.com/apk/res

jsp頁面帶有的grid表格,如何將勾選中的行記錄所有列數據傳送到後臺。

blank href 後臺 aaa 數據 www hue 選中 cs6 忱分慕兇釉瀑懲防慌虜敝慘緩猩http://jz.docin.com/shuvg316 帳段繁臨市杉聞壞倫捶剎空合戀http://huiyi.docin.com/ogq2843 杏燎乘安轄任凸托飯承臨

編輯文章頁面,修改側邊欄的分類的樣式。

ane admin type cat pan style stty 分類 text function change_cat_meta_postbox_css(){ ?> <style type="text/css"> .wp-tab-panel

獲取

safety safe check index this 多選 bsp name checked var idList= $("input[type=‘checkbox‘][name=‘allChoose‘]:checked"); var idList= $("input[

angular2.x 下拉選擇組件

下拉 round ice osi 界面 poi top iou open angular2.x - 5.x 的下拉多選框選擇組件 ng2 -- ng5。最近在學angular4,經常在交流群看見很多人問 下拉多選怎麽做。。。 今天就隨便寫的個。 組件源碼 百度雲 鏈接:

Bootstrap3基礎 disabled 鼠標放在方框與文字上都出現禁止標識

true set alt contain utf-8 cas 感恩 use pos 禮悟:   公恒學思合行悟,尊師重道存感恩。葉見尋根三返一,江河湖海同一體。 虛懷若谷良心主,願行無悔給最苦。讀書鍛煉養身心,誠勸且行且珍惜。   

form表單提交數據 服務器只能接受到一個數據

表單提交 form 多選 提交過去後表單中name相同的值會被後一個覆蓋,而不會被單獨識別出來。在name名稱後面加上‘[]’即可;如 name=‘user[]‘ 註意下面兩個教程的區別,我很想知道w3c怎麽讀取到的。等待指教; http://www.w3school.com.cn/tags/at

自己用ul模擬實現下拉

ogg point shee index ati ref -m order nowrap 模擬實現下拉多選框 效果如下 <!DOCTYPE html> <html lang="en"> <head> <meta char

安卓按鍵:靜態界面的變成單

備忘 bbs border class http 問題 href div false 原文地址 http://bbs.anjian.com/showtopic-658485-1.aspx核心代碼Function a UIP.SetAttribute "多選框2",

jquery如何根據name來獲得選中的值。

comm lin input this func jpg 代碼實現 title ali 根據多選框name來獲得選中的值可用如下 jquery代碼實現 1 2 3 $("input:checkbox[name=‘test‘]:checked").each(fu

jquery,js,checkbox取值和賦值

ber javascrip 支持 substr i++ 不想 put pre htm 今天一個同事不太會多選框的取值和賦值的問題,我幫他解決了一下,不想自己想的朋友可以參考一下。 獲取checkBox的值,checkBox的html如下 <input type

改變默認的 checkbox 樣式~

ima solid 默認 posit 17. 分享 設置 元素 box 效果圖: HTML代碼: <label for="Checkbox1" style="display:none;"></label> <input type="c