いいえ、そうではありません。私はあなたの点を、申し訳ありませんでした。
私は複数選択要素の選択を反転したい場合はとにかく、私は(私は前に提供ページのこの3要素のドロップダウンについて)このようにそれをやる:
storeSelectedIndexes | xpath=(//select[@name='jezyk'])[4] | selected
removeAllSelections | xpath=(//select[@name='jezyk'])[4]
store | ${selected} | selected2
store | javascript{storedVars['selected2'].split(',').length} | selectedNo
store | 999 | selectedIndexNo0
store | 999 | selectedIndexNo1
store | 999 | selectedIndexNo2
store | -1 | loop1
while | ${loop1} < (${selectedNo} - 1)
store | javascript{storedVars.loop1++}
store | javascript{storedVars['selected2'].split(',')[storedVars['loop1']]} | selectedIndexNo${loop1}
endWhile |
store | -1 | loop2
while | ${loop2} < 2
store | javascript{storedVars.loop2++}
gotoIf | ${loop2} == ${selectedIndexNo0} || ${loop2} == ${selectedIndexNo1} || ${loop2} == ${selectedIndexNo2} | dontSelect
addSelection | xpath=(//select[@name='jezyk'])[4] | index=${loop2}
label | dontSelect
endWhile |
それが最も簡単な方法はありません私は思っていますが、動作します。
3つのマルチセレクト要素に適しています。
最初のループ(つつ - ENDWHILE)抽出選択インデックス及び第二のループは、以前に選択されたもの以外のすべての要素を選択します。
[OK]を、私はいくつかの変更を加え、スクリプトのこのバージョンは、任意のサイズの要素(あれば最初のラベルは、インデックス= 0を有するもの)で使用する細かいあります。あなたがしなければならないことは、検査された複数形のためのidまたはxpathを最初のコマンドに入れ、要素の中のすべてのラベルの数をstoreXpathCountか、単にそれらの数を入れるだけです。そして、複数形の大きさに応じて、 "gotoIf"コマンドに条件を増減します。
スクリプトの第二版:
//store | put here id or xpath of your dropdown | elementID
store | xpath=(//select[@name='jezyk'])[4] | elementID
storeSelectedIndexes | ${elementID} | selected
removeAllSelections | ${elementID}
store | ${selected} | selected2
store | javascript{storedVars['selected2'].split(',').length} | selectedNo
//use custom xpath or explicitly type number of labels using simple "store" command instead of "storeXpathCount"
storeXpathCount | //div[@id='content']/div/div[2]/div[31]/div/select/option | elementSize
store | -1 | loop0
while | ${loop0} < ${elementSize}
store | javascript{storedVars.loop0++}
store | 999 | selectedIndexNo${loop0}
endWhile |
store | -1 | loop1
while | ${loop1} < (${selectedNo} - 1)
store | javascript{storedVars.loop1++}
store | javascript{storedVars['selected2'].split(',')[storedVars['loop1']]} | selectedIndexNo${loop1}
endWhile |
store | -1 | loop2
while | ${loop2} < (${elementSize} - 1)
store | javascript{storedVars.loop2++}
//depending on size of your multiform element you have to add more conditions to below "gotoIf" command. At the moment it's good for three elements (labels)
gotoIf | ${loop2} == ${selectedIndexNo0} || ${loop2} == ${selectedIndexNo1} || ${loop2} == ${selectedIndexNo2} | dontSelect
addSelection | ${elementID} | index=${loop2}
label | dontSelect
endWhile |
に私は理解していない - * *現在の選択を反転することになって2つの選択を追加してどのように? – l0b0