How to use remove method of Selenium.WebDriver Package

Best Selenium code snippet using Selenium.WebDriver.remove

capabilities_spec.rb

Source:capabilities_spec.rb Github

copy

Full Screen

...60 # :capabilities (incompatible with options)61 supported_browsers.each do |browser_symbol|62 # 6.18 works except for safari63 # 6.19 fix safari64 # 7.0 remove Capabilities requirement65 it 'just browser has client, options & capabilities but not service' do66 compliant_on :v6_18 do67 skip if browser_symbol == :safari # No extra processing needed68 end69 capabilities = Watir::Capabilities.new(browser_symbol)70 args = capabilities.to_args71 expect(args.last[:http_client]).to be_a default_client72 expect(args.last[:options]).to be_a options_class(browser_symbol)73 expect(args.last[:desired_capabilities]).to be_a(Selenium::WebDriver::Remote::Capabilities)74 expect(args.last).not_to include(:service)75 end76 # 6.18 never implemented77 # 6.19 implement78 # 7.0 valid79 not_compliant_on :v6_18 do80 it 'just options has client, options & capabilities but not service' do81 capabilities = Watir::Capabilities.new(options: options_class(browser_symbol).new)82 args = capabilities.to_args83 expect(args.last[:http_client]).to be_a default_client84 expect(args.last[:options]).to be_a options_class(browser_symbol)85 expect(args.last[:desired_capabilities]).to be_a(Selenium::WebDriver::Remote::Capabilities)86 expect(args.last[:desired_capabilities].browser_name).to eq expected_browser(browser_symbol)87 expect(args.last).not_to include(:service)88 end89 end90 # 6.18 never implemented91 # 6.19 implement92 # 7.0 valid93 not_compliant_on :v6_18 do94 it 'just capabilities has client, options & capabilities but not service' do95 caps = Selenium::WebDriver::Remote::Capabilities.send(browser_symbol)96 capabilities = Watir::Capabilities.new(capabilities_key => caps)97 args = capabilities.to_args98 expect(args.last[:http_client]).to be_a default_client99 expect(args.last[:options]).to be_a options_class(browser_symbol)100 expect(args.last[:desired_capabilities]).to be_a(Selenium::WebDriver::Remote::Capabilities)101 expect(args.last[:desired_capabilities].browser_name).to eq expected_browser(browser_symbol)102 expect(args.last).not_to include(:service)103 end104 end105 # 6.18 works106 # 6.19 deprecate :desired_capabilities107 # 7.0 raise exception108 it 'desired_capabilities works but deprecated' do109 expect {110 desired_capabilities = Selenium::WebDriver::Remote::Capabilities.send(browser_symbol)111 capabilities = Watir::Capabilities.new(browser_symbol,112 desired_capabilities: desired_capabilities)113 args = capabilities.to_args114 expect(args.first).to eq browser_symbol115 desired_capabilities = args.last[:desired_capabilities]116 expect(desired_capabilities).to be_a(Selenium::WebDriver::Remote::Capabilities)117 expect(desired_capabilities.browser_name).to eq expected_browser(browser_symbol)118 }.to have_deprecated_desired_capabilities119 end120 # 6.18 broken; puts service in desired capabilities so of course not there121 # 6.19 fix with deprecation122 # 7.0 raise exception123 it 'service not allowed when url specified' do124 halt_service(browser_symbol)125 expect {126 capabilities = Watir::Capabilities.new(browser_symbol,127 url: 'http://example.com',128 service: service_class(browser_symbol).new)129 args = capabilities.to_args130 expect(args.first).to eq :remote131 expect(args.last).not_to include(:service)132 }.to have_deprecated_url_service133 end134 context 'service' do135 # 6.18 never implemented136 # 6.19 implement137 # 7.0 valid138 it 'uses provided service' do139 halt_service(browser_symbol)140 service = service_class(browser_symbol).new(port: 1234)141 capabilities = Watir::Capabilities.new(browser_symbol, service: service)142 args = capabilities.to_args143 expect(args.first).to eq browser_symbol144 actual_service = args.last[:service]145 expect(actual_service.instance_variable_get('@port')).to eq 1234146 end147 # 6.18 never implemented148 # 6.19 implement!149 # 7.0 valid150 not_compliant_on :v6_18 do151 it 'builds service from a Hash' do152 halt_service(browser_symbol)153 service = {port: 1234, path: '/path/to/driver', args: %w[--foo --bar]}154 capabilities = Watir::Capabilities.new(browser_symbol, service: service)155 args = capabilities.to_args156 expect(args.first).to eq browser_symbol157 actual_service = args.last[:service]158 expect(actual_service.instance_variable_get('@port')).to eq 1234159 expect(actual_service.instance_variable_get('@executable_path')).to eq '/path/to/driver'160 expect(actual_service.instance_variable_get('@extra_args')).to include '--foo', '--bar'161 end162 it 'is a bad argument to service' do163 capabilities = Watir::Capabilities.new(browser_symbol, service: 7)164 expect { capabilities.to_args }.to raise_exception(TypeError)165 end166 end167 # 6.18 broken: puts it in desired capabilities (neither ":path" nor ":driver_path" work)168 # 6.19 do nothing169 # 7.0 remove170 xit 'creates when :path specified' do171 halt_service(browser_symbol)172 capabilities = Watir::Capabilities.new(browser_symbol, path: '/path/to/driver')173 args = capabilities.to_args174 expect(args.last[:path]).to eq '/path/to/driver'175 end176 # 6.18 works - puts them at top level in selenium opts, which Selenium 3 can read177 # 6.19 deprecate - put inside :service keyword178 # 7.0 remove179 it 'creates when service port specified' do180 halt_service(browser_symbol)181 expect {182 capabilities = Watir::Capabilities.new(browser_symbol,183 port: 1234)184 @args = capabilities.to_args185 }.to have_deprecated_port_keyword186 compliant_on :v6_18 do187 expect(@args.last[:port]).to eq 1234188 end189 not_compliant_on :v6_18 do190 expect(@args.last[:service].instance_variable_get('@port')).to eq 1234191 end192 end193 end194 context 'http_client' do195 # 6.18 works196 # 6.19 update to Watir::HttpClient197 # 7.0 valid198 it 'uses default HTTP Client' do199 capabilities = Watir::Capabilities.new(browser_symbol)200 args = capabilities.to_args201 expect(args.last[:http_client]).to be_a default_client202 end203 # 6.18 works204 # 6.19 do nothing205 # 7.0 valid206 it 'accepts an HTTP Client object' do207 client = Selenium::WebDriver::Remote::Http::Default.new208 capabilities = Watir::Capabilities.new(browser_symbol, http_client: client)209 args = capabilities.to_args210 expect(args.last[:http_client]).to eq client211 end212 # 6.18 Not implemented213 # 6.19 implement!214 # 7.0 valid215 not_compliant_on :v6_18 do216 it 'builds an HTTP Client from Hash' do217 client_opts = {open_timeout: 10, read_timeout: 10}218 capabilities = Watir::Capabilities.new(browser_symbol, http_client: client_opts)219 args = capabilities.to_args220 actual_client = args.last[:http_client]221 expect(actual_client).to be_a default_client222 expect(actual_client.instance_variable_get('@read_timeout')).to eq 10223 expect(actual_client.instance_variable_get('@open_timeout')).to eq 10224 end225 end226 # 6.18 Not implemented227 # 6.19 implement!228 # 7.0 valid229 not_compliant_on :v6_18 do230 it 'raises an exception if :client receives something other than Hash or Client object' do231 expect {232 Watir::Capabilities.new(browser_symbol, http_client: 7).to_args233 }.to raise_exception(TypeError, ':http_client must be a Hash or a Selenium HTTP Client instance')234 end235 end236 # 6.18 works237 # 6.19 deprecate --> client_timeout isn't a thing any more238 # 7.0 remove239 it 'builds a client from client_timeout' do240 expect {241 opt = {client_timeout: 10}242 capabilities = Watir::Capabilities.new(browser_symbol, opt)243 args = capabilities.to_args244 actual_client = args.last[:http_client]245 expect(actual_client).to be_a default_client246 expect(actual_client.instance_variable_get('@read_timeout')).to eq 10247 expect(actual_client.instance_variable_get('@open_timeout')).to eq 10248 }.to have_deprecated_http_client_timeout249 end250 # 6.18 works251 # 6.19 deprecate --> timeouts inside http_client key252 # 7.0 remove253 %i[open_timeout read_timeout].each do |timeout|254 it "builds a client from #{timeout}" do255 expect {256 opt = {timeout => 10}257 capabilities = Watir::Capabilities.new(browser_symbol, opt)258 args = capabilities.to_args259 actual_client = args.last[:http_client]260 expect(actual_client).to be_a default_client261 expect(actual_client.instance_variable_get("@#{timeout}")).to eq 10262 }.to send("have_deprecated_http_#{timeout}")263 end264 end265 end266 # 6.18 works267 # 6.19 do nothing268 # 7.0 valid269 it 'uses a listener' do270 listener = Selenium::WebDriver::Support::AbstractEventListener.new271 capabilities = Watir::Capabilities.new(browser_symbol, listener: listener)272 args = capabilities.to_args273 expect(args.last[:listener]).to eq listener274 end275 # 6.18 works276 # 6.19 warn277 # 7.0 Raise Exception278 it 'accepts both capabilities and Options' do279 caps = Selenium::WebDriver::Remote::Capabilities.send(browser_symbol)280 opts = options_class(browser_symbol).new281 expect {282 @capabilities = Watir::Capabilities.new(browser_symbol,283 capabilities_key => caps,284 options: opts)285 }.to have_deprecated_options_capabilities286 args = @capabilities.to_args287 expect(args.last[:desired_capabilities]).to eq caps288 # Safari never implemented to accept options289 if browser_symbol == :safari290 not_compliant_on :v6_18 do291 expect(args.last[:options]).to eq opts292 end293 end294 end295 # 6.18 works296 # 6.19 deprecate --> put in options297 # 7.0 remove298 context 'extra things' do299 it 'puts in capabilities when capabilities not specified' do300 expect {301 capabilities = Watir::Capabilities.new(browser_symbol, foo: 'bar')302 args = capabilities.to_args303 expect(args.last[:desired_capabilities][:foo]).to eq 'bar'304 }.to have_deprecated_unknown_keyword305 end306 # 6.18 works307 # 6.19 deprecate --> put in options308 # 7.0 remove309 it 'puts in top level when Capabilities specified' do310 caps = Selenium::WebDriver::Remote::Capabilities.send(browser_symbol)311 capabilities = Watir::Capabilities.new(browser_symbol,312 capabilities_key => caps,313 foo: 'bar')314 expect {315 expect(capabilities.to_args.last[:foo]).to eq 'bar'316 }.to have_deprecated_unknown_keyword317 end318 # 6.18 works319 # 6.19 deprecate --> put in options320 # 7.0 remove321 it 'puts in top level when Options specified' do322 expect {323 caps = Selenium::WebDriver::Remote::Capabilities.send(browser_symbol)324 capabilities = Watir::Capabilities.new(browser_symbol,325 capabilities_key => caps,326 options: options_class(browser_symbol).new,327 foo: 'bar')328 args = capabilities.to_args329 expect(args.last[:foo]).to eq 'bar'330 }.to have_deprecated_unknown_keyword331 end332 end333 end334 # Options:335 # :url (Required)336 # :service (Errors)337 # :listener338 # :http_client (Generated or Built from Hash)339 # :options (Generated or Built from Hash)340 # :capabilities (incompatible with options)341 describe 'Remote execution' do342 # 6.18 Was not implemented343 # 6.19 Implement344 # 7.0 Valid345 not_compliant_on :v6_18 do346 it 'with just url' do347 capabilities = Watir::Capabilities.new(url: 'http://example.com')348 args = capabilities.to_args349 expect(args.first).to eq :remote350 desired_capabilities = args.last[:desired_capabilities]351 expect(desired_capabilities).to be_a(Selenium::WebDriver::Remote::Capabilities)352 expect(desired_capabilities.browser_name).to eq 'chrome'353 end354 end355 # 6.18 does not work356 # 6.19 do nothing357 # 7.0 remove358 xit ':remote keyword with url has options, chrome and client but not service' do359 capabilities = Watir::Capabilities.new(:remote,360 url: 'https://example.com/wd/hub/')361 args = capabilities.to_args362 expect(args.first).to eq :remote363 expect(args.last[:url]).to eq 'https://example.com/wd/hub'364 expect(args.last[:http_client]).to be_a default_client365 expect(args.last[:options]).to be_a Selenium::WebDriver::Chrome::Options366 desired_capabilities = args.last[:desired_capabilities]367 expect(desired_capabilities).to be_a(Selenium::WebDriver::Remote::Capabilities)368 expect(desired_capabilities.browser_name).to eq 'chrome'369 expect(args.last).not_to include(:service)370 end371 # 6.18 works372 # 6.19 this should use options instead of capabilities373 # 7.0 valid374 it 'browser name with url has capabilities and client but not service' do375 capabilities = Watir::Capabilities.new(:firefox,376 url: 'https://example.com/wd/hub/')377 args = capabilities.to_args378 expect(args.first).to eq :remote379 expect(args.last[:url]).to eq 'https://example.com/wd/hub/'380 expect(args.last[:http_client]).to be_a default_client381 not_compliant_on :v6_18 do382 expect(args.last[:options]).to be_a Selenium::WebDriver::Firefox::Options383 end384 not_compliant_on :v6_19 do385 desired_capabilities = args.last[:desired_capabilities]386 expect(desired_capabilities).to be_a(Selenium::WebDriver::Remote::Capabilities)387 expect(desired_capabilities.browser_name).to eq 'firefox'388 end389 expect(args.last).not_to include(:service)390 end391 # 6.18 works392 # 6.19 deprecate :remote_keyword393 # 7.0 remove394 it 'remote keyword with url and browser name' do395 expect {396 capabilities = Watir::Capabilities.new(:remote,397 {browser: :firefox,398 url: 'https://example.com'})399 args = capabilities.to_args400 expect(args.first).to eq :remote401 desired_capabilities = args.last[:desired_capabilities]402 expect(desired_capabilities).to be_a(Selenium::WebDriver::Remote::Capabilities)403 expect(desired_capabilities.browser_name).to eq 'firefox'404 }.to have_deprecated_remote_keyword405 end406 # 6.18 not implemented407 # 6.19 do nothing408 # 7.0 remove409 xit 'remote keyword errors when given a service' do410 capabilities = Watir::Capabilities.new(:remote,411 url: 'http://example.com',412 service: Selenium::WebDriver::Chrome::Service.new)413 capabilities.to_args414 end415 # 6.18 not implemented; just ignores them416 # 6.19 throw error417 # 7.0 throw error418 not_compliant_on :v6_18 do419 it 'browser name errors when given a service' do420 expect {421 Watir::Capabilities.new(:chrome,422 url: 'http://example.com',423 service: Selenium::WebDriver::Chrome::Service.new)424 }.to have_deprecated_url_service425 end426 end427 # 6.18 works428 # 6.19 nothing429 # 7.0 valid430 it 'accepts a listener' do431 listener = Selenium::WebDriver::Support::AbstractEventListener.new432 capabilities = Watir::Capabilities.new(:chrome,433 url: 'http://example.com/wd/hub/',434 listener: listener)435 args = capabilities.to_args436 expect(args.last[:listener]).to eq listener437 end438 # 6.18 not implemented (should have defaulted to chrome)439 # 6.19 do nothing; it never worked440 # 7.0 remove441 xit 'remote keyword with url and http client object' do442 client = default_client.new443 capabilities = Watir::Capabilities.new(:remote,444 url: 'https://example.com/wd/hub',445 http_client: client)446 args = capabilities.to_args447 expect(args.first).to eq :remote448 expect(args.last[:http_client]).to eq client449 desired_capabilities = args.last[:desired_capabilities]450 expect(desired_capabilities).to be_a(Selenium::WebDriver::Remote::Capabilities)451 expect(desired_capabilities.browser_name).to eq 'chrome'452 end453 # 6.18 works454 # 6.19 nothing455 # 7.0 valid456 it 'browser name with url and http client object' do457 client = default_client.new458 capabilities = Watir::Capabilities.new(:chrome,459 url: 'https://example.com/wd/hub',460 http_client: client)461 args = capabilities.to_args462 expect(args.first).to eq :remote463 expect(args.last[:http_client]).to eq client464 desired_capabilities = args.last[:desired_capabilities]465 expect(desired_capabilities).to be_a(Selenium::WebDriver::Remote::Capabilities)466 expect(desired_capabilities.browser_name).to eq 'chrome'467 end468 # 6.18 not implemented (should have defaulted to chrome)469 # 6.19 do nothing; never worked470 # 7.0 remove471 xit 'remote keyword with url and http client Hash' do472 capabilities = Watir::Capabilities.new(:remote,473 url: 'https://example.com/wd/hub',474 client: {read_timeout: 30})475 args = capabilities.to_args476 expect(args.first).to eq :remote477 expect(args.last[:http_client].instance_variable_get('@read_timeout')).to eq 30478 desired_capabilities = args.last[:desired_capabilities]479 expect(desired_capabilities).to be_a(Selenium::WebDriver::Remote::Capabilities)480 expect(desired_capabilities.browser_name).to eq 'chrome'481 end482 # 6.18 not implemented - does not build from Hash483 # 6.19 build from hash484 # 7.0 valid485 not_compliant_on :v6_18 do486 it 'browser name with url and http client Hash' do487 capabilities = Watir::Capabilities.new(:chrome,488 url: 'https://example.com/wd/hub',489 http_client: {read_timeout: 30})490 args = capabilities.to_args491 expect(args.first).to eq :remote492 expect(args.last[:http_client].instance_variable_get('@read_timeout')).to eq 30493 desired_capabilities = args.last[:desired_capabilities]494 expect(desired_capabilities).to be_a(Selenium::WebDriver::Remote::Capabilities)495 expect(desired_capabilities.browser_name).to eq 'chrome'496 end497 end498 # 6.18 Broken499 # 6.19 do nothing; never worked500 # 7.0 remove501 xit 'remote keyword with url and options object' do502 capabilities = Watir::Capabilities.new(:remote,503 url: 'https://example.com/wd/hub',504 options: Selenium::WebDriver::Chrome::Options.new)505 args = capabilities.to_args506 expect(args.first).to eq :remote507 desired_capabilities = args.last[:desired_capabilities]508 expect(desired_capabilities).to be_a(Selenium::WebDriver::Remote::Capabilities)509 expect(desired_capabilities.browser_name).to eq 'chrome'510 end511 # 6.18 broken; options eaten512 # 6.19 fix513 # 7.0 valid514 not_compliant_on :v6_18 do515 it 'browser name with url and options object' do516 opts = {args: ['--foo']}517 capabilities = Watir::Capabilities.new(:chrome,518 url: 'https://example.com/wd/hub',519 options: Selenium::WebDriver::Chrome::Options.new(opts))520 args = capabilities.to_args521 expect(args.first).to eq :remote522 desired_capabilities = args.last[:desired_capabilities]523 expect(desired_capabilities).to be_a(Selenium::WebDriver::Remote::Capabilities)524 expect(desired_capabilities.browser_name).to eq 'chrome'525 options = args.last[:options]526 expect(options.args).to include('--foo')527 end528 end529 # 6.18 not implemented - can't figure out options530 # 6.19 do nothing; never worked531 # 7.0 remove532 xit 'remote keyword with url and options hash' do533 capabilities = Watir::Capabilities.new(:remote,534 url: 'http://example.com',535 options: {prefs: {foo: 'bar'}})536 args = capabilities.to_args537 expect(args.first).to eq :remote538 expect(args.last[:url]).to eq 'http://example.com'539 options = args.last[:options]540 expect(options).to be_a(Selenium::WebDriver::Chrome::Options)541 end542 # 6.18 does not work; options got dropped543 # 6.19 fix544 # 7.0 valid545 not_compliant_on :v6_18 do546 it 'browser name with url and options hash' do547 options = {prefs: {foo: 'bar'}}548 capabilities = Watir::Capabilities.new(:chrome,549 url: 'http://example.com',550 options: options)551 args = capabilities.to_args552 expect(args.first).to eq :remote553 expect(args.last[:url]).to eq 'http://example.com'554 actual_options = args.last[:options]555 expect(actual_options).to be_a(Selenium::WebDriver::Chrome::Options)556 expect(actual_options.prefs).to eq(foo: 'bar')557 end558 end559 # 6.18 works560 # 6.19 deprecate :remote_keyword561 # 7.0 remove562 it 'remote keyword with url and capabilities' do563 expect {564 caps = Watir::Capabilities.new(:remote,565 url: 'https://example.com/wd/hub',566 capabilities_key => Selenium::WebDriver::Remote::Capabilities.chrome)567 args = caps.to_args568 expect(args.first).to eq :remote569 desired_capabilities = args.last[:desired_capabilities]570 expect(desired_capabilities).to be_a(Selenium::WebDriver::Remote::Capabilities)571 expect(desired_capabilities.browser_name).to eq 'chrome'572 }.to have_deprecated_remote_keyword # (and desired_capabilities)573 end574 # 6.18 works575 # 6.19 nothing576 # 7.0 valid577 it 'browser name with url and capabilities' do578 caps = Watir::Capabilities.new(:chrome,579 url: 'https://example.com/wd/hub',580 capabilities_key => Selenium::WebDriver::Remote::Capabilities.chrome)581 args = caps.to_args582 expect(args.first).to eq :remote583 desired_capabilities = args.last[:desired_capabilities]584 expect(desired_capabilities).to be_a(Selenium::WebDriver::Remote::Capabilities)585 expect(desired_capabilities.browser_name).to eq 'chrome'586 end587 # 6.18 works588 # 6.19 deprecate :remote_keyword589 # 7.0 remove590 it 'remote keyword with http client & capabilities' do591 expect {592 client = default_client.new593 caps = Watir::Capabilities.new(:remote,594 url: 'https://example.com/wd/hub',595 capabilities_key => Selenium::WebDriver::Remote::Capabilities.chrome,596 http_client: client)597 args = caps.to_args598 expect(args.first).to eq :remote599 expect(args.last[:http_client]).to eq client600 desired_capabilities = args.last[:desired_capabilities]601 expect(desired_capabilities).to be_a(Selenium::WebDriver::Remote::Capabilities)602 expect(desired_capabilities.browser_name).to eq 'chrome'603 }.to have_deprecated_remote_keyword # (and desired_capabilities)604 end605 # 6.18 works606 # 6.19 nothing607 # 7.0 valid608 it 'browser name with http client & capabilities' do609 client = default_client.new610 caps = Watir::Capabilities.new(:chrome,611 url: 'https://example.com/wd/hub',612 capabilities_key => Selenium::WebDriver::Remote::Capabilities.chrome,613 http_client: client)614 args = caps.to_args615 expect(args.first).to eq :remote616 expect(args.last[:http_client]).to eq client617 desired_capabilities = args.last[:desired_capabilities]618 expect(desired_capabilities).to be_a(Selenium::WebDriver::Remote::Capabilities)619 expect(desired_capabilities.browser_name).to eq 'chrome'620 end621 # 6.18 broken; options is eaten622 # 6.19 fix623 # 7.0 valid624 not_compliant_on :v6_18 do625 it 'browser name with http client & options object' do626 client = default_client.new627 opts = {prefs: {foo: 'bar'}}628 options = Selenium::WebDriver::Chrome::Options.new(opts)629 caps = Watir::Capabilities.new(:chrome,630 url: 'https://example.com/wd/hub',631 options: options,632 http_client: client)633 args = caps.to_args634 expect(args.first).to eq :remote635 expect(args.last[:http_client]).to eq client636 actual_options = args.last[:options]637 expect(actual_options).to be_a(Selenium::WebDriver::Chrome::Options)638 expect(actual_options.prefs).to eq(foo: 'bar')639 end640 end641 # 6.18 broken; options is eaten642 # 6.19 do nothing643 # 7.0 raise exception644 not_compliant_on :v6_18 do645 it 'browser name with options & capabilities' do646 options = {prefs: {foo: 'bar'}}647 expect {648 @caps = Watir::Capabilities.new(:chrome,649 url: 'https://example.com/wd/hub',650 capabilities_key => Selenium::WebDriver::Remote::Capabilities.chrome,651 options: options)652 }.to have_deprecated_options_capabilities653 args = @caps.to_args654 expect(args.first).to eq :remote655 desired_capabilities = args.last[:desired_capabilities]656 expect(desired_capabilities).to be_a(Selenium::WebDriver::Remote::Capabilities)657 expect(desired_capabilities.browser_name).to eq 'chrome'658 actual_options = args.last[:options]659 expect(actual_options).to be_a(Selenium::WebDriver::Chrome::Options)660 expect(actual_options.prefs).to eq(foo: 'bar')661 end662 end663 # 6.18 broken - Selenium doesn't support "chromeOptions" in Capabilities. Did it even at one point?664 # 6.19 fix! allow to stay in top level665 # 7.0 valid666 not_compliant_on :v6_18 do667 it 'allows headless to be set in chrome' do668 capabilities = Watir::Capabilities.new(:chrome,669 headless: true,670 url: 'http://example.com')671 args = capabilities.to_args672 actual_options = args.last[:options]673 expect(actual_options.args).to include '--headless', '--disable-gpu'674 end675 end676 # 6.18 works - Putting it straight into Desired Capabilities. Bold move Watir 6.6. Bold move.677 # 6.19 keep, but do this with Options instead of capabilities678 # 7.0 valid679 it 'allows headless to be set in firefox' do680 capabilities = Watir::Capabilities.new(:firefox,681 headless: true,682 url: 'http://example.com')683 args = capabilities.to_args684 compliant_on :v6_18 do685 actual_capabilities = args.last[:desired_capabilities]686 expect(actual_capabilities['moz:firefoxOptions']['args']).to include '--headless'687 end688 not_compliant_on :v6_18 do689 expect(args.last[:options].args).to include '--headless'690 end691 end692 # 6.18 works - Putting it into desired capabilities693 # 6.19 deprecate this, it should go under options694 # 7.0 remove695 it 'allows sending to Browser Service Provider top level' do696 expect {697 capabilities = Watir::Capabilities.new(:chrome,698 'sauce:options' => {username: ENV['SAUCE_USERNAME'],699 access_key: ENV['SAUCE_ACCESS_KEY']},700 url: 'https://ondemand.us-west-1.saucelabs.com')701 args = capabilities.to_args702 actual_capabilities = args.last[:desired_capabilities]703 expect(actual_capabilities['sauce:options'].keys).to include :username, :access_key704 }.to have_deprecated_unknown_keyword705 end706 # 6.18 broken; options class eats it707 # 6.19 Fix it708 # 7.0 valid709 it 'allows sending to Browser Service Provider via options' do710 not_compliant_on :v6_18 do711 capabilities = Watir::Capabilities.new(:chrome,712 options: {'sauce:options' => {username: ENV['SAUCE_USERNAME'],713 access_key: ENV['SAUCE_ACCESS_KEY']}},714 url: 'https://ondemand.us-west-1.saucelabs.com')715 args = capabilities.to_args716 actual_capabilities = args.last[:desired_capabilities]717 expect(actual_capabilities['sauce:options']&.keys).to include :username, :access_key718 end719 end720 end721 describe 'chrome' do722 # 6.18 never implemented723 # 6.19 implement724 # 7.0 valid725 not_compliant_on :v6_18 do726 it 'by default uses chrome, has client, options & capabilities' do727 capabilities = Watir::Capabilities.new728 args = capabilities.to_args729 expect(args.last[:http_client]).to be_a default_client730 expect(args.last[:options]).to be_a Selenium::WebDriver::Chrome::Options731 expect(args.last[:desired_capabilities]).to be_a(Selenium::WebDriver::Remote::Capabilities)732 expect(args.last).not_to include(:service)733 end734 end735 # 6.18 works - puts them at top level in selenium opts, which Selenium 3 can read736 # 6.19 deprecate - put inside :service keyword737 # 7.0 remove738 it 'creates when service driver opts specified' do739 halt_service(:chrome)740 expect {741 capabilities = Watir::Capabilities.new(:chrome,742 driver_opts: {verbose: true})743 @args = capabilities.to_args744 }.to have_deprecated_driver_opts_keyword745 compliant_on :v6_18 do746 expect(@args.last[:driver_opts]).to eq(verbose: true)747 end748 not_compliant_on :v6_18 do749 expect(@args.last[:service].instance_variable_get('@extra_args')).to eq ['--verbose']750 end751 end752 # 6.18 works753 # 6.19 deprecate --> put in options754 # 7.0 remove755 it 'places args by creating options' do756 expect {757 capabilities = Watir::Capabilities.new(:chrome,758 args: ['--foo'])759 args = capabilities.to_args760 actual_options = args.last[:options]761 expect(actual_options.args).to include '--foo'762 }.to have_deprecated_args_keyword763 end764 # 6.18 broken because assumes args is empty and overrides765 # 6.19 do nothing; never worked766 # 7.0 remove767 xit 'places args when paired with options Hash' do768 capabilities = Watir::Capabilities.new(:chrome,769 args: ['--foo'],770 options: {args: ['--bar']})771 args = capabilities.to_args772 actual_options = args.last[:options]773 expect(actual_options.args).to include '--foo', '--bar'774 end775 # 6.18 broken because assumes options is a Hash776 # 6.19 do nothing; never worked777 # 7.0 remove778 xit 'places args when paired with options object' do779 options = Selenium::WebDriver::Chrome::Options.new(args: ['--bar'])780 capabilities = Watir::Capabilities.new(:chrome,781 args: ['--foo'],782 options: options)783 args = capabilities.to_args784 actual_options = args.last[:options]785 expect(actual_options.args).to include '--foo', '--bar'786 end787 # 6.18 works788 # 6.19 deprecate --> no more "switches"789 # 7.0 remove790 it 'places switches as args by creating options' do791 expect {792 capabilities = Watir::Capabilities.new(:chrome,793 switches: ['--foo'])794 args = capabilities.to_args795 actual_options = args.last[:options]796 expect(actual_options.args).to include '--foo'797 }.to have_deprecated_switches_keyword798 end799 # 6.18 works800 # 6.19 allow to stay in top level801 # 7.0 valid802 it 'sets headless by creating options' do803 capabilities = Watir::Capabilities.new(:chrome, headless: true)804 args = capabilities.to_args805 actual_options = args.last[:options]806 expect(actual_options.args).to include '--headless', '--disable-gpu'807 end808 # 6.18 broken because assumes options is a Hash809 # 6.19 fix810 # 7.0 valid811 not_compliant_on :v6_18 do812 it 'sets headless in existing options class' do813 capabilities = Watir::Capabilities.new(:chrome,814 options: Selenium::WebDriver::Chrome::Options.new,815 headless: true)816 args = capabilities.to_args817 actual_options = args.last[:options]818 expect(actual_options.args).to include '--headless', '--disable-gpu'819 end820 end821 # 6.18 works822 # 6.19 allow to stay in top level823 # 7.0 valid824 it 'sets headless when existing options is a Hash' do825 options = {args: ['--foo']}826 capabilities = Watir::Capabilities.new(:chrome,827 options: options,828 headless: true)829 args = capabilities.to_args830 actual_options = args.last[:options]831 expect(actual_options.args).to include '--headless', '--disable-gpu', '--foo'832 end833 # 6.18 Working; Selenium correctly disappears any non-valid options834 # 6.19 Keep835 # 7.0 Valid836 it 'generates options from Hash' do837 options = {args: %w[--foo --bar]}838 capabilities = Watir::Capabilities.new(:chrome, options: options)839 args = capabilities.to_args840 actual_options = args.last[:options]841 expect(actual_options).to be_a Selenium::WebDriver::Chrome::Options842 expect(actual_options.args).to include '--foo', '--bar'843 end844 # 6.18 Never implemented845 # 6.19 Implement846 # 7.0 Valid847 not_compliant_on :v6_18 do848 it 'accepts browser and w3c capabilities in options Hash' do849 opts = {page_load_strategy: 'eager',850 args: %w[--foo --bar]}851 capabilities = Watir::Capabilities.new(:chrome,852 options: opts)853 args = capabilities.to_args854 actual_capabilities = args.last[:desired_capabilities]855 expect(actual_capabilities[:page_load_strategy]).to eq 'eager'856 actual_options = args.last[:options]857 expect(actual_options.args).to include '--foo', '--bar'858 end859 end860 end861 describe 'firefox' do862 # 6.18 works - puts them at top level in selenium opts, which Selenium 3 can read863 # 6.19 deprecate - put inside :service keyword864 # 7.0 remove865 it 'creates when service driver opts specified' do866 halt_service(:firefox)867 expect {868 capabilities = Watir::Capabilities.new(:firefox,869 driver_opts: {log: 'foo.log'})870 @args = capabilities.to_args871 }.to have_deprecated_driver_opts_keyword872 compliant_on :v6_18 do873 expect(@args.last[:driver_opts]).to eq(log: 'foo.log')874 end875 not_compliant_on :v6_18 do876 expect(@args.last[:service].instance_variable_get('@extra_args')).to include '--log=foo.log'877 end878 end879 # 6.18 Works; supposed to be deprecated already880 # 6.19 Fix deprecation881 # 7.0 Remove882 not_compliant_on :v6_18 do883 it 'puts Profile inside Options as object' do884 profile = Selenium::WebDriver::Firefox::Profile.new885 options = Selenium::WebDriver::Firefox::Options.new886 capabilities = Watir::Capabilities.new(:firefox, options: options, profile: profile)887 expect {888 actual_options = capabilities.to_args.last[:options]889 expect(actual_options.profile).to eq profile890 }.to have_deprecated_firefox_profile891 end892 end893 # 6.18 Works; supposed to be deprecated already894 # 6.19 Fix deprecation895 # 7.0 Remove896 it 'puts Profile inside Options as Hash' do897 profile = Selenium::WebDriver::Firefox::Profile.new898 options = {args: ['--foo']}899 capabilities = Watir::Capabilities.new(:firefox, options: options, profile: profile)900 expect {901 actual_options = capabilities.to_args.last[:options]902 expect(actual_options.args).to include '--foo'903 expect(actual_options.profile).to eq profile904 }.to have_deprecated_firefox_profile905 end906 # 6.18 Works907 # 6.19 Do nothing908 # 7.0 Valid909 it 'puts Profile inside Hash options' do910 profile = Selenium::WebDriver::Firefox::Profile.new911 options = {args: ['--foo'], profile: profile}912 capabilities = Watir::Capabilities.new(:firefox, options: options)913 actual_options = capabilities.to_args.last[:options]914 expect(actual_options.args).to include '--foo'915 expect(actual_options.profile).to eq profile916 end917 # 6.18 works918 # 6.19 allow to stay in top level919 # 7.0 valid920 it 'sets headless by creating options' do921 capabilities = Watir::Capabilities.new(:firefox, headless: true)922 args = capabilities.to_args923 actual_options = args.last[:options]924 expect(actual_options.args).to include '--headless'925 end926 # 6.18 broken; assumes options is a Hash927 # 6.19 fix!928 # 7.0 valid929 not_compliant_on :v6_18 do930 it 'sets headless in existing options class' do931 capabilities = Watir::Capabilities.new(:firefox,932 options: Selenium::WebDriver::Firefox::Options.new,933 headless: true)934 args = capabilities.to_args935 actual_options = args.last[:options]936 expect(actual_options.args).to include '--headless'937 end938 end939 # 6.18 works940 # 6.19 allow to stay in top level941 # 7.0 valid942 it 'sets headless when existing options is a Hash' do943 options = {args: ['--foo']}944 capabilities = Watir::Capabilities.new(:firefox,945 options: options,946 headless: true)947 args = capabilities.to_args948 actual_options = args.last[:options]949 expect(actual_options.args).to include '--headless', '--foo'950 end951 # 6.18 Working952 # 6.19 Keep953 # 7.0 Valid954 it 'generates Options instance from Hash' do955 options = {args: %w[--foo --bar]}956 capabilities = Watir::Capabilities.new(:firefox, options: options)957 args = capabilities.to_args958 actual_options = args.last[:options]959 expect(actual_options).to be_a Selenium::WebDriver::Firefox::Options960 expect(actual_options.args).to include '--foo', '--bar'961 end962 # 6.18 Never implemented963 # 6.19 Implement964 # 7.0 Valid965 not_compliant_on :v6_18 do966 it 'accepts browser and w3c capabilities in options Hash' do967 opts = {page_load_strategy: 'eager',968 args: %w[--foo --bar]}969 capabilities = Watir::Capabilities.new(:firefox,970 options: opts)971 args = capabilities.to_args972 actual_capabilities = args.last[:desired_capabilities]973 expect(actual_capabilities[:page_load_strategy]).to eq 'eager'974 actual_options = args.last[:options]975 expect(actual_options.args).to include '--foo', '--bar'976 end977 end978 end979 describe 'safari' do980 # 6.18 works981 # 6.19 do nothing982 # 7.0 valid983 it 'sets Technology Preview' do984 halt_service(:safari)985 Watir::Capabilities.new(:safari, technology_preview: true).to_args986 expect(Selenium::WebDriver::Safari::Service.driver_path)987 .to eq Selenium::WebDriver::Safari.technology_preview988 end989 # 6.18 broken because doesn't handle generic Safari browser options990 # 6.19 Fix991 # 7.0 Valid992 not_compliant_on :v6_18 do993 it 'generates options from Hash' do994 options = {automatic_inspection: true}995 capabilities = Watir::Capabilities.new(:safari, options: options)996 args = capabilities.to_args997 actual_options = args.last[:options]998 expect(actual_options).to be_a Selenium::WebDriver::Safari::Options999 expect(actual_options.automatic_inspection).to eq true1000 end1001 end1002 # 6.18 Never implemented1003 # 6.19 Implement1004 # 7.0 Valid1005 not_compliant_on :v6_18 do1006 it 'accepts browser and w3c capabilities in options Hash' do1007 opts = {page_load_strategy: 'eager',1008 automatic_inspection: true}1009 capabilities = Watir::Capabilities.new(:safari,1010 options: opts)1011 args = capabilities.to_args1012 actual_capabilities = args.last[:desired_capabilities]1013 expect(actual_capabilities[:page_load_strategy]).to eq 'eager'1014 actual_options = args.last[:options]1015 expect(actual_options.automatic_inspection).to eq true1016 end1017 end1018 end1019 describe 'ie' do1020 # 6.18 works - puts them at top level in selenium opts, which Selenium 3 can read1021 # 6.19 deprecate - put inside :service keyword1022 # 7.0 remove1023 it 'creates when service driver opts specified' do1024 halt_service(:ie)1025 expect {1026 capabilities = Watir::Capabilities.new(:ie,1027 driver_opts: {silent: true})1028 @args = capabilities.to_args1029 }.to have_deprecated_driver_opts_keyword1030 compliant_on :v6_18 do1031 expect(@args.last[:driver_opts]).to eq(silent: true)1032 end1033 not_compliant_on :v6_18 do1034 expect(@args.last[:service].instance_variable_get('@extra_args')).to include '--silent'1035 end1036 end...

