A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/seleniumhq/selenium/commit/f207270082d762764fd0b05328f87eb6ea5efcbe below:

[rb] do not allow Select class to select disabled options · SeleniumHQ/selenium@f207270 · GitHub

@@ -23,6 +23,10 @@ module Selenium

23 23

module WebDriver

24 24

module Support

25 25

describe Select do

26 +

let(:select) { Select.new(driver.find_element(name: 'selectomatic')) }

27 +

let(:multi_select) { Select.new(driver.find_element(id: 'multi')) }

28 +

let(:single_disabled) { Select.new(driver.find_element(name: 'single_disabled')) }

29 +

let(:multi_disabled) { Select.new(driver.find_element(name: 'multi_disabled')) }

26 30 27 31

before { driver.navigate.to url_for('formPage.html') }

28 32

@@ -85,8 +89,6 @@ module Support

85 89

end

86 90 87 91

context 'when multiple select' do

88 -

let(:multi_select) { Select.new(driver.find_element(id: 'multi')) }

89 - 90 92

context 'when by text' do

91 93

it 'already selected stays selected' do

92 94

multi_select.select_by(:text, 'Sausages')

@@ -112,6 +114,12 @@ module Support

112 114

expect(selected_options).to include(driver.find_element(css: 'option[value="onion gravy"]'))

113 115

end

114 116 117 +

it 'errors when option disabled' do

118 +

expect {

119 +

multi_disabled.select_by(:text, 'Disabled')

120 +

}.to raise_exception(Error::UnsupportedOperationError)

121 +

end

122 + 115 123

it 'errors when not found' do

116 124

expect { multi_select.select_by(:text, 'invalid') }.to raise_exception(Error::NoSuchElementError)

117 125

end

@@ -134,6 +142,10 @@ module Support

134 142

expect(selected_options).to include(driver.find_element(css: 'option[value=ham]'))

135 143

end

136 144 145 +

it 'errors when option disabled' do

146 +

expect { multi_disabled.select_by(:index, 1) }.to raise_exception(Error::UnsupportedOperationError)

147 +

end

148 + 137 149

it 'errors when not found' do

138 150

expect { multi_select.select_by(:index, 5) }.to raise_exception(Error::NoSuchElementError)

139 151

end

@@ -156,15 +168,19 @@ module Support

156 168

expect(selected_options).to include(driver.find_element(css: 'option[value=ham]'))

157 169

end

158 170 171 +

it 'errors when option disabled' do

172 +

expect {

173 +

multi_disabled.select_by(:value, 'disabled')

174 +

}.to raise_exception(Error::UnsupportedOperationError)

175 +

end

176 + 159 177

it 'errors when not found' do

160 178

expect { multi_select.select_by(:value, 'invalid') }.to raise_exception(Error::NoSuchElementError)

161 179

end

162 180

end

163 181

end

164 182 165 183

context 'when single select' do

166 -

let(:select) { Select.new(driver.find_element(name: 'selectomatic')) }

167 - 168 184

context 'when by text' do

169 185

it 'already selected stays selected' do

170 186

select.select_by(:text, 'One')

@@ -186,6 +202,12 @@ module Support

186 202

expect(select.selected_options).to eq([expected_option])

187 203

end

188 204 205 +

it 'errors when option disabled' do

206 +

expect {

207 +

single_disabled.select_by(:text, 'Disabled')

208 +

}.to raise_exception(Error::UnsupportedOperationError)

209 +

end

210 + 189 211

it 'errors when not found' do

190 212

expect { select.select_by(:text, 'invalid') }.to raise_exception(Error::NoSuchElementError)

191 213

end

@@ -206,8 +228,12 @@ module Support

206 228

expect(selected_options).to eq([driver.find_element(css: 'option[value="two"]')])

207 229

end

208 230 231 +

it 'errors when option disabled' do

232 +

expect { single_disabled.select_by(:index, 1) }.to raise_exception(Error::UnsupportedOperationError)

233 +

end

234 + 209 235

it 'errors when not found' do

210 -

expect { select.select_by(:index, 4) }.to raise_exception(Error::NoSuchElementError)

236 +

expect { select.select_by(:index, 5) }.to raise_exception(Error::NoSuchElementError)

211 237

end

212 238

end

213 239

@@ -226,6 +252,12 @@ module Support

226 252

expect(selected_options).to eq([driver.find_element(css: 'option[value="two"]')])

227 253

end

228 254 255 +

it 'errors when option disabled' do

256 +

expect {

257 +

single_disabled.select_by(:value, 'disabled')

258 +

}.to raise_exception(Error::UnsupportedOperationError)

259 +

end

260 + 229 261

it 'errors when not found' do

230 262

expect { select.select_by(:value, 'invalid') }.to raise_exception(Error::NoSuchElementError)

231 263

end

@@ -234,8 +266,6 @@ module Support

234 266

end

235 267 236 268

describe '#deselect_by' do

237 -

let(:multi_select) { Select.new(driver.find_element(id: 'multi')) }

238 - 239 269

it 'invalid how raises exception' do

240 270

expect { multi_select.deselect_by(:invalid, 'foo') }.to raise_exception(ArgumentError)

241 271

end

@@ -320,6 +350,12 @@ module Support

320 350

expect { select.select_all }.to raise_exception(Error::UnsupportedOperationError)

321 351

end

322 352 353 +

it 'raises exception if select contains disabled options' do

354 +

select = Select.new(driver.find_element(name: 'multi_disabled'))

355 + 356 +

expect { select.select_all }.to raise_exception(Error::UnsupportedOperationError)

357 +

end

358 + 323 359

it 'selects all options' do

324 360

multi_select = Select.new(driver.find_element(id: 'multi'))

325 361

multi_select.select_all

@@ -337,6 +373,12 @@ module Support

337 373

expect { select.deselect_all }.to raise_exception(Error::UnsupportedOperationError)

338 374

end

339 375 376 +

it 'does not error when select contains disabled options' do

377 +

select = Select.new(driver.find_element(name: 'multi_disabled'))

378 + 379 +

expect { select.deselect_all }.not_to raise_exception

380 +

end

381 + 340 382

it 'deselects all options' do

341 383

multi_select = Select.new(driver.find_element(id: 'multi'))

342 384

multi_select.deselect_all


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4