How to use expect_request method of Selenium.WebDriver.Chrome Package

Best Selenium code snippet using Selenium.WebDriver.Chrome.expect_request

session_spec.rb

Source:session_spec.rb Github

copy

Full Screen

...14 'sauce:options': {username: 'foo',15 accessKey: '123',16 build: 'TEMP BUILD: 11'}}17 end18 def expect_request(caps = default_capabilities)19 body = {capabilities: {alwaysMatch: caps}}.to_json20 endpoint ||= 'https://ondemand.us-west-1.saucelabs.com/wd/hub/session'21 stub_request(:post, endpoint).with(body: body).to_return(valid_response)22 end23 before do24 allow_any_instance_of(Selenium::WebDriver::Remote::Http::Default).to receive(:use_proxy?).and_return(false)25 end26 describe '#new' do27 it 'creates default Options instance if none is provided' do28 ClimateControl.modify(**BUILD_ENV) do29 @session = Session.new30 end31 expected_caps = {'browserName' => 'chrome',32 'browserVersion' => 'latest',33 'platformName' => 'Windows 10',34 'sauce:options' => {'build' => 'TEMP BUILD: 11',35 'username' => 'foo',36 'accessKey' => '123'}}37 ClimateControl.modify(**SAUCE_ACCESS) do38 @results = @session.to_selenium39 end40 expect(@results[:url]).to eq 'https://ondemand.us-west-1.saucelabs.com/wd/hub'41 expect(@results[:capabilities].as_json).to eq expected_caps42 end43 it 'uses provided Options class' do44 ClimateControl.modify(**BUILD_ENV) do45 @sauce_opts = Options.chrome(browser_version: '123',46 platform_name: 'Mac',47 idle_timeout: 4)48 end49 session = Session.new(@sauce_opts)50 expected_caps = {'browserName' => 'chrome',51 'browserVersion' => '123',52 'platformName' => 'Mac',53 'sauce:options' => {'idleTimeout' => 4,54 'build' => 'TEMP BUILD: 11',55 'username' => 'foo',56 'accessKey' => '123'}}57 ClimateControl.modify(**SAUCE_ACCESS) do58 @results = session.to_selenium59 end60 expect(@results[:url]).to eq 'https://ondemand.us-west-1.saucelabs.com/wd/hub'61 expect(@results[:capabilities].as_json).to eq expected_caps62 end63 it 'defaults to US West data Center' do64 ClimateControl.modify(**BUILD_ENV) do65 @session = Session.new66 end67 expect(@session.data_center).to eq :US_WEST68 end69 it 'uses provided Data Center' do70 ClimateControl.modify(**BUILD_ENV) do71 @session = Session.new(data_center: :EU_CENTRAL)72 end73 expected_caps = {'browserName' => 'chrome',74 'browserVersion' => 'latest',75 'platformName' => 'Windows 10',76 'sauce:options' => {'build' => 'TEMP BUILD: 11',77 'username' => 'foo',78 'accessKey' => '123'}}79 ClimateControl.modify(**SAUCE_ACCESS) do80 @results = @session.to_selenium81 end82 expect(@results[:url]).to eq 'https://ondemand.eu-central-1.saucelabs.com/wd/hub'83 expect(@results[:capabilities].as_json).to eq expected_caps84 end85 it 'uses provided Event Listener' do86 listener = instance_double(Selenium::WebDriver::Support::AbstractEventListener)87 ClimateControl.modify(**BUILD_ENV) do88 @session = Session.new(listener: listener)89 end90 ClimateControl.modify(**SAUCE_ACCESS) do91 expect(@session.to_selenium[:listener]).to eq listener92 end93 end94 it 'uses provided HTTP Client' do95 http_client = instance_double(Selenium::WebDriver::Remote::Http::Default)96 ClimateControl.modify(**BUILD_ENV) do97 @session = Session.new(http_client: http_client)98 end99 ClimateControl.modify(**SAUCE_ACCESS) do100 expect(@session.to_selenium[:http_client]).to eq http_client101 end102 end103 it 'raises exception if data center is invalid' do104 ClimateControl.modify(**BUILD_ENV) do105 expect { Session.new(data_center: :FOO) }.to raise_exception(ArgumentError)106 end107 end108 end109 describe '#start' do110 it 'starts the session and returns Selenium Driver instance' do111 expect_request112 ClimateControl.modify(**BUILD_ENV, **SAUCE_ACCESS) do113 @driver = Session.new.start114 end115 expect(@driver).to be_a Selenium::WebDriver::Driver116 end117 it 'raises exception if no username set' do118 ClimateControl.modify SAUCE_USERNAME: nil do119 expect { Session.new.start }.to raise_exception(ArgumentError)120 end121 end122 it 'raises exception if no access key set' do123 ClimateControl.modify SAUCE_ACCESS_KEY: nil do124 expect { Session.new.start }.to raise_exception(ArgumentError)125 end126 end127 end128 describe '#stop' do129 it 'quits the driver' do130 expect_request131 ClimateControl.modify(**BUILD_ENV) do132 @session = Session.new133 end134 ClimateControl.modify(**SAUCE_ACCESS) do135 @driver = @session.start136 end137 allow(@session).to receive :print_results138 allow(@driver).to receive :quit139 allow(SauceWhisk::Jobs).to receive(:change_status).with('0', false)140 @session.stop(false)141 expect(@driver).to have_received(:quit)142 expect(SauceWhisk::Jobs).to have_received(:change_status).with('0', false)143 end144 it 'raises error when argument value is not boolean' do145 expect_request146 ClimateControl.modify(**BUILD_ENV) do147 @session = Session.new148 end149 ClimateControl.modify(**SAUCE_ACCESS) do150 @driver = @session.start151 end152 allow(@driver).to receive :quit153 expect { @session.stop('String') }.to raise_error(ArgumentError)154 end155 end156 describe '#data_center=' do157 it 'overrides default value for data center' do158 session = Session.new159 session.data_center = :US_EAST160 expect(session.url).to eq('https://ondemand.us-east-1.saucelabs.com/wd/hub')161 end162 it 'raises exception if data center is invalid' do163 session = Session.new164 expect { session.data_center = :FOO }.to raise_exception(ArgumentError)165 end166 end167 describe '#http_client=' do168 it 'uses provided HTTP Client' do169 http_client = instance_double(Selenium::WebDriver::Remote::Http::Default)170 session = Session.new171 session.http_client = http_client172 expect(session.to_selenium[:http_client]).to eq http_client173 end174 end175 describe '#listener=' do176 it 'uses provided Event Listener' do177 listener = instance_double(Selenium::WebDriver::Support::AbstractEventListener)178 ClimateControl.modify(**BUILD_ENV) do179 @session = Session.new180 end181 @session.listener = listener182 ClimateControl.modify(**SAUCE_ACCESS) do183 expect(@session.to_selenium[:listener]).to eq listener184 end185 end186 end187 describe '#url=' do188 it 'allows user to override default URL' do189 ClimateControl.modify(**BUILD_ENV) do190 @session = Session.new191 end192 @session.url = 'https://mycustomurl/foo/wd/hub:8080'193 expected_caps = {'browserName' => 'chrome',194 'browserVersion' => 'latest',195 'platformName' => 'Windows 10',196 'sauce:options' => {'build' => 'TEMP BUILD: 11',197 'username' => 'foo',198 'accessKey' => '123'}}199 ClimateControl.modify(**SAUCE_ACCESS) do200 @results = @session.to_selenium201 end202 expect(@results[:url]).to eq 'https://mycustomurl/foo/wd/hub:8080'203 expect(@results[:capabilities].as_json).to eq expected_caps204 end205 end206 describe '#annotate' do207 it 'raises exception if session not started' do208 ClimateControl.modify(**BUILD_ENV) do209 @session = Session.new210 end211 expect { @session.annotate('Comment') }.to raise_error(SessionNotStartedError)212 end213 it 'accepts annotation' do214 expect_request215 ClimateControl.modify(**BUILD_ENV) do216 @session = Session.new217 end218 ClimateControl.modify(**SAUCE_ACCESS) do219 @driver = @session.start220 end221 allow(@driver).to receive :quit222 allow(@driver).to receive(:execute_script)223 @session.annotate('comment')224 expect(@driver).to have_received(:execute_script).with('sauce:context=comment')225 end226 end227 describe '#pause' do228 it 'raises exception if session not started' do229 ClimateControl.modify(**BUILD_ENV) do230 @session = Session.new231 end232 expect { @session.pause }.to raise_error(SessionNotStartedError)233 end234 it 'pauses test' do235 expect_request236 ClimateControl.modify(**BUILD_ENV) do237 @session = Session.new238 end239 ClimateControl.modify(**SAUCE_ACCESS) do240 @driver = @session.start241 end242 allow(@driver).to receive :quit243 allow(@driver).to receive(:execute_script)244 message = "\nThis test has been stopped; no more driver commands will be accepted\n\n" \245 "You can take manual control of the test from the Sauce Labs UI here: https://app.saucelabs.com/tests/0\n"246 expect { @session.pause }.to output(message).to_stdout247 expect(@driver).to have_received(:execute_script).with('sauce: break')248 end249 end250 describe '#enable_logs' do251 it 'raises exception if session not started' do252 ClimateControl.modify(**BUILD_ENV) do253 @session = Session.new254 end255 expect { @session.enable_logging }.to raise_error(SessionNotStartedError)256 end257 it 'enables logs' do258 expect_request259 ClimateControl.modify(**BUILD_ENV) do260 @session = Session.new261 end262 ClimateControl.modify(**SAUCE_ACCESS) do263 @driver = @session.start264 end265 allow(@driver).to receive :quit266 allow(@driver).to receive(:execute_script)267 @session.enable_logging268 expect(@driver).to have_received(:execute_script).with('sauce: enable log')269 end270 end271 describe '#disable_logs' do272 it 'raises exception if session not started' do273 ClimateControl.modify(**BUILD_ENV) do274 @session = Session.new275 end276 expect { @session.disable_logging }.to raise_error(SessionNotStartedError)277 end278 it 'disables logs' do279 expect_request280 ClimateControl.modify(**BUILD_ENV) do281 @session = Session.new282 end283 ClimateControl.modify(**SAUCE_ACCESS) do284 @driver = @session.start285 end286 allow(@driver).to receive :quit287 allow(@driver).to receive(:execute_script)288 @session.disable_logging289 expect(@driver).to have_received(:execute_script).with('sauce: disable log')290 end291 end292 describe '#stop_network' do293 it 'raises exception if session not started' do294 ClimateControl.modify(**BUILD_ENV) do295 @session = Session.new296 end297 expect { @session.stop_network }.to raise_error(SessionNotStartedError)298 end299 it 'raises exception if session not on a Mac' do300 expect_request301 ClimateControl.modify(**BUILD_ENV) do302 @session = Session.new303 end304 ClimateControl.modify(**SAUCE_ACCESS) do305 @driver = @session.start306 end307 allow(@driver).to receive :quit308 allow(@driver).to receive(:execute_script)309 error = /Can only start or stop the network on a Mac/310 expect { @session.stop_network }.to raise_error(InvalidPlatformError, error)311 end312 it 'stops network' do313 caps = default_capabilities.merge(platformName: 'mac')314 expect_request(caps)315 ClimateControl.modify(**BUILD_ENV) do316 @session = Session.new(Options.chrome(platform_name: 'mac'))317 end318 ClimateControl.modify(**SAUCE_ACCESS) do319 @driver = @session.start320 end321 allow(@driver).to receive :quit322 allow(@driver).to receive(:execute_script)323 @session.stop_network324 expect(@driver).to have_received(:execute_script).with('sauce: stop network')325 end326 end327 describe '#start_network' do328 it 'raises exception if session not started' do329 ClimateControl.modify(**BUILD_ENV) do330 @session = Session.new331 end332 expect { @session.start_network }.to raise_error(SessionNotStartedError)333 end334 it 'raises exception if session not on a Mac' do335 expect_request336 ClimateControl.modify(**BUILD_ENV) do337 @session = Session.new338 end339 ClimateControl.modify(**SAUCE_ACCESS) do340 @driver = @session.start341 end342 allow(@driver).to receive :quit343 allow(@driver).to receive(:execute_script)344 error = /Can only start or stop the network on a Mac/345 expect { @session.start_network }.to raise_error(InvalidPlatformError, error)346 end347 it 'starts network' do348 caps = default_capabilities.merge(platformName: 'mac')349 expect_request(caps)350 ClimateControl.modify(**BUILD_ENV) do351 @session = Session.new(Options.chrome(platform_name: 'mac'))352 end353 ClimateControl.modify(**SAUCE_ACCESS) do354 @driver = @session.start355 end356 allow(@driver).to receive :quit357 allow(@driver).to receive(:execute_script)358 @session.start_network359 expect(@driver).to have_received(:execute_script).with('sauce: start network')360 end361 end362 describe '#change_name' do363 it 'raises exception if session not started' do364 ClimateControl.modify(**BUILD_ENV) do365 @session = Session.new366 end367 expect { @session.change_name('New Name') }.to raise_error(SessionNotStartedError)368 end369 it 'changes the test name' do370 expect_request371 ClimateControl.modify(**BUILD_ENV) do372 @session = Session.new373 end374 ClimateControl.modify(**SAUCE_ACCESS) do375 @driver = @session.start376 end377 allow(@driver).to receive :quit378 allow(@driver).to receive(:execute_script)379 @session.change_name('New Name')380 expect(@driver).to have_received(:execute_script).with('sauce:job-name=New Name')381 end382 end383 describe '#tags=' do384 it 'raises exception if session not started' do385 ClimateControl.modify(**BUILD_ENV) do386 @session = Session.new387 end388 expect { @session.add_tags([]) }.to raise_error(SessionNotStartedError)389 end390 it 'accepts single tag' do391 expect_request392 ClimateControl.modify(**BUILD_ENV) do393 @session = Session.new394 end395 ClimateControl.modify(**SAUCE_ACCESS) do396 @driver = @session.start397 end398 allow(@driver).to receive :quit399 allow(@driver).to receive(:execute_script)400 @session.add_tags 'foo'401 expect(@driver).to have_received(:execute_script).with('sauce:job-tags=foo')402 end403 it 'accepts multiple tags as String' do404 expect_request405 ClimateControl.modify(**BUILD_ENV) do406 @session = Session.new407 end408 ClimateControl.modify(**SAUCE_ACCESS) do409 @driver = @session.start410 end411 allow(@driver).to receive :quit412 allow(@driver).to receive(:execute_script)413 @session.add_tags 'foo,bar'414 expect(@driver).to have_received(:execute_script).with('sauce:job-tags=foo,bar')415 end416 it 'accepts multiple tags as Array' do417 expect_request418 ClimateControl.modify(**BUILD_ENV) do419 @session = Session.new420 end421 ClimateControl.modify(**SAUCE_ACCESS) do422 @driver = @session.start423 end424 allow(@driver).to receive :quit425 allow(@driver).to receive(:execute_script)426 @session.add_tags %w[foo bar]427 expect(@driver).to have_received(:execute_script).with('sauce:job-tags=foo,bar')428 end429 end430 end431end...