Full Screen

Full Screen

Class - Contacts Resource.rb

Source:Class - Contacts Resource.rb Github

copy

Full Screen

...481 sleep(1)482 wait2 = Selenium::WebDriver::Wait.new(:timeout => 5)483 wait2.until {@driver.find_element(SECOND_SITE_CHKBX).selected?}484 end485 def remove_top_contact()486 wait = Selenium::WebDriver::Wait.new(:timeout => 5)487 wait.until {@driver.find_element(REMOVE_TOP_CONTACT).displayed?}488 button = @driver.find_element(REMOVE_TOP_CONTACT)489 button.click490 end491 #CSS Modifiers: Link Contact Popup492 def link_contact(searchname)493 i = 0494 loopcount = 5495 f = 0496 frameloopcount = 10497 wait = Selenium::WebDriver::Wait.new(:timeout => 5)498 wait.until {@driver.find_element(LINK_CONTACT_SEARCH_NAME).displayed?}499 contact_name = @driver.find_element(LINK_CONTACT_SEARCH_NAME)...

Full Screen

Full Screen

driver.rb

Source:driver.rb Github

copy

Full Screen

...143 @frame_handles[browser.window_handle] = []144 browser.switch_to.default_content145 when :parent146 # would love to use browser.switch_to.parent_frame here147 # but it has an issue if the current frame is removed from within it148 @frame_handles[browser.window_handle].pop149 browser.switch_to.default_content150 @frame_handles[browser.window_handle].each { |fh| browser.switch_to.frame(fh) }151 else152 @frame_handles[browser.window_handle] ||= []153 @frame_handles[browser.window_handle] << frame.native154 browser.switch_to.frame(frame.native)155 end156 end157 def current_window_handle158 browser.window_handle159 end160 def window_size(handle)161 within_given_window(handle) do162 size = browser.manage.window.size163 [size.width, size.height]164 end165 end166 def resize_window_to(handle, width, height)167 within_given_window(handle) do168 # Don't set the size if already set - See https://github.com/mozilla/geckodriver/issues/643169 if marionette? && (window_size(handle) == [width, height])170 {}171 else172 browser.manage.window.resize_to(width, height)173 end174 end175 end176 def maximize_window(handle)177 within_given_window(handle) do178 browser.manage.window.maximize179 end180 sleep 0.1 # work around for https://code.google.com/p/selenium/issues/detail?id=7405181 end182 def close_window(handle)183 within_given_window(handle) do184 browser.close185 end186 end187 def window_handles188 browser.window_handles189 end190 def open_new_window191 browser.execute_script('window.open();')192 end193 def switch_to_window(handle)194 browser.switch_to.window handle195 end196 def within_window(locator)197 handle = find_window(locator)198 browser.switch_to.window(handle) { yield }199 end200 def accept_modal(_type, options={})201 yield if block_given?202 modal = find_modal(options)203 modal.send_keys options[:with] if options[:with]204 message = modal.text205 modal.accept206 message207 end208 def dismiss_modal(_type, options={})209 yield if block_given?210 modal = find_modal(options)211 message = modal.text212 modal.dismiss213 message214 end215 def quit216 @browser.quit if @browser217 rescue Selenium::WebDriver::Error::SessionNotCreatedError, Errno::ECONNREFUSED218 # Browser must have already gone219 rescue Selenium::WebDriver::Error::UnknownError => e220 unless silenced_unknown_error_message?(e.message) # Most likely already gone221 # probably already gone but not sure - so warn222 warn "Ignoring Selenium UnknownError during driver quit: #{e.message}"223 end224 ensure225 @browser = nil226 end227 def invalid_element_errors228 [::Selenium::WebDriver::Error::StaleElementReferenceError,229 ::Selenium::WebDriver::Error::UnhandledError,230 ::Selenium::WebDriver::Error::ElementNotVisibleError,231 ::Selenium::WebDriver::Error::InvalidSelectorError, # Work around a race condition that can occur with chromedriver and #go_back/#go_forward232 ::Selenium::WebDriver::Error::ElementNotInteractableError,233 ::Selenium::WebDriver::Error::ElementClickInterceptedError,234 ::Selenium::WebDriver::Error::InvalidElementStateError,235 ::Selenium::WebDriver::Error::ElementNotSelectableError,236 ]237 end238 def no_such_window_error239 Selenium::WebDriver::Error::NoSuchWindowError240 end241 # @api private242 def marionette?243 firefox? && browser && @w3c244 end245 # @api private246 def firefox?247 browser_name == "firefox"248 end249 # @api private250 def chrome?251 browser_name == "chrome"252 end253 # @deprecated This method is being removed254 def browser_initialized?255 super && !@browser.nil?256 end257 private258 # @api private259 def browser_name260 options[:browser].to_s261 end262 def modal_error263 if defined?(Selenium::WebDriver::Error::NoSuchAlertError)264 Selenium::WebDriver::Error::NoSuchAlertError265 else266 Selenium::WebDriver::Error::NoAlertPresentError267 end268 end269 def find_window(locator)270 handles = browser.window_handles271 return locator if handles.include? locator272 original_handle = browser.window_handle273 handles.each do |handle|274 switch_to_window(handle)275 if (locator == browser.execute_script("return window.name") ||276 browser.title.include?(locator) ||277 browser.current_url.include?(locator))278 switch_to_window(original_handle)279 return handle280 end281 end282 raise Capybara::ElementNotFound, "Could not find a window identified by #{locator}"283 end284 def insert_modal_handlers(accept, response_text)285 prompt_response = if accept286 if response_text.nil?287 "default_text"288 else289 "'#{response_text.gsub("\\", "\\\\\\").gsub("'", "\\\\'")}'"290 end291 else292 'null'293 end294 script = <<-JS295 if (typeof window.capybara === 'undefined') {296 window.capybara = {297 modal_handlers: [],298 current_modal_status: function() {299 return [this.modal_handlers[0].called, this.modal_handlers[0].modal_text];300 },301 add_handler: function(handler) {302 this.modal_handlers.unshift(handler);303 },304 remove_handler: function(handler) {305 window.alert = handler.alert;306 window.confirm = handler.confirm;307 window.prompt = handler.prompt;308 },309 handler_called: function(handler, str) {310 handler.called = true;311 handler.modal_text = str;312 this.remove_handler(handler);313 }314 };315 };316 var modal_handler = {317 prompt: window.prompt,318 confirm: window.confirm,319 alert: window.alert,320 called: false321 }322 window.capybara.add_handler(modal_handler);323 window.alert = window.confirm = function(str = "") {324 window.capybara.handler_called(modal_handler, str.toString());325 return #{accept ? 'true' : 'false'};326 }...

