Best Selenium code snippet using Selenium.WebDriver.locked
driver.rb
Source:driver.rb
...72 #73 def lock(duration = nil)74 @bridge.lock(duration)75 end76 # Check current device status is weather locked or not77 #78 # @example79 #80 # @driver.device_locked?81 # @driver.locked?82 #83 def locked?84 @bridge.device_locked?85 end86 alias device_locked? locked?87 # Unlock the device88 #89 # @example90 #91 # @driver.unlock92 #93 def unlock94 @bridge.unlock95 end96 # Hide the onscreen keyboard97 # @param [String] close_key The name of the key which closes the keyboard.98 # Defaults to 'Done' for iOS(except for XCUITest).99 # @param [Symbol] strategy The symbol of the strategy which closes the keyboard.100 # XCUITest ignore this argument....
element.rb
Source:element.rb
...535 end536 end537 def element_call(precondition = nil, &block)538 caller = caller_locations(1, 1)[0].label539 already_locked = Wait.timer.locked?540 unless already_locked541 Wait.timer = Wait::Timer.new(timeout: Watir.default_timeout)542 end543 begin544 check_condition(precondition)545 Watir.logger.info "-> `Executing #{inspect}##{caller}`"546 yield547 rescue unknown_exception => ex548 if precondition.nil?549 element_call(:wait_for_exists, &block)550 end551 msg = ex.message552 msg += "; Maybe look in an iframe?" if @query_scope.ensure_context && @query_scope.iframes.count > 0553 custom_attributes = @locator.nil? ? [] : @locator.selector_builder.custom_attributes554 msg += "; Watir treated #{custom_attributes} as a non-HTML compliant attribute, ensure that was intended" unless custom_attributes.empty?555 raise unknown_exception, msg556 rescue Selenium::WebDriver::Error::StaleElementReferenceError557 @query_scope.ensure_context558 reset!559 retry560 rescue Selenium::WebDriver::Error::ElementNotVisibleError, Selenium::WebDriver::Error::ElementNotInteractableError561 raise_present unless Wait.timer.remaining_time > 0562 raise_present unless precondition == :wait_for_present || precondition == :wait_for_enabled563 retry564 rescue Selenium::WebDriver::Error::InvalidElementStateError565 raise_disabled unless Wait.timer.remaining_time > 0566 raise_disabled unless precondition == :wait_for_writable || precondition == :wait_for_enabled567 retry568 rescue Selenium::WebDriver::Error::NoSuchWindowError569 raise Exception::NoMatchingWindowFoundException, "browser window was closed"570 ensure571 Watir.logger.info "<- `Completed #{inspect}##{caller}`"572 Wait.timer.reset! unless already_locked573 end574 end575 def check_condition(condition)576 Watir.logger.info "<- `Verifying precondition #{inspect}##{condition}`"577 begin578 condition.nil? ? assert_exists : send(condition)579 Watir.logger.info "<- `Verified precondition #{inspect}##{condition || 'assert_exists'}`"580 rescue unknown_exception581 raise unless condition.nil?582 Watir.logger.info "<- `Unable to satisfy precondition #{inspect}##{condition}`"583 check_condition(:wait_for_exists)584 end585 end586 def method_missing(meth, *args, &blk)...
fora_spec.rb
Source:fora_spec.rb
...26 let(:root_html_file) { File.join(minibbs_fixtures_dir, 'index.html') }27 let(:reply_by_me_html_file) { File.join(minibbs_fixtures_dir, 'reply_by_me.html') }28 let(:reply_to_me_html_file) { File.join(minibbs_fixtures_dir, 'reply_to_me.html') }29 let(:topic_html_file) { File.join(minibbs_fixtures_dir, 'topic.html') }30 let(:topic_locked_html_file) { File.join(minibbs_fixtures_dir, 'topic_locked.html') }31 let(:topic_mine_html_file) { File.join(minibbs_fixtures_dir, 'topic_mine.html') }32 let(:topic_posting_html_file) { File.join(minibbs_fixtures_dir, 'topic_posting.html') }33 describe '[instance]' do34 context 'with valid options' do35 subject { Fora.new(valid_options) }36 it 'successfully initializes' do37 expect { subject }.to_not raise_error38 end39 context 'with HTML fixtures' do40 before do41 # modify the method's return values to be local paths42 expect(subject).to receive(:url_for).at_least(:once) do |args|43 # puts args.inspect44 "file://#{args[:path]}"45 end46 end47 it 'loads the correct fixture' do48 expect(@selenium).to receive(:get).with("file://#{root_html_file}").and_call_original49 subject.visit root_html_file50 end51 context 'at the root page' do52 before do53 subject.visit root_html_file54 end55 describe '#topics' do56 it 'is an Array' do57 expect(subject.topics root_html_file).to be_an Array58 end59 it 'finds 20 topics' do60 expect(subject.topics(root_html_file).length).to eq 2061 end62 it 'contains Selenium::WebDriver::Element objects' do63 subject.topics(root_html_file).each do |e|64 expect(e).to be_a Selenium::WebDriver::Element65 end66 end67 it 'calls platform.store_topics' do68 expect(subject.platform).to receive(:store_topics).with(any_args)69 subject.topics(root_html_file)70 end71 end72 describe '#known_topics' do73 it 'is a Hash' do74 expect(subject.known_topics).to be_a Hash75 end76 it 'is empty by default' do77 expect(subject.known_topics).to eq({})78 end79 end80 context 'when calling #topics' do81 before do82 subject.topics root_html_file83 end84 describe '#known_topics' do85 it 'contains 20 topics' do86 expect(subject.known_topics.length).to eq 2087 end88 end89 end90 describe '#my_replies' do91 it 'is an Array' do92 expect(subject.my_replies).to be_an Array93 end94 it 'is empty' do95 expect(subject.my_replies).to be_empty96 end97 end98 describe '#replies_to_me' do99 it 'is an Array' do100 expect(subject.replies_to_me).to be_an Array101 end102 it 'is empty' do103 expect(subject.replies_to_me).to be_empty104 end105 end106 describe '#viewing_a_topic?' do107 it 'is falsey' do108 expect(subject.viewing_a_topic?).to be_falsey109 end110 end111 describe '#topic_is_locked?' do112 it 'is truthy' do113 expect(subject.topic_is_locked?).to be_truthy114 end115 end116 describe '#viewing_my_topic?' do117 it 'is falsey' do118 expect(subject.viewing_my_topic?).to be_falsey119 end120 end121 end122 context 'at a topic page' do123 before do124 subject.visit topic_html_file125 end126 describe '#topics' do127 it 'is an Array' do128 expect(subject.topics topic_html_file).to be_an Array129 end130 it 'finds 0 topics' do131 expect(subject.topics(topic_html_file).length).to eq 0132 end133 end134 describe '#known_topics' do135 it 'is a Hash' do136 expect(subject.known_topics).to be_a Hash137 end138 end139 describe '#my_replies' do140 it 'is an Array' do141 expect(subject.my_replies).to be_an Array142 end143 it 'is empty' do144 expect(subject.my_replies).to be_empty145 end146 end147 describe '#replies_to_me' do148 it 'is an Array' do149 expect(subject.replies_to_me).to be_an Array150 end151 it 'is empty' do152 expect(subject.replies_to_me).to be_empty153 end154 end155 describe '#viewing_a_topic?' do156 it 'is truthy' do157 expect(subject.viewing_a_topic?).to be_truthy158 end159 end160 describe '#topic_is_locked?' do161 it 'is falsey' do162 expect(subject.topic_is_locked?).to be_falsey163 end164 end165 describe '#viewing_my_topic?' do166 it 'is falsey' do167 expect(subject.viewing_my_topic?).to be_falsey168 end169 end170 end171 context 'at a locked topic page' do172 before do173 subject.visit topic_locked_html_file174 end175 describe '#topics' do176 it 'is an Array' do177 expect(subject.topics topic_html_file).to be_an Array178 end179 it 'finds 0 topics' do180 expect(subject.topics(topic_html_file).length).to eq 0181 end182 end183 describe '#known_topics' do184 it 'is a Hash' do185 expect(subject.known_topics).to be_a Hash186 end187 end188 describe '#my_replies' do189 it 'is an Array' do190 expect(subject.my_replies).to be_an Array191 end192 it 'is empty' do193 expect(subject.my_replies).to be_empty194 end195 end196 describe '#replies_to_me' do197 it 'is an Array' do198 expect(subject.replies_to_me).to be_an Array199 end200 it 'is empty' do201 expect(subject.replies_to_me).to be_empty202 end203 end204 describe '#viewing_a_topic?' do205 it 'is truthy' do206 expect(subject.viewing_a_topic?).to be_truthy207 end208 end209 describe '#topic_is_locked?' do210 it 'is truthy' do211 expect(subject.topic_is_locked?).to be_truthy212 end213 end214 describe '#viewing_my_topic?' do215 it 'is falsey' do216 expect(subject.viewing_my_topic?).to be_falsey217 end218 end219 end220 context 'at my topic page' do221 before do222 subject.visit topic_mine_html_file223 end224 describe '#topics' do225 it 'is an Array' do226 expect(subject.topics topic_html_file).to be_an Array227 end228 it 'finds 0 topics' do229 expect(subject.topics(topic_html_file).length).to eq 0230 end231 end232 describe '#known_topics' do233 it 'is a Hash' do234 expect(subject.known_topics).to be_a Hash235 end236 end237 describe '#my_replies' do238 it 'is an Array' do239 expect(subject.my_replies).to be_an Array240 end241 it 'contains 1 reply' do242 expect(subject.my_replies.length).to eq 1243 end244 end245 describe '#replies_to_me' do246 it 'is an Array' do247 expect(subject.replies_to_me).to be_an Array248 end249 it 'is empty' do250 expect(subject.replies_to_me).to be_empty251 end252 end253 describe '#viewing_a_topic?' do254 it 'is true' do255 expect(subject.viewing_a_topic?).to eq true256 end257 end258 describe '#topic_is_locked?' do259 it 'is false' do260 expect(subject.topic_is_locked?).to eq false261 end262 end263 describe '#viewing_my_topic?' do264 it 'is truthy' do265 expect(subject.viewing_my_topic?).to be_truthy266 end267 it 'returns the topic post' do268 expect(subject.viewing_my_topic?).to be_a(Selenium::WebDriver::Element)269 end270 end271 end272 context 'at the new topic page' do273 before do274 subject.visit topic_posting_html_file275 end276 describe '#topics' do277 it 'is an Array' do278 expect(subject.topics topic_html_file).to be_an Array279 end280 it 'finds 0 topics' do281 expect(subject.topics(topic_html_file).length).to eq 0282 end283 end284 describe '#known_topics' do285 it 'is a Hash' do286 expect(subject.known_topics).to be_a Hash287 end288 end289 describe '#my_replies' do290 it 'is an Array' do291 expect(subject.my_replies).to be_an Array292 end293 it 'is empty' do294 expect(subject.my_replies).to be_empty295 end296 end297 describe '#replies_to_me' do298 it 'is an Array' do299 expect(subject.replies_to_me).to be_an Array300 end301 it 'is empty' do302 expect(subject.replies_to_me).to be_empty303 end304 end305 describe '#viewing_a_topic?' do306 it 'is false' do307 expect(subject.viewing_a_topic?).to eq false308 end309 end310 describe '#topic_is_locked?' do311 it 'is true' do312 expect(subject.topic_is_locked?).to eq true313 end314 end315 describe '#viewing_my_topic?' do316 it 'is false' do317 expect(subject.viewing_my_topic?).to eq false318 end319 end320 end321 context 'on a page with replies written by me' do322 before do323 subject.visit reply_by_me_html_file324 end325 describe '#topics' do326 it 'is an Array' do327 expect(subject.topics topic_html_file).to be_an Array328 end329 it 'finds 0 topics' do330 expect(subject.topics(topic_html_file).length).to eq 0331 end332 end333 describe '#known_topics' do334 it 'is a Hash' do335 expect(subject.known_topics).to be_a Hash336 end337 end338 describe '#my_replies' do339 it 'is an Array' do340 expect(subject.my_replies).to be_an Array341 end342 it 'is contains 1 reply' do343 expect(subject.my_replies.length).to eq 1344 end345 it 'contains Selenium::WebDriver::Element objects' do346 subject.my_replies.each do |e|347 expect(e).to be_a Selenium::WebDriver::Element348 end349 end350 end351 describe '#replies_to_me' do352 it 'is an Array' do353 expect(subject.replies_to_me).to be_an Array354 end355 it 'is empty' do356 expect(subject.replies_to_me).to be_empty357 end358 end359 describe '#viewing_a_topic?' do360 it 'is true' do361 expect(subject.viewing_a_topic?).to eq true362 end363 end364 describe '#topic_is_locked?' do365 it 'is false' do366 expect(subject.topic_is_locked?).to eq false367 end368 end369 describe '#viewing_my_topic?' do370 it 'is false' do371 expect(subject.viewing_my_topic?).to eq false372 end373 end374 end375 context 'on a page with replies addressed to me' do376 before do377 subject.visit reply_to_me_html_file378 end379 describe '#topics' do380 it 'is an Array' do381 expect(subject.topics topic_html_file).to be_an Array382 end383 it 'finds 0 topics' do384 expect(subject.topics(topic_html_file).length).to eq 0385 end386 end387 describe '#known_topics' do388 it 'is a Hash' do389 expect(subject.known_topics).to be_a Hash390 end391 end392 describe '#my_replies' do393 it 'is an Array' do394 expect(subject.my_replies).to be_an Array395 end396 it 'is contains 1 reply' do397 expect(subject.my_replies.length).to eq 2398 end399 it 'contains Selenium::WebDriver::Element objects' do400 subject.my_replies.each do |e|401 expect(e).to be_a Selenium::WebDriver::Element402 end403 end404 end405 describe '#replies_to_me' do406 it 'is an Array' do407 expect(subject.replies_to_me).to be_an Array408 end409 it 'contains 1 reply' do410 expect(subject.replies_to_me.length).to eq 1411 end412 it 'contains Selenium::WebDriver::Element objects' do413 subject.replies_to_me.each do |e|414 expect(e).to be_a Selenium::WebDriver::Element415 end416 end417 end418 describe '#viewing_a_topic?' do419 it 'is true' do420 expect(subject.viewing_a_topic?).to eq true421 end422 end423 describe '#topic_is_locked?' do424 it 'is false' do425 expect(subject.topic_is_locked?).to eq false426 end427 end428 describe '#viewing_my_topic?' do429 it 'is false' do430 expect(subject.viewing_my_topic?).to eq false431 end432 end433 end434 end435 end436 end437 end438end...
TC_010_signing_key_add_and_build_rspec.rb
Source:TC_010_signing_key_add_and_build_rspec.rb
...107 it "IT_004: iOS: The signing-key used by the app was the default signing-key " do 108 name = @app_builds_page.ios_get_signing_key_name_of_id @current_app_id109 name.should eql @data_signing_key[:ios][:name_valid]110 end111 it "IT_005: iOS: the signing-key was locked after adding one. " do 112 # @driver.navigate.refresh113 sleep 30114 Selenium::WebDriver::Wait.new(:timeout => 300).until { ios_signing_key_dropdown_select.attribute("disabled") == nil }115 dropdown = Selenium::WebDriver::Support::Select.new(ios_signing_key_dropdown_select)116 dropdown.select_by(:text, @data_str[$lang][:apps_builds_add_a_key])117 @app_builds_page.ios_add_signing_key118 @app_builds_page.ios_get_status_of_the_signing_key.should eql @data_str[$lang][:apps_signing_key_locked]119 end120 it "IT_006: iOS: got an error message after building with a locked signing_key" do 121 rebuild_all_btn.click122 sleep 10123 txt = @app_builds_page.ios_get_error_msg_of_the_signing_key.strip124 puts "+ <testcases><TC_010> iOS: Error msg with locked key: #{txt}"125 txt.should eql @data_str[$lang][:error_msg_ios_build_with_locked_signing_key]126 end127 it "IT_007: iOS: the signing-key used was the signing-key just added after unlocking the key and then building " do 128 @app_builds_page.to_unlock_ios_signing_key129 rebuild_all_btn.click130 puts "+ <testcases><TC_010> iOS: after 'rebuild_all' button was clicked"131 sleep 10132 signing_key_name = @app_builds_page.ios_get_signing_key_name_of_id @current_app_id133 signing_key_name.should eql "abc#{@data_signing_key[:ios][:name_valid]}"134 end135 it "IT_008: Android: the signing-key was locked after adding one" do 136 Selenium::WebDriver::Wait.new(:timeout => 300).until { android_signing_key_dropdown_select.attribute("disabled") == nil }137 dropdown = Selenium::WebDriver::Support::Select.new(android_signing_key_dropdown_select)138 dropdown.select_by(:text, @data_str[$lang][:apps_builds_add_a_key])139 @app_builds_page.android_add_signing_key140 @app_builds_page.android_get_status_of_the_signing_key.should eql @data_str[$lang][:apps_signing_key_locked]141 end142 it "IT_009: Android: got an error message after building with a locked signing-key" do 143 rebuild_all_btn.click144 sleep 10145 txt = @app_builds_page.android_get_error_msg_of_the_signing_key.strip146 puts "+ <testcases><TC_010> Android: Error msg with locked key: #{txt}"147 txt.should eql @data_str[$lang][:error_msg_android_build_with_locked_signing_key]148 end149 it "IT_010: Android: the signing-key used was the signing-key just added after unlocking the key and then building" do 150 @app_builds_page.to_unlock_android_signing_key151 rebuild_all_btn.click 152 puts "+ <testcases><TC_010> BlackBerry: after 'rebuild_all' button was clicked "153 sleep 10154 signing_key_name = @app_builds_page.android_get_signing_key_name_of @current_app_id155 signing_key_name.should eql "abc#{@data_signing_key[:android][:name_valid]}"156 end157 it "IT_011: BlackBerry: The signing-key was locked after adding one. " do 158 Selenium::WebDriver::Wait.new(:timeout => 300).until { blackberry_signing_key_dropdown_select.attribute("disabled") == nil }159 dropdown = Selenium::WebDriver::Support::Select.new(blackberry_signing_key_dropdown_select)160 dropdown.select_by(:text, @data_str[$lang][:apps_builds_add_a_key])161 @app_builds_page.blackberry_add_signing_key162 @app_builds_page.blackberry_get_status_of_the_signing_key.should eql @data_str[$lang][:apps_signing_key_locked]163 end164 it "IT_012: BlackBerry: Got an error message after building with a locked signing-key " do 165 rebuild_all_btn.click166 sleep 10167 txt = @app_builds_page.blackberry_get_error_msg_of_the_signing_key.strip168 puts "+ <testcases><TC_010> BlackBerry: Error msg with locked key: #{txt}"169 txt.should eql @data_str[$lang][:error_msg_blackberry_build_with_locked_signing_key]170 end171 it "IT_013: BlackBerry: the signing_key used was the signing_key just added after unlocking the key and building" do 172 @app_builds_page.to_unlock_blackberry_signing_key173 rebuild_all_btn.click 174 puts "+ <testcases><TC_010> BlackBerry: after 'rebuild_all' button was clicked "175 sleep 10176 signing_key_name = @app_builds_page.blackberry_get_signing_key_name_of @current_app_id177 signing_key_name.should eql "abc#{@data_signing_key[:blackberry][:name_valid]}"178 end179 end180end...
test_spec.rb
Source:test_spec.rb
...33 expect(subject.viewing_a_topic?).to be_truthy34 end35 end36 end37 describe 'topic_is_locked?' do38 #39 it 'does not raise_error' do40 expect { subject.topic_is_locked? }.to_not raise_error41 end42 it 'is truthy' do43 expect(subject.topic_is_locked?).to be_truthy44 end45 context '(and viewing_a_topic? is true)' do46 before do47 expect(subject).to receive(:viewing_a_topic?).48 at_least(:once).49 and_return(true)50 end51 context '(when #call_driver_finder is truthy)' do52 before do53 expect(subject).to receive(:call_driver_finder).54 at_least(:once).55 and_return('element')56 end57 it 'is truthy' do58 expect(subject.topic_is_locked?).to be_truthy59 end60 end61 context '(when #call_driver_finder is falsey)' do62 before do63 expect(subject).to receive(:call_driver_finder).64 at_least(:once).65 and_return(false)66 end67 it 'is falsey' do68 expect(subject.topic_is_locked?).to be_falsey69 end70 end71 end72 end73 describe 'viewing_my_topic?' do74 #75 it 'does not raise_error' do76 expect { subject.viewing_my_topic? }.to_not raise_error77 end78 it 'is falsey' do79 expect(subject.viewing_my_topic?).to be_falsey80 end81 end82 describe 'my_replies' do83 #84 it 'does not raise_error' do85 expect { subject.my_replies }.to_not raise_error86 end87 it 'is empty' do88 expect(subject.my_replies).to be_empty89 end90 end91 describe 'replies_to_me' do92 #93 it 'does not raise_error' do94 expect { subject.replies_to_me }.to_not raise_error95 end96 it 'is empty' do97 expect(subject.replies_to_me).to be_empty98 end99 end100 describe '(protected methods)' do101 describe 'topic_page_selector' do102 #103 it 'is a Hash' do104 expect(subject.send(:topic_page_selector)).to be_a Hash105 end106 end107 describe 'topics_links_selector' do108 #109 it 'is a Hash' do110 expect(subject.send(:topics_links_selector)).to be_a Hash111 end112 end113 describe 'my_topic_selector' do114 #115 it 'is a Hash' do116 expect(subject.send(:my_topic_selector)).to be_a Hash117 end118 end119 describe 'my_replies_selector' do120 #121 it 'is a Hash' do122 expect(subject.send(:my_replies_selector)).to be_a Hash123 end124 it 'has a fixture' do125 expect(subject.send(:my_replies_selector)).to be_present126 end127 end128 describe 'replies_to_me_selector' do129 #130 it 'is a Hash' do131 expect(subject.send(:replies_to_me_selector)).to be_a Hash132 end133 it 'has a fixture' do134 expect(subject.send(:replies_to_me_selector)).to be_present135 end136 end137 describe 'locked_topic_selector' do138 #139 it 'is a Hash' do140 expect(subject.send(:locked_topic_selector)).to be_a Hash141 end142 it 'has a fixture' do143 expect(subject.send(:locked_topic_selector)).to be_present144 end145 end146 end147 context 'with empty selectors' do148 before do149 allow_any_instance_of(Fora).to receive(:dom_selectors).and_return({})150 end151 describe '#viewing_a_topic?' do152 #153 it 'does not raise_error' do154 expect { subject.viewing_a_topic? }.to_not raise_error155 end156 it 'is falsey' do157 expect(subject.viewing_a_topic?).to be_falsey158 end159 end160 describe 'topic_is_locked?' do161 #162 it 'does not raise_error' do163 expect { subject.topic_is_locked? }.to_not raise_error164 end165 it 'is truthy' do166 expect(subject.topic_is_locked?).to be_truthy167 end168 context '(and viewing a topic is true)' do169 before do170 expect(subject).to receive(:viewing_a_topic?).171 at_least(:once).172 and_return(true)173 end174 it 'is falsey' do175 expect(subject.topic_is_locked?).to be_falsey176 end177 end178 end179 describe 'viewing_my_topic?' do180 #181 it 'does not raise_error' do182 expect { subject.viewing_my_topic? }.to_not raise_error183 end184 it 'is falsey' do185 expect(subject.viewing_my_topic?).to be_falsey186 end187 end188 describe 'my_replies' do189 #190 it 'does not raise_error' do191 expect { subject.my_replies }.to_not raise_error192 end193 it 'is empty' do194 expect(subject.my_replies).to be_empty195 end196 end197 describe 'replies_to_me' do198 #199 it 'does not raise_error' do200 expect { subject.replies_to_me }.to_not raise_error201 end202 it 'is empty' do203 expect(subject.replies_to_me).to be_empty204 end205 end206 describe '(protected methods)' do207 describe 'topic_page_selector' do208 #209 it 'has safe defaults' do210 expect(subject.send(:topic_page_selector)).to be_blank211 end212 end213 describe 'topics_links_selector' do214 #215 it 'has safe defaults' do216 expect(subject.send(:topics_links_selector)).to be_blank217 end218 end219 describe 'my_topic_selector' do220 #221 it 'has safe defaults' do222 expect(subject.send(:my_topic_selector)).to be_blank223 end224 end225 describe 'my_replies_selector' do226 #227 it 'has safe defaults' do228 expect(subject.send(:my_replies_selector)).to be_blank229 end230 end231 describe 'replies_to_me_selector' do232 #233 it 'has safe defaults' do234 expect(subject.send(:replies_to_me_selector)).to be_blank235 end236 end237 describe 'locked_topic_selector' do238 #239 it 'has safe defaults' do240 expect(subject.send(:locked_topic_selector)).to be_blank241 end242 end243 end244 end245 describe '(private methods)' do246 describe '#call_driver_finder' do247 it 'raises error when the argument does not respond to fetch' do248 expect do249 subject.send(:call_driver_finder, '')250 end.to raise_error251 end252 it 'raises error when :returns is unexpected' do253 expect do254 subject.send(:call_driver_finder, dom_selector.merge(returns: :hamburger))...
mora_spec.rb
Source:mora_spec.rb
...26 let(:root_html_file) { File.join(minibbs_fixtures_dir, 'index.html') }27 let(:reply_by_me_html_file) { File.join(minibbs_fixtures_dir, 'reply_by_me.html') }28 let(:reply_to_me_html_file) { File.join(minibbs_fixtures_dir, 'reply_to_me.html') }29 let(:topic_html_file) { File.join(minibbs_fixtures_dir, 'topic.html') }30 let(:topic_locked_html_file) { File.join(minibbs_fixtures_dir, 'topic_locked.html') }31 let(:topic_mine_html_file) { File.join(minibbs_fixtures_dir, 'topic_mine.html') }32 let(:topic_posting_html_file) { File.join(minibbs_fixtures_dir, 'topic_posting.html') }33 describe '[instance]' do34 context 'with valid options' do35 let(:fora) { Fora.new valid_options }36 subject { Mora.new fora: fora }37 it 'successfully initializes' do38 expect { subject }.to_not raise_error39 end40 context 'with HTML fixtures' do41 before do42 # modify the method's return values to be local paths43 expect(subject.fora).to receive(:url_for).at_least(:once) do |args|44 # puts args.inspect45 "file://#{args[:path]}"46 end47 end48 it 'loads the correct fixture' do49 expect(@selenium).to receive(:get).with("file://#{root_html_file}").and_call_original50 subject.fora.visit root_html_file51 end52 context 'at the root page' do53 before do54 subject.fora.visit root_html_file55 end56 describe '#read_this_page' do57 it 'is true' do58 expect(subject.read_this_page).to eq true59 end60 it 'does not call #check_my_replies' do61 expect(subject).to_not receive(:check_my_replies)62 subject.read_this_page63 end64 end65 end66 context 'at a topic page' do67 before do68 subject.fora.visit topic_html_file69 end70 describe '#read_this_page' do71 it 'is true' do72 expect(subject.read_this_page).to eq true73 end74 it 'calls #check_my_replies' do75 expect(subject).to receive(:check_my_replies)76 subject.read_this_page77 end78 end79 end80 context 'at a locked topic page' do81 before do82 subject.fora.visit topic_locked_html_file83 end84 describe '#read_this_page' do85 it 'is true' do86 expect(subject.read_this_page).to eq true87 end88 it 'does not call #check_my_replies' do89 expect(subject).to_not receive(:check_my_replies)90 subject.read_this_page91 end92 end93 end94 context 'at my topic page' do95 before do96 subject.fora.visit topic_mine_html_file...
socket_lock.rb
Source:socket_lock.rb
...8 def initialize(port, timeout)9 @port = port10 @timeout = timeout11 end12 def locked(&blk)13 lock14 begin15 yield16 ensure17 release18 end19 end20 private21 def lock22 max_time = Time.now + @timeout23 until can_lock? || Time.now >= max_time24 sleep 0.125 end26 unless did_lock?...
locked
Using AI Code Generation
1element = driver.find_element(:name, 'q')2wait = Selenium::WebDriver::Wait.new(:timeout => 10)3element = wait.until { driver.find_element(:name, 'q') }4The problem is that Ruby 2.0.0 (and 2.1.0) implements a new feature called keyword arguments. This feature allows you to pass arguments to a method using a hash, where the keys of the hash are the names of the arguments. For example:5def foo(bar, baz)6foo(baz: 'baz', bar: 'bar')7def foo(bar, baz = {})8foo(baz: 'baz', bar: 'bar')9{:baz=>"baz"}10def foo(bar, baz)11foo(bar: 'bar', baz: 'baz')12{:baz=>"baz"}
locked
Using AI Code Generation
1driver.find_element(:name, 'q').send_keys "Hello World"2driver.find_element(:name, 'btnK').click3driver.find_element(:name, 'q').send_keys "Hello World"4driver.find_element(:name, 'btnK').click5driver.find_element(:name, 'q').send_keys "Hello World"6driver.find_element(:name, 'btnK').click7driver.find_element(:name, 'q').send_keys "Hello World"8driver.find_element(:name, 'btnK').click9driver.find_element(:name, 'q').send_keys "Hello World"10driver.find_element(:name, 'btnK').click11driver.find_element(:name, 'q').send_keys "Hello World"12driver.find_element(:name, 'btnK').click13driver.find_element(:name, 'q').send_keys "Hello World"14driver.find_element(:name, 'btnK').click
locked
Using AI Code Generation
1driver.find_element(:id, "gbqfq").send_keys "Selenium"2driver.find_element(:id, "gbqfb").click3driver.find_element(:id, "gbqfq").send_keys "Selenium"4driver.find_element(:id, "gbqfb").click5driver.find_element(:id, "gbqfq").send_keys "Selenium"6driver.find_element(:id, "gbqfb").click7driver.find_element(:id, "gbqfq").send_keys "Selenium"8driver.find_element(:id, "gbqfb").click9driver.find_element(:id, "gbqfq").send_keys "Selenium"10driver.find_element(:id, "gbqfb").click11driver.find_element(:id, "gbqfq").send_keys "Selenium"12driver.find_element(:id, "gbqfb").click13driver.find_element(:id,
locked
Using AI Code Generation
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").click7driver.find_element(:name, "q").send_keys "Selenium WebDriver"8driver.find_element(:name, "btnG").click9driver.find_element(:name, "q").send_keys "Selenium WebDriver"10driver.find_element(:name, "btnG").click11driver.find_element(:name, "q").send_keys "Selenium WebDriver"12driver.find_element(:name, "btnG").click
locked
Using AI Code Generation
1search_box = driver.find_element(name: 'q')2driver.find_element(css: 'h3.r a').click3wait = Selenium::WebDriver::Wait.new(timeout: 10)4wait.until { driver.title.downcase.start_with? 'selenium' }5search_box = driver.find_element(name: 'q')6driver.find_element(css: 'h3.r a').click7wait = Selenium::WebDriver::Wait.new(timeout: 10)8wait.until { driver.title.downcase.start_with? 'selenium' }9search_box = driver.find_element(name: 'q')10driver.find_element(css: 'h3.r a').click11wait = Selenium::WebDriver::Wait.new(timeout: 10)12wait.until { driver.title.downcase.start_with? 'selenium' }
locked
Using AI Code Generation
1caps['phantomjs.page.settings.userAgent'] = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1309.0 Safari/537.17'2driver.find_element(:name, 'q').send_keys "Hello WebDriver!"3driver.find_element(:name, 'btnG').click
locked
Using AI Code Generation
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").click7driver.find_element(:name, "q").send_keys "Selenium WebDriver"8driver.find_element(:name, "btnG").click9driver.find_element(:name, "q").send_keys "Selenium WebDriver"10driver.find_element(:name, "btnG").click
locked
Using AI Code Generation
1caps['phantomjs.page.settings.userAgent'] = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1309.0 Safari/537.17'2driver.find_element(:name, 'q').send_keys "Hello WebDriver!"3driver.find_element(:name, 'btnG').click
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!