Full Screen

Full Screen

driver_spec.rb

Source:driver_spec.rb Github

copy

Full Screen

...24 {status: 200,25 body: {value: {sessionId: 0, capabilities: Remote::Capabilities.chrome}}.to_json,26 headers: {"content_type": "application/json"}}27 end28 def expect_request(body: nil, endpoint: nil)29 body = (body || {capabilities: {firstMatch: [browserName: "chrome"]}}).to_json30 endpoint ||= "http://127.0.0.1:4444/wd/hub/session"31 stub_request(:post, endpoint).with(body: body).to_return(valid_response)32 end33 it 'requires parameters' do34 # Note that this is not a valid Session package, so expecting this request means we expect it to fail35 expect_request(body: {capabilities: {firstMatch: [{}]}})36 expect { Driver.new }.not_to raise_exception37 end38 context 'with :desired capabilities' do39 it 'accepts value as a Symbol' do40 expect_request41 expect {42 expect { Driver.new(desired_capabilities: :chrome) }.to have_deprecated(:desired_capabilities)43 }.not_to raise_exception44 end45 it 'accepts a generated Capabilities instance' do46 capabilities = Remote::Capabilities.chrome47 expect_request48 expect {49 expect { Driver.new(desired_capabilities: capabilities) }.to have_deprecated(:desired_capabilities)50 }.not_to raise_exception51 end52 it 'accepts constructed Capabilities with Snake Case as Symbols' do53 capabilities = Remote::Capabilities.new(browser_name: 'chrome', invalid: 'foobar')54 expect_request(body: {capabilities: {firstMatch: [browserName: "chrome", invalid: 'foobar']}})55 expect {56 expect { Driver.new(desired_capabilities: capabilities) }.to have_deprecated(:desired_capabilities)57 }.not_to raise_exception58 end59 it 'accepts constructed Capabilities with Camel Case as Symbols' do60 capabilities = Remote::Capabilities.new(browserName: 'chrome', invalid: 'foobar')61 expect_request(body: {capabilities: {firstMatch: [browserName: "chrome", invalid: 'foobar']}})62 expect {63 expect { Driver.new(desired_capabilities: capabilities) }.to have_deprecated(:desired_capabilities)64 }.not_to raise_exception65 end66 it 'accepts constructed Capabilities with Camel Case as Strings' do67 capabilities = Remote::Capabilities.new('browserName' => 'chrome', 'invalid' => 'foobar')68 expect_request(body: {capabilities: {firstMatch: [browserName: "chrome", invalid: 'foobar']}})69 expect {70 expect { Driver.new(desired_capabilities: capabilities) }.to have_deprecated(:desired_capabilities)71 }.not_to raise_exception72 end73 it 'accepts Hash with Camel Case keys as Symbols' do74 capabilities = {browserName: 'chrome', invalid: 'foobar'}75 expect_request(body: {capabilities: {firstMatch: [browserName: "chrome", invalid: 'foobar']}})76 expect {77 expect { Driver.new(desired_capabilities: capabilities) }.to have_deprecated(:desired_capabilities)78 }.not_to raise_exception79 end80 it 'accepts Hash with Camel Case keys as Strings' do81 capabilities = {"browserName" => 'chrome', "invalid" => 'foobar'}82 expect_request(body: {capabilities: {firstMatch: [browserName: "chrome", invalid: 'foobar']}})83 expect {84 expect { Driver.new(desired_capabilities: capabilities) }.to have_deprecated(:desired_capabilities)85 }.not_to raise_exception86 end87 end88 it 'uses provided URL' do89 server = "http://example.com:4646/wd/hub"90 expect_request(endpoint: "#{server}/session")91 expect {92 expect {93 Driver.new(desired_capabilities: :chrome, url: server)94 }.to have_deprecated(:desired_capabilities)95 }.not_to raise_exception96 end97 it 'uses provided HTTP Client' do98 client = Remote::Http::Default.new99 expect_request100 expect {101 driver = Driver.new(desired_capabilities: :chrome, http_client: client)102 expect(driver.send(:bridge).http).to eq client103 }.to have_deprecated(:desired_capabilities)104 end105 it 'accepts Options as sole parameter' do106 opts = {args: ['-f']}107 expect_request(body: {capabilities: {firstMatch: [browserName: 'chrome', "goog:chromeOptions": opts]}})108 expect {109 expect { Driver.new(options: Chrome::Options.new(**opts)) }.to have_deprecated(:browser_options)110 }.not_to raise_exception111 end112 it 'accepts combination of Options and Capabilities' do113 opts = {args: ['-f']}114 expect_request(body: {capabilities: {firstMatch: [browserName: "chrome", "goog:chromeOptions": opts]}})115 expect {116 expect {117 Driver.new(desired_capabilities: :chrome, options: Chrome::Options.new(**opts))118 }.to have_deprecated(%i[browser_options desired_capabilities])119 }.not_to raise_exception120 end121 it 'raises an ArgumentError if parameter is not recognized' do122 msg = 'Unable to create a driver with parameters: {:invalid=>"foo"}'123 expect { Driver.new(invalid: 'foo') }.to raise_error(ArgumentError, msg)124 end125 context 'with :capabilities' do126 it 'accepts value as a Symbol' do127 expect_request(body: {capabilities: {firstMatch: [browserName: "chrome"]}})128 expect { Driver.new(capabilities: :chrome) }.not_to raise_exception129 end130 it 'accepts generated Capabilities instance' do131 capabilities = Remote::Capabilities.chrome(invalid: 'foobar')132 expect_request(body: {capabilities: {firstMatch: [browserName: "chrome", invalid: 'foobar']}})133 expect { Driver.new(capabilities: capabilities) }.not_to raise_exception134 end135 it 'accepts constructed Capabilities with Snake Case as Symbols' do136 capabilities = Remote::Capabilities.new(browser_name: 'chrome', invalid: 'foobar')137 expect_request(body: {capabilities: {firstMatch: [browserName: "chrome", invalid: 'foobar']}})138 expect { Driver.new(capabilities: capabilities) }.not_to raise_exception139 end140 it 'accepts constructed Capabilities with Camel Case as Symbols' do141 capabilities = Remote::Capabilities.new(browserName: 'chrome', invalid: 'foobar')142 expect_request(body: {capabilities: {firstMatch: [browserName: "chrome", invalid: 'foobar']}})143 expect { Driver.new(capabilities: capabilities) }.not_to raise_exception144 end145 it 'accepts constructed Capabilities with Camel Case as Strings' do146 capabilities = Remote::Capabilities.new('browserName' => 'chrome', 'invalid' => 'foobar')147 expect_request(body: {capabilities: {firstMatch: [browserName: "chrome", invalid: 'foobar']}})148 expect { Driver.new(capabilities: capabilities) }.not_to raise_exception149 end150 it 'accepts Hash with Camel Case keys as Symbols but is deprecated' do151 capabilities = {browserName: 'chrome', invalid: 'foobar'}152 expect_request(body: {capabilities: {firstMatch: [browserName: "chrome", invalid: 'foobar']}})153 expect {154 expect { Driver.new(capabilities: capabilities) }.to have_deprecated(:capabilities_hash)155 }.not_to raise_exception156 end157 it 'accepts Hash with Camel Case keys as Strings but is deprecated' do158 capabilities = {"browserName" => 'chrome', "invalid" => 'foobar'}159 expect_request(body: {capabilities: {firstMatch: [browserName: "chrome", invalid: 'foobar']}})160 expect {161 expect { Driver.new(capabilities: capabilities) }.to have_deprecated(:capabilities_hash)162 }.not_to raise_exception163 end164 context 'when value is an Array' do165 let(:as_json_object) do166 Class.new do167 def as_json(*)168 {'company:key': 'value'}169 end170 end171 end172 it 'with Options instance' do173 options = Chrome::Options.new(args: ['-f'])174 expect_request(body: {capabilities: {firstMatch: [browserName: "chrome",175 'goog:chromeOptions': {'args': ['-f']}]}})176 expect { Driver.new(capabilities: [options]) }.not_to raise_exception177 end178 it 'with Capabilities instance' do179 capabilities = Remote::Capabilities.new(browser_name: 'chrome', invalid: 'foobar')180 expect_request(body: {capabilities: {firstMatch: [browserName: "chrome", invalid: 'foobar']}})181 expect { Driver.new(capabilities: [capabilities]) }.not_to raise_exception182 end183 it 'with Options instance and an instance of a custom object responding to #as_json' do184 expect_request(body: {capabilities: {firstMatch: [browserName: "chrome",185 'goog:chromeOptions': {},186 'company:key': 'value']}})187 expect { Driver.new(capabilities: [Chrome::Options.new, as_json_object.new]) }.not_to raise_exception188 end189 it 'with Options instance, Capabilities instance and instance of a custom object responding to #as_json' do190 capabilities = Remote::Capabilities.new(browser_name: 'chrome', invalid: 'foobar')191 options = Chrome::Options.new(args: ['-f'])192 expect_request(body: {capabilities: {firstMatch: [browserName: "chrome", invalid: 'foobar',193 'goog:chromeOptions': {'args': ['-f']},194 'company:key': 'value']}})195 expect { Driver.new(capabilities: [capabilities, options, as_json_object.new]) }.not_to raise_exception196 end197 end198 end199 end200 end # Remote201 end # WebDriver202end # Selenium...