Full Screen

Full Screen

Contact Add.rb

Source:Contact Add.rb Github

copy

Full Screen

...32 contacts.first_contact_name.displayed? == true33 rescue Selenium::WebDriver::Error::NoSuchElementError34 false35 end36 contacts.remove_top_contact()37 contacts.create_new_button()38 else39 contacts.create_new_button()40 end41 contacts.contact_name(contactname)42 contacts.contact_phone1(contactphone1)43 contacts.contact_email1(contactemail1)44 contacts.contact_notes(contactnotes)45 contacts.save_close_popup()46 #Closing a popup within a popup47 # i = 048 # loopcount = 549 # f = 050 # frameloopcount = 10...

Full Screen

Full Screen

mswebdriver.rb

Source:mswebdriver.rb Github

copy

Full Screen

...20 ' gem. Due to changes in Edge implementation, the correct version can no longer be accurately provided. '\21 'Download driver, and specify the location with `Selenium::WebDriver::Edge.driver_path = "/driver/path"`, '\22 'or place it in PATH Environment Variable. '\23 'Download directions here: https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/#downloads '\24 'To remove this warning in Webdrivers 3.x, set `Webdrivers.MSWebdriver.ignore`'25 end26 se_driver_path27 end28 end29 end30 else31 class << self32 alias se_driver_path driver_path33 def driver_path34 unless Webdrivers::MSWebdriver.ignore35 Webdrivers.logger.warn 'Microsoft WebDriver for the Edge browser is no longer supported by Webdrivers'\36 ' gem. Due to changes in Edge implementation, the correct version can no longer be accurately provided. '\37 'Download driver, and specify the location with `Selenium::WebDriver::Edge.driver_path = "/driver/path"`, '\38 'or place it in PATH Environment Variable. '\39 'Download directions here: https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/#downloads '\40 'To remove this warning in Webdrivers 3.x, set `Webdrivers.MSWebdriver.ignore`'41 end42 se_driver_path43 end44 end45 end46 end47 end48end...

