File tree Expand file tree Collapse file tree 1 file changed +10
-12
lines changed
Expand file tree Collapse file tree 1 file changed +10
-12
lines changed Original file line number Diff line number Diff line change @@ -97,23 +97,17 @@ public function getFirstSelectedOption()
9797 */
9898 public function selectByIndex ($ index )
9999 {
100- $ matched = false ;
101100 foreach ($ this ->getOptions () as $ option ) {
102101 if ($ option ->getAttribute ('index ' ) === (string ) $ index ) {
103102 if (!$ option ->isSelected ()) {
104103 $ option ->click ();
105- if (!$ this ->isMultiple ()) {
106- return ;
107- }
108104 }
109- $ matched = true ;
105+
106+ return ;
110107 }
111108 }
112- if (!$ matched ) {
113- throw new NoSuchElementException (
114- sprintf ('Cannot locate option with index: %d ' , $ index )
115- );
116- }
109+
110+ throw new NoSuchElementException (sprintf ('Cannot locate option with index: %d ' , $ index ));
117111 }
118112
119113 /**
@@ -262,8 +256,12 @@ public function deselectByIndex($index)
262256 }
263257
264258 foreach ($ this ->getOptions () as $ option ) {
265- if ($ option ->getAttribute ('index ' ) === (string ) $ index && $ option ->isSelected ()) {
266- $ option ->click ();
259+ if ($ option ->getAttribute ('index ' ) === (string ) $ index ) {
260+ if ($ option ->isSelected ()) {
261+ $ option ->click ();
262+ }
263+
264+ return ;
267265 }
268266 }
269267 }
You can’t perform that action at this time.
0 commit comments