Full Screen

Full Screen

capybara_session_spec.rb

Source:capybara_session_spec.rb Github

copy

Full Screen

...15 'sauce:options': {username: 'foo',16 accessKey: '123',17 build: 'TEMP BUILD: 11'}}18 end19 def expect_request20 body = {capabilities: {alwaysMatch: default_capabilities}}.to_json21 endpoint = 'https://ondemand.us-west-1.saucelabs.com/wd/hub/session'22 stub_request(:post, endpoint).with(body: body).to_return(valid_response)23 end24 describe '#new' do25 it 'registers a Capybara Driver' do26 CapybaraSession.new27 expect(Capybara.drivers.names).to include(:sauce)28 expect(Capybara.current_driver).to eq :sauce29 end30 end31 describe '#start' do32 it 'starts the session with Capybara driver' do33 expect_request34 ClimateControl.modify(**SAUCE_ACCESS, **BUILD_ENV) do35 @driver = CapybaraSession.new.start36 end37 expect(@driver).to eq Capybara.current_session.driver.browser38 Capybara.current_session.driver.instance_variable_set('@browser', nil)39 end40 end41 describe '#stop' do42 it 'quits the driver' do43 cappy_driver = instance_double(Capybara::Selenium::Driver)44 driver = instance_double(Selenium::WebDriver::Remote::Driver, session_id: '1234')45 allow(cappy_driver).to receive(:browser).and_return(driver)46 allow(SauceWhisk::Jobs).to receive(:change_status).with('1234', true)47 session = CapybaraSession.new...