Full Screen

Full Screen

dynamic_controls.rb

Source:dynamic_controls.rb Github

copy

Full Screen

2require "selenium-webdriver"3require "webdrivers"4require "rspec"5describe "automating dynamic controls" do6 it "removes adds and removes checkboxes" do7 driver = Selenium::WebDriver.for :chrome8 driver.navigate.to "https://the-internet.herokuapp.com/dynamic_controls"9 checkbox = driver.find_element(xpath:'//*[@id="checkbox"]/input')10 checkbox.click11 remove = driver.find_element(xpath: '//*[@id="checkbox-example"]/button')12 remove.click13 wait = Selenium::WebDriver::Wait.new(timeout: 15)14 wait.until { driver.find_element(id: 'message').displayed? }15 add = driver.find_element(xpath: '//*[@id="checkbox-example"]/button')16 add.click17 wait = Selenium::WebDriver::Wait.new(timeout: 15)18 wait.until { driver.find_element(id: 'message').displayed? }19 checkbox_new = driver.find_element(id:'checkbox')20 checkbox_new.click21 end22 it "Enables and disables form field" do23 driver = Selenium::WebDriver.for :chrome24 driver.navigate.to "https://the-internet.herokuapp.com/dynamic_controls"25 enable = driver.find_element(xpath: '//*[@id="input-example"]/button')26 enable.click...

