How to use current method of Capybara Package

Best Capybara code snippet using Capybara.current

dsl_spec.rb

Source:dsl_spec.rb Github

copy

Full Screen

...30 Capybara.default_driver = :culerity31 expect(Capybara.default_driver).to eq(:culerity)32 end33 end34 describe '#current_driver' do35 it "should default to the default driver" do36 expect(Capybara.current_driver).to eq(:rack_test)37 Capybara.default_driver = :culerity38 expect(Capybara.current_driver).to eq(:culerity)39 end40 it "should be changeable" do41 Capybara.current_driver = :culerity42 expect(Capybara.current_driver).to eq(:culerity)43 end44 end45 describe '#javascript_driver' do46 it "should default to selenium" do47 expect(Capybara.javascript_driver).to eq(:selenium)48 end49 it "should be changeable" do50 Capybara.javascript_driver = :culerity51 expect(Capybara.javascript_driver).to eq(:culerity)52 end53 end54 describe '#use_default_driver' do55 it "should restore the default driver" do56 Capybara.current_driver = :culerity57 Capybara.use_default_driver58 expect(Capybara.current_driver).to eq(:rack_test)59 end60 end61 describe '#using_driver' do62 before do63 expect(Capybara.current_driver).not_to eq(:selenium)64 end65 it 'should set the driver using Capybara.current_driver=' do66 driver = nil67 Capybara.using_driver(:selenium) { driver = Capybara.current_driver }68 expect(driver).to eq(:selenium)69 end70 it 'should return the driver to default if it has not been changed' do71 Capybara.using_driver(:selenium) do72 expect(Capybara.current_driver).to eq(:selenium)73 end74 expect(Capybara.current_driver).to eq(Capybara.default_driver)75 end76 it 'should reset the driver even if an exception occurs' do77 driver_before_block = Capybara.current_driver78 begin79 Capybara.using_driver(:selenium) { raise "ohnoes!" }80 rescue Exception81 end82 expect(Capybara.current_driver).to eq(driver_before_block)83 end84 it 'should return the driver to what it was previously' do85 Capybara.current_driver = :selenium86 Capybara.using_driver(:culerity) do87 Capybara.using_driver(:rack_test) do88 expect(Capybara.current_driver).to eq(:rack_test)89 end90 expect(Capybara.current_driver).to eq(:culerity)91 end92 expect(Capybara.current_driver).to eq(:selenium)93 end94 it 'should yield the passed block' do95 called = false96 Capybara.using_driver(:selenium) { called = true }97 expect(called).to eq(true)98 end99 end100 describe '#using_wait_time' do101 before do102 @previous_wait_time = Capybara.default_max_wait_time103 end104 after do105 Capybara.default_max_wait_time = @previous_wait_time106 end107 it "should switch the wait time and switch it back" do108 in_block = nil109 Capybara.using_wait_time 6 do110 in_block = Capybara.default_max_wait_time111 end112 expect(in_block).to eq(6)113 expect(Capybara.default_max_wait_time).to eq(@previous_wait_time)114 end115 it "should ensure wait time is reset" do116 expect do117 Capybara.using_wait_time 6 do118 raise "hell"119 end120 end.to raise_error(RuntimeError, "hell")121 expect(Capybara.default_max_wait_time).to eq(@previous_wait_time)122 end123 end124 describe '#app' do125 it "should be changeable" do126 Capybara.app = "foobar"127 expect(Capybara.app).to eq('foobar')128 end129 end130 describe '#current_session' do131 it "should choose a session object of the current driver type" do132 expect(Capybara.current_session).to be_a(Capybara::Session)133 end134 it "should use #app as the application" do135 Capybara.app = proc {}136 expect(Capybara.current_session.app).to eq(Capybara.app)137 end138 it "should change with the current driver" do139 expect(Capybara.current_session.mode).to eq(:rack_test)140 Capybara.current_driver = :selenium141 expect(Capybara.current_session.mode).to eq(:selenium)142 end143 it "should be persistent even across driver changes" do144 object_id = Capybara.current_session.object_id145 expect(Capybara.current_session.object_id).to eq(object_id)146 Capybara.current_driver = :selenium147 expect(Capybara.current_session.mode).to eq(:selenium)148 expect(Capybara.current_session.object_id).not_to eq(object_id)149 Capybara.current_driver = :rack_test150 expect(Capybara.current_session.object_id).to eq(object_id)151 end152 it "should change when changing application" do153 object_id = Capybara.current_session.object_id154 expect(Capybara.current_session.object_id).to eq(object_id)155 Capybara.app = proc {}156 expect(Capybara.current_session.object_id).not_to eq(object_id)157 expect(Capybara.current_session.app).to eq(Capybara.app)158 end159 it "should change when the session name changes" do160 object_id = Capybara.current_session.object_id161 Capybara.session_name = :administrator162 expect(Capybara.session_name).to eq(:administrator)163 expect(Capybara.current_session.object_id).not_to eq(object_id)164 Capybara.session_name = :default165 expect(Capybara.session_name).to eq(:default)166 expect(Capybara.current_session.object_id).to eq(object_id)167 end168 end169 describe "#using_session" do170 it "should change the session name for the duration of the block" do171 expect(Capybara.session_name).to eq(:default)172 Capybara.using_session(:administrator) do173 expect(Capybara.session_name).to eq(:administrator)174 end175 expect(Capybara.session_name).to eq(:default)176 end177 it "should reset the session to the default, even if an exception occurs" do178 begin179 Capybara.using_session(:raise) do180 raise...

Full Screen

Full Screen

current

Using AI Code Generation

copy

Full Screen

1World(Capybara)2World(Capybara)3World(Capybara)4World(Capybara)5World(Capybara)6World(Capybara)7World(Capybara)8World(Capybara)9World(Capybara)

Full Screen

Full Screen

current

Using AI Code Generation

copy

Full Screen

1 def self.find(*args)2 def self.find(*args)3 def self.find(*args)4 def self.find(*args)5 def self.find(*args)6 def self.find(*args)7 def self.find(*args)8 def self.find(*args)9 def self.find(*args)10 def self.find(*args)11 def self.find(*args)

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 Capybara 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