Full Screen

Full Screen

expect_request

Using AI Code Generation

copy

Full Screen

1driver.find_element(:name, 'q').send_keys 'Selenium WebDriver'2driver.find_element(:name, 'btnK').click3driver.find_element(:css, 'div.rc > div.r > a').click4driver.find_element(:id, 'q').send_keys 'Selenium WebDriver'5driver.find_element(:id, 'btnK').click6driver.find_element(:css, 'div.rc > div.r > a').click7driver.find_element(:id, 'q').send_keys 'Selenium WebDriver'8driver.find_element(:id, 'btnK').click9driver.find_element(:css, 'div.rc > div.r > a').click10driver.find_element(:id, 'q').send_keys 'Selenium WebDriver'11driver.find_element(:id, 'btnK').click12driver.find_element(:css, 'div.rc > div.r > a').click13driver.find_element(:id, 'q').send_keys 'Selenium WebDriver'14driver.find_element(:id, 'btnK').click15driver.find_element(:css, 'div.rc > div.r > a').click16driver.find_element(:id, 'q').send_keys 'Selenium WebDriver'17driver.find_element(:id, 'btnK').click18driver.find_element(:css, 'div.rc > div.r > a').click19driver.find_element(:id, 'q').send_keys 'Selenium WebDriver'20driver.find_element(:id, 'btnK').click21driver.find_element(:css, 'div.rc > div.r > a').click22driver.find_element(:id, 'q').send_keys 'Selenium WebDriver'23driver.find_element(:id, 'btnK').click24driver.find_element(:css, 'div.rc > div.r > a').click25driver.find_element(:id, 'q').send_keys 'Selenium WebDriver'26driver.find_element(:id, 'btnK').click27driver.find_element(:css, 'div.rc > div.r > a').click28driver.find_element(:id, 'q').send_keys 'Selenium WebDriver'29driver.find_element(:id, 'btnK').click30driver.find_element(:css, 'div.rc > div.r > a').click31driver.find_element(:id, 'q').send_keys 'Selenium WebDriver'