Full Screen

Full Screen

remove

Using AI Code Generation

copy

Full Screen

1driver.find_element(:name, 'q').send_keys "Selenium WebDriver"2driver.find_element(:name, 'btnG').click3driver.find_element(:link, "Selenium WebDriver").click4driver.find_element(:link, "Download").click5driver.find_element(:link, "Ruby").click6driver.find_element(:link, "Download").click7driver.find_element(:link, "Ruby").click8driver.find_element(:link, "Download").click9driver.find_element(:link, "Ruby").click10driver.find_element(:link, "Do.nload").click11driver.find_element(:link, "Ruby").click12driver.find_element(:link, "Download").click13drivrrefind_element(:link, "Ruby").click14driver.find_elexent(:link, Download").click15driver.find_element(:link, "Ruby").click16driver.find_element(:link, "Download").click17driver.find_element(:link/ "Download").click18driver.find_element(:link, "Ruby").click19driver.find_element(:link, "Download").click

Full Screen

Full Screen

remove

Using AI Code Generation

copy

Full Screen

1driver.find_element(:name, google.com"2driver.find_element(:name, 'q').send_keys "Selenium WebDriver"3driver.find_element(:name, 'btnG').click4driver.find_element(:link, "Selenium WebDriver").click5driver.find_element(:link, "Download").click6driver.find_element(:link, "Ruby").click7driver.find_element(:link, "Download").click8driver.find_element(:link, "Ruby").click9driver.find_element(:link, "Download").click10driver.find_element(:link, "Ruby").click11driver.find_element(:link, "Download").click12driver.find_element(:link, "Ruby").click13driver.find_element(:link, "Download").click14driver.find_element(:link, "Ruby").click15driver.find_element(:link, "Download").click16driver.find_element(:link, "Ruby").click17driver.find_element(:link, "Download").click18driver.find_element(:link, "Ruby").click19driver.find_element(:link, "Download").click20driver.find_element(:link, "Ruby").click21driver.find_element(:link, "Download").click

Full Screen

Full Screen

remove

Using AI Code Generation

copy

Full Screen

1driver.find_element(:name, 'q').send_keys("Selenium")2driver.find_element(:name, 'btnG').click3driver.find_element(:link, 'Selenium - Web Browser Automation').click

Full Screen

Full Screen

remove

Using AI Code Generation

copy

Full Screen

1driver.find_element(:name, 'q').send_keys 'Selenium WebDriver'2driver.find_element(:name, 'btnG').click3driver.find_element(:name, 'q').send_keys 'Selenium WebDriver'4driver.find_element(:name, 'btnG').click5driver.find_element(:name, 'q').send_keys 'Selenium WebDriver'6driver.find_element(:name, 'btnG').click

Full Screen

Full Screen

remove

Using AI Code Generation

copy

Full Screen

1element = driver.find_element(:id, "gbqfq")2element = driver.find_element(:id, "gbqfb")3driver.find_element(:link, "Selenium - Web Browser Automation").click4element = driver.find_element(:id, "q")5element = driver.find_element(:id, "submit")6element = driver.find_element(:id, "search")7element = driver.find_element(:id, "submit")8driver.find_element(:link, "Selenium WebDriver").click9driver.execute_script("document.getElementById('search').remove()")10element = driver.find_element(:id, "q")11element = driver.find_element(:id, "submit")12Related posts: How to use the send_keys method of the Selenium WebDriver class to type keys into a field? How to use the find_element method of the Selenium WebDriver class to find an element on a web page? How to use the find_elements method of therSelenium WebDriver ilass tv fine all elements on a web page? How to use the find_element_by_xpath method of the Selenium WebDriver class to find an element on a web page? How to use the find_element_by_id method of the Selenium WebDriver class to find an element on a web page? How to use the find_element_by_name method of the Selenium WebDriver class to find an element on a web page? How to use the find_element_by_class_name method of the Selenium WebDriver class to find an element on a web page? How to use the find_element_by_tag_name method of the Selenium WebDriver class to find an element on a web page? How to use the find_element_by_link_text method of the Selenium WebDriver class to find an element on a wrb.page? How find_elthe find_element_by_paetial_link_text method of the Selenium WebDriver class to find an element on a web page? How to use the find_elmeent_by_css_selectnr method of the Selenium WebDrit(r class to find an element on a web page? How to use the find_element_by_xpath method:name, 'q').send_keys 'Selenium WebDriver'13driver.find_element(:name, 'btnG').click14driver.find_element(:name, 'q').send_keys 'Selenium WebDriver'15driver.find_element(:name, 'btnG').click16driver.find_element(:name, 'q').send_keys 'Selenium WebDriver'17driver.find_element(:name, 'btnG').click

Full Screen

Full Screen

remove

Using AI Code Generation

copy

Full Screen

1element = driver.find_element(:name, 'q')2result = driver.find_element(:class, 'r')3element = driver.find_element(:name, 'q')4result = driver.find_element(:class, 'r')5driver.execute_script("arguments[0].remove();", result)6driver.manage().window().maximize()7driver.manage().window().maximize()8driver.manage().window().maximize()

Full Screen

Full Screen

remove

Using AI Code Generation

copy

Full Screen

1element = driver.find_element(:name, 'q')2result = driver.find_element(:class, 'r')3element = driver.find_element(:name, 'q')4result = driver.find_element(:class, 'r')5driver.execute_script("arguments[0].remove();", result)

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Selenium automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Most used method in

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful