Skip to content

Commit 8f24c56

Browse files
authored
Merge 90502a0 into 609b43c
2 parents 609b43c + 90502a0 commit 8f24c56

File tree

4 files changed

+11
-15
lines changed

4 files changed

+11
-15
lines changed

dotnet/src/support/UI/SelectElement.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ public void SelectByIndex(int index)
247247

248248
foreach (IWebElement option in this.Options)
249249
{
250-
if (option.GetAttribute("index") == match)
250+
if (option.GetDomProperty("index") == match)
251251
{
252252
SetSelected(option, true);
253253
return;
@@ -364,7 +364,7 @@ public void DeselectByIndex(int index)
364364
string match = index.ToString(CultureInfo.InvariantCulture);
365365
foreach (IWebElement option in this.Options)
366366
{
367-
if (match == option.GetAttribute("index"))
367+
if (match == option.GetDomProperty("index"))
368368
{
369369
SetSelected(option, false);
370370
return;

javascript/node/selenium-webdriver/lib/select.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ class Select {
191191
}
192192

193193
for (let option of options) {
194-
if ((await option.getAttribute('index')) === index.toString()) {
194+
if ((await option.getProperty('index')) === index) {
195195
await this.setSelected(option)
196196
}
197197
}
@@ -415,7 +415,7 @@ class Select {
415415
}
416416

417417
for (let option of options) {
418-
if ((await option.getAttribute('index')) === index.toString()) {
418+
if ((await option.getProperty('index')) === index) {
419419
if (await option.isSelected()) {
420420
await option.click()
421421
}

javascript/node/selenium-webdriver/test/select_test.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,10 @@ suite(
7878
let selector = new Select(
7979
driver.findElement(By.name(singleSelectValues1['name']))
8080
)
81-
for (let x in singleSelectValues1['values']) {
82-
await selector.selectByIndex(x)
81+
for (let [index, value] of singleSelectValues1['values'].entries()) {
82+
await selector.selectByIndex(index)
8383
let ele = await selector.getFirstSelectedOption()
84-
assert.deepEqual(
85-
await ele.getText(),
86-
singleSelectValues1['values'][x]
87-
)
84+
assert.deepEqual(await ele.getText(), value)
8885
}
8986
})
9087

py/selenium/webdriver/support/select.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,16 +85,15 @@ def select_by_value(self, value: str) -> None:
8585

8686
def select_by_index(self, index: int) -> None:
8787
"""Select the option at the given index. This is done by examining the
88-
"index" attribute of an element, and not merely by counting.
88+
"index" property of an element, and not merely by counting.
8989
9090
:Args:
9191
- index - The option at this index will be selected
9292
9393
throws NoSuchElementException If there is no option with specified index in SELECT
9494
"""
95-
match = str(index)
9695
for opt in self.options:
97-
if opt.get_attribute("index") == match:
96+
if opt.get_property("index") == index:
9897
self._set_selected(opt)
9998
return
10099
raise NoSuchElementException(f"Could not locate element with index {index}")
@@ -172,7 +171,7 @@ def deselect_by_value(self, value: str) -> None:
172171

173172
def deselect_by_index(self, index: int) -> None:
174173
"""Deselect the option at the given index. This is done by examining
175-
the "index" attribute of an element, and not merely by counting.
174+
the "index" property of an element, and not merely by counting.
176175
177176
:Args:
178177
- index - The option at this index will be deselected
@@ -182,7 +181,7 @@ def deselect_by_index(self, index: int) -> None:
182181
if not self.is_multiple:
183182
raise NotImplementedError("You may only deselect options of a multi-select")
184183
for opt in self.options:
185-
if opt.get_attribute("index") == str(index):
184+
if opt.get_property("index") == index:
186185
self._unset_selected(opt)
187186
return
188187
raise NoSuchElementException(f"Could not locate element with index {index}")

0 commit comments

Comments
 (0)