Full Screen

Full Screen

expect_request

Using AI Code Generation

copy

Full Screen

1 def expect_request(&block)2 def initialize(&block)3 block.call(self)4 def initialize(&block)5 block.call(self)6 def to_return(response)7 def initialize(response)8 def call(env)9 def to_raise(error)10 def call(env)

Full Screen

Full Screen

expect_request

Using AI Code Generation

copy

Full Screen

1driver.expect_request(2 headers: { 'Accept' => 'text/html' }3driver.expect_request(4 headers: { 'Accept' => 'text/html' }5driver.expect_request(6 headers: { 'Accept' => 'text/html' }7driver.expect_request(8 headers: { 'Accept' => 'text/html' }9driver.expect_request(10 headers: { 'Accept' => 'text/html' }11driver.expect_request(12 headers: { 'Accept' => 'text/html' }

Full Screen

Full Screen

expect_request

Using AI Code Generation

copy

Full Screen

1driver.expect_request("*", 5)2driver.expect_request("http://www.google.com", 5)3driver.expect_request("http://www.google.com", 5)4driver.expect_request("http://www.google.com", 5)5driver.expect_request("http://www.google.com", 5)6driver.expect_request("http://www.google.com", 5)7driver.expect_request("http://www.google.com", 5)

Full Screen

Full Screen

expect_request

Using AI Code Generation

copy

Full Screen

1search_field = driver.find_element(:name, 'q')2search_button = driver.find_element(:name, 'btnG')3wait = Selenium::WebDriver::Wait.new(:timeout => 10)4wait.until { driver.find_element(:id, 'resultStats') }5expect_request(driver, 'http://www.google-analytics.com/ga.js')6def expect_request(driver, url)7 traffic = driver.manage.logs.get(:performance)8 if traffic.any? { |t| t.message.include? url }

Full Screen

Full Screen

expect_request

Using AI Code Generation

copy

Full Screen

1driver.expect_request("http://www.google.com", 5)2driver.expect_request("http://www.google.com", 5)3driver.expect_request("http://www.google.com", 5)4driver.expect_request("http://www.google.com", 5)5driver.expect_request("http://www.google.com", 5)6driver.expect_request("http://www.google.com", 5)

Full Screen

Full Screen

expect_request

Using AI Code Generation

copy

Full Screen

1search_field = driver.find_element(:name, 'q')2search_button = driver.find_element(:name, 'btnG')3wait = Selenium::WebDriver::Wait.new(:timeout => 10)4wait.until { driver.find_element(:id, 'resultStats') }5expect_request(driver, 'http://www.google-analytics.com/ga.js')6def expect_request(driver, url)7 traffic = driver.manage.logs.get(:performance)8 if traffic.any? { |t| t.message.include? url }

Full Screen

Full Screen

expect_request

Using AI Code Generation

copy

Full Screen

1driver.find_element(:name, 'q').send_keys 'Selenium WebDriver'2driver.find_element(:name, 'btnK').click3driver.find_element(:css, 'div.rc > div.r > a').click4driver.find_element(:id, 'q').send_keys 'Selenium WebDriver'5driver.find_element(:id, 'btnK').click6driver.find_element(:css, 'div.rc > div.r > a').click7driver.find_element(:id, 'q').send_keys 'Selenium WebDriver'8driver.find_element(:id, 'btnK').click9driver.find_element(:css, 'div.rc > div.r > a').click10driver.find_element(:id, 'q').send_keys 'Selenium WebDriver'11driver.find_element(:id, 'btnK').click12driver.find_element(:css, 'div.rc > div.r > a').click13driver.find_element(:id, 'q').send_keys 'Selenium WebDriver'14driver.find_element(:id, 'btnK').click15driver.find_element(:css, 'div.rc > div.r > a').click16driver.find_element(:id, 'q').send_keys 'Selenium WebDriver'17driver.find_element(:id, 'btnK').click18driver.find_element(:css, 'div.rc > div.r > a').click19driver.find_element(:id, 'q').send_keys 'Selenium WebDriver'20driver.find_element(:id, 'btnK').click21driver.find_element(:css, 'div.rc > div.r > a').click22driver.find_element(:id, 'q').send_keys 'Selenium WebDriver'23driver.find_element(:id, 'btnK').click24driver.find_element(:css, 'div.rc > div.r > a').click25driver.find_element(:id, 'q').send_keys 'Selenium WebDriver'26driver.find_element(:id, 'btnK').click27driver.find_element(:css, 'div.rc > div.r > a').click28driver.find_element(:id, 'q').send_keys 'Selenium WebDriver'29driver.find_element(:id, 'btnK').click30driver.find_element(:css, 'div.rc > div.r > a').click31driver.find_element(:id, 'q').send_keys 'Selenium WebDriver'

Full Screen

Full Screen

expect_request

Using AI Code Generation

copy

Full Screen

1search_field = driver.find_element(:name, 'q')2search_button = driver.find_element(:name, 'btnG')3wait = Selenium::WebDriver::Wait.new(:timeout => 10)4wait.until { driver.find_element(:id, 'resultStats') }5expect_request(driver, 'http://www.google-analytics.com/ga.js')6def expect_request(driver, url)7 traffic = driver.manage.logs.get(:performance)8 if traffic.any? { |t| t.message.include? url }

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.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful