Best Capybara code snippet using Capybara.Driver.obscured
node_spec.rb
Source:node_spec.rb
...221 expect(html_page).to have_no_css(descendants_css, visible: :visible)222 .and(have_css(descendants_css, visible: :hidden, count: 3))223 end224 end225 describe '#obscured?', driver: :chrome_headless do226 it 'should see non visible elements as obscured' do227 Capybara.ignore_hidden_elements = false228 html_page.find(:xpath, '//div[@id="hidden"]').should.be_obscured229 html_page.find(:xpath, '//div[@id="hidden_via_ancestor"]').should.be_obscured230 html_page.find(:xpath, '//div[@id="hidden_attr"]').should.be_obscured231 html_page.find(:xpath, '//a[@id="hidden_attr_via_ancestor"]').should.be_obscured232 html_page.find(:xpath, '//input[@id="hidden_input"]').should.be_obscured233 end234 it 'should see non-overlapped elements as not obscured' do235 visit('/obscured')236 html_page.find('#cover').should_not.be_obscured237 end238 it 'should see elements only overlapped by descendants as not obscured' do239 html_page.first('p:not(.para)').should_not.be_obscured240 end241 it 'should see elements outside the viewport as obscured' do242 visit('/obscured')243 off = html_page.find('#offscreen')244 off_wrapper = html_page.find('#offscreen_wrapper')245 expect(off).to be_obscured246 expect(off_wrapper).to be_obscured247 html_page.scroll_to(off_wrapper)248 expect(off_wrapper).not_to be_obscured249 expect(off).to be_obscured250 off_wrapper.scroll_to(off)251 expect(off).not_to be_obscured252 expect(off_wrapper).not_to be_obscured253 end254 it 'should see overlapped elements as obscured' do255 visit('/obscured')256 html_page.find('#obscured').should.be_obscured257 end258 it 'should work in frames' do259 visit('/obscured')260 html_page.within_frame('frameOne') do261 div = html_page.find('#divInFrameOne').should.be_obscured262 html_page.scroll_to(div)263 div.should_no_longer.be_obscured264 end265 end266 it 'should work in nested iframes' do267 visit('/obscured')268 html_page.within_frame('nestedFrames') do269 html_page.within_frame(:css, '#childFrame') do270 gcframe = html_page.find('#grandchildFrame2')271 html_page.within_frame(gcframe.to_capybara_node) do272 html_page.find('#divInFrameTwo').should.be_obscured273 end274 html_page.scroll_to(gcframe)275 html_page.within_frame(gcframe.to_capybara_node) do276 html_page.find('#divInFrameTwo').should_not.be_obscured277 expect { html_page.find('#divInFrameTwo').should.be_obscured }278 .to raise_error(RSpec::Expectations::ExpectationNotMetError, /expected #<Capybara::Node::Element tag="div" .*> to be obscured/)279 end280 end281 end282 end283 end284 describe '#checked?' do285 it 'should extract node checked state' do286 form_page.visit_page287 form_page.find(:xpath, '//input[@id="gender_female"]').should.be_checked288 form_page.find(:xpath, '//input[@id="gender_male"]').should_not.be_checked289 form_page.first(:xpath, '//h1').should_not.be_checked290 expect { form_page.first(:xpath, '//h1').should.be_checked }.to raise_error(RSpec::Expectations::ExpectationNotMetError)291 end292 end293 describe '#selected?' do294 it 'should extract node selected state' do295 form_page.visit_page296 form_page.find(:xpath, '//option[@value="en"]').should.be_selected297 form_page.find(:xpath, '//option[@value="sv"]').should_not.be_selected298 form_page.first(:xpath, '//h1').should_not.be_selected299 expect { form_page.first(:xpath, '//h1').should.be_selected }.to raise_error(RSpec::Expectations::ExpectationNotMetError)300 end301 end302 describe '#==' do303 it 'preserve object identity' do304 expect(html_page.find(:xpath, '//h1') == html_page.find(:xpath, '//h1')).to be true305 expect(html_page.find(:xpath, '//h1') == html_page.find(:xpath, '//h1').to_capybara_node).to be true306 expect(html_page.find(:xpath, '//h1') === html_page.find(:xpath, '//h1')).to be true # rubocop:disable Style/CaseEquality307 expect(html_page.find(:xpath, '//h1').eql?(html_page.find(:xpath, '//h1'))).to be false308 end309 it 'returns false for unrelated object' do310 expect(html_page.find(:xpath, '//h1') == 'Not Capybara::Node::Base').to be false311 expect(html_page.find(:xpath, '//h1') == html_page.find(:xpath, '//h2', match: :first)).to be false312 end313 end314 describe '#path' do315 # Testing for specific XPaths here doesn't make sense since there316 # are many that can refer to the same element317 before do318 visit('/path')319 end320 it 'returns xpath which points to itself' do321 element = html_page.find(:link, 'Second Link')322 expect(html_page.find(:xpath, element.path)).to eq(element)323 end324 end325 describe '#drag_to', driver: :chrome_headless do326 it 'should drag and drop an object' do327 js_page.visit_page328 element = js_page.find(:xpath, '//div[@id="drag"]')329 target = js_page.find(:xpath, '//div[@id="drop"]')330 element.drag_to(target)331 js_page.should.have_dropped_element332 end333 it 'should drag and drop if scrolling is needed' do334 js_page.visit_page335 element = js_page.find(:xpath, '//div[@id="drag_scroll"]')336 target = js_page.find(:xpath, '//div[@id="drop_scroll"]')337 element.drag_to(target)338 js_page.should.have_dropped_element339 end340 it 'should drag a link' do341 js_page.visit_page342 link = js_page.find_link('drag_link')343 target = js_page.find(:id, 'drop')344 link.drag_to target345 js_page.should.have_dropped_element346 end347 it 'should work with Dragula' do348 visit('/with_dragula')349 js_page.within('#sortable.ready') do350 src = js_page.find('div', text: 'Item 1')351 target = js_page.find('div', text: 'Item 3')352 src.drag_to target353 html_page.should.have_content(/Item 2.*Item 1/, normalize_ws: true)354 end355 end356 it 'should work with jsTree' do357 visit('/with_jstree')358 js_page.within('#container') do359 js_page.assert_text(/A.*B.*C/m)360 source = js_page.find('#j1_1_anchor')361 target = js_page.find('#j1_2_anchor')362 source.drag_to(target)363 js_page.assert_no_text(/A.*B.*C/m)364 js_page.assert_text(/B.*C/m)365 end366 end367 it 'should simulate a single held down modifier key' do368 %I[369 alt370 ctrl371 meta372 shift373 ].each do |modifier_key|374 js_page.visit_page375 element = js_page.find(:xpath, '//div[@id="drag"]')376 target = js_page.find(:xpath, '//div[@id="drop"]')377 element.drag_to(target, drop_modifiers: modifier_key)378 js_page.should.have_css('div.drag_start', exact_text: 'Dragged!')379 js_page.should.have_dropped_element(modifier_key)380 end381 end382 it 'should simulate multiple held down modifier keys' do383 js_page.visit_page384 element = js_page.find(:xpath, '//div[@id="drag"]')385 target = js_page.find(:xpath, '//div[@id="drop"]')386 modifier_keys = %I[alt ctrl meta shift]387 element.drag_to(target, drop_modifiers: modifier_keys)388 js_page.should.have_dropped_element(*modifier_keys)389 end390 it 'should support key aliases' do391 { control: :ctrl,392 command: :meta,393 cmd: :meta }.each do |(key_alias, key)|394 js_page.visit_page395 element = js_page.find(:xpath, '//div[@id="drag"]')396 target = js_page.find(:xpath, '//div[@id="drop"]')397 element.drag_to(target, drop_modifiers: [key_alias])398 target.should.have_text("Dropped!-#{ key }", exact: true)399 end400 end401 context 'HTML5', driver: :chrome_headless do402 it 'should HTML5 drag and drop an object' do403 js_page.visit_page404 element = js_page.find(:xpath, '//div[@id="drag_html5"]')405 target = js_page.find(:xpath, '//div[@id="drop_html5"]')406 element.drag_to(target)407 expect(js_page).to have_xpath('//div[contains(., "HTML5 Dropped string: text/plain drag_html5")]')408 end409 it 'should HTML5 drag and drop an object child' do410 js_page.visit_page411 element = js_page.find(:xpath, '//div[@id="drag_html5"]/p')412 target = js_page.find(:xpath, '//div[@id="drop_html5"]')413 element.drag_to(target)414 expect(js_page).to have_xpath('//div[contains(., "HTML5 Dropped string: text/plain drag_html5")]')415 end416 it 'should set clientX/Y in dragover events' do417 js_page.visit_page418 element = js_page.find(:xpath, '//div[@id="drag_html5"]')419 target = js_page.find(:xpath, '//div[@id="drop_html5"]')420 element.drag_to(target)421 js_page.should.have_css('div.log', text: /DragOver with client position: [1-9]\d*,[1-9]\d*/, count: 2)422 end423 it 'should preserve clientX/Y from last dragover event' do424 js_page.visit_page425 element = js_page.find(:xpath, '//div[@id="drag_html5"]')426 target = js_page.find(:xpath, '//div[@id="drop_html5"]')427 element.drag_to(target)428 conditions = %w[DragLeave Drop DragEnd].map do |text|429 have_css('div.log', text: text)430 end431 expect(js_page).to(conditions.reduce { |memo, cond| memo.and(cond) })432 # The first "DragOver" div is inserted by the last dragover event dispatched433 drag_over_div = js_page.first(:xpath, '//div[@class="log" and starts-with(text(), "DragOver")]')434 position = drag_over_div.text.sub('DragOver ', '')435 js_page.should.have_css('div.log', text: /DragLeave #{ position }/, count: 1)436 js_page.should.have_css('div.log', text: /Drop #{ position }/, count: 1)437 js_page.should.have_css('div.log', text: /DragEnd #{ position }/, count: 1)438 end439 it 'should not HTML5 drag and drop on a non HTML5 drop element' do440 js_page.visit_page441 element = js_page.find(:xpath, '//div[@id="drag_html5"]')442 target = js_page.find(:xpath, '//div[@id="drop_html5"]')443 target.execute_script("$(this).removeClass('drop');")444 element.drag_to(target)445 sleep 1446 expect(js_page).not_to have_xpath('//div[contains(., "HTML5 Dropped")]')447 end448 it 'should HTML5 drag and drop when scrolling needed' do449 js_page.visit_page450 element = js_page.find(:xpath, '//div[@id="drag_html5_scroll"]')451 target = js_page.find(:xpath, '//div[@id="drop_html5_scroll"]')452 element.drag_to(target)453 expect(js_page).to have_xpath('//div[contains(., "HTML5 Dropped string: text/plain drag_html5_scroll")]')454 end455 it 'should drag HTML5 default draggable elements' do456 js_page.visit_page457 link = js_page.find_link('drag_link_html5')458 target = js_page.find(:id, 'drop_html5')459 link.drag_to target460 expect(js_page).to have_xpath('//div[contains(., "HTML5 Dropped")]')461 end462 it 'should drag HTML5 default draggable element child' do463 js_page.visit_page464 source = js_page.find_link('drag_link_html5').find('p')465 target = js_page.find(:id, 'drop_html5')466 source.drag_to target467 expect(js_page).to have_xpath('//div[contains(., "HTML5 Dropped")]')468 end469 it 'should simulate a single held down modifier key' do470 %I[alt ctrl meta shift].each do |modifier_key|471 js_page.visit_page472 element = js_page.find(:xpath, '//div[@id="drag_html5"]')473 target = js_page.find(:xpath, '//div[@id="drop_html5"]')474 element.drag_to(target, drop_modifiers: modifier_key)475 js_page.should.have_css('div.drag_start', exact_text: 'HTML5 Dragged!')476 expect(js_page).to have_xpath("//div[contains(., 'HTML5 Dropped string: text/plain drag_html5-#{ modifier_key }')]")477 end478 end479 it 'should simulate multiple held down modifier keys' do480 js_page.visit_page481 element = js_page.find(:xpath, '//div[@id="drag_html5"]')482 target = js_page.find(:xpath, '//div[@id="drop_html5"]')483 modifier_keys = %I[alt ctrl meta shift]484 element.drag_to(target, drop_modifiers: modifier_keys)485 expect(js_page).to have_xpath("//div[contains(., 'HTML5 Dropped string: text/plain drag_html5-#{ modifier_keys.join('-') }')]")486 end487 it 'should support key aliases' do488 { control: :ctrl,489 command: :meta,490 cmd: :meta }.each do |(key_alias, key)|491 js_page.visit_page492 element = js_page.find(:xpath, '//div[@id="drag_html5"]')493 target = js_page.find(:xpath, '//div[@id="drop_html5"]')494 element.drag_to(target, drop_modifiers: [key_alias])495 target.should.have_text(%r{^HTML5 Dropped string: text/plain drag_html5-#{ key }$}m, exact: true)496 end497 end498 end499 end500 describe 'Element#drop', driver: :chrome_headless do501 it 'can drop a file' do502 js_page.visit_page503 js_page.drop_target504 .drop_file('capybara.jpg')505 .should.have_dropped('file: capybara.jpg')506 end507 it 'can drop multiple files' do508 js_page.visit_page509 js_page.drop_target510 .drop_file('capybara.jpg', 'test_file.txt')511 .should.have_dropped('file: capybara.jpg')512 .should.have_dropped('file: test_file.txt')513 end514 it 'can drop strings' do515 js_page.visit_page516 js_page.drop_target517 .drop('text/plain' => 'Some dropped text')518 .should.have_dropped('string: text/plain Some dropped text')519 end520 it 'can drop multiple strings' do521 js_page.visit_page522 js_page.drop_target523 .drop('text/plain' => 'Some dropped text', 'text/url' => 'http://www.google.com')524 .should.have_dropped('string: text/plain Some dropped text')525 .should.have_dropped('string: text/url http://www.google.com')526 end527 end528 describe '#hover', driver: :chrome_headless do529 it 'should allow hovering on an element' do530 visit('/with_hover')531 revealed_on_hover = js_page.find('.wrapper:not(.scroll_needed) .hidden_until_hover', visible: false)532 revealed_on_hover.should_not.be_visible533 js_page.find('.wrapper:not(.scroll_needed)').hover534 revealed_on_hover.should_now.be_visible535 end536 it 'should allow hovering on an element that needs to be scrolled into view' do537 visit('/with_hover')538 revealed_on_hover = js_page.find('.wrapper.scroll_needed .hidden_until_hover', visible: false)539 revealed_on_hover.should_not.be_visible540 js_page.find('.wrapper.scroll_needed').hover541 revealed_on_hover.should_now.be_visible542 end543 it 'should hover again after following a link and back' do544 visit('/with_hover')545 js_page.find('.wrapper:not(.scroll_needed)').hover546 js_page.click_link('Other hover page')547 js_page.click_link('Go back')548 js_page.find('.wrapper:not(.scroll_needed)').hover549 .find('.hidden_until_hover', visible: false).should.be_visible550 end551 end552 describe '#click' do553 it 'should not follow a link if no href' do554 html_page.find('#link_placeholder').click555 expect(html_page.current_url).to match(%r{/with_html$})556 end557 it 'should go to the same page if href is blank' do558 html_page.find('#link_blank_href').click559 sleep 1560 expect(html_page).to have_current_path('/with_html')561 end562 it 'should be able to check a checkbox' do563 form_page.visit_page564 form_page.find(:checkbox, 'form_terms_of_use')565 .should_not.be_checked566 .click567 .should.be_checked568 end569 it 'should be able to uncheck a checkbox' do570 form_page.visit_page571 form_page.find(:checkbox, 'form_pets_dog')572 .should.be_checked573 .click574 .should_not.be_checked575 end576 it 'should be able to select a radio button' do577 form_page.visit_page578 form_page.find(:radio_button, 'gender_male')579 .should_not.be_checked580 .click581 .should.be_checked582 end583 it 'should allow modifiers', driver: :chrome_headless do584 js_page.visit_page585 html_page.find('#click-test').click(:shift)586 expect(html_page).to have_link('Has been shift clicked')587 end588 it 'should allow multiple modifiers', driver: :chrome_headless do589 js_page.visit_page590 html_page.find('#click-test').click(:control, :alt, :meta, :shift)591 # Selenium with Chrome on OSX ctrl-click generates a right click so just verify all keys but not click type592 expect(html_page).to have_link('alt control meta shift')593 end594 it 'should allow to adjust the click offset', driver: :chrome_headless do595 js_page.visit_page596 html_page.find('#click-test').click(x: 5, y: 5)597 link = html_page.find(:link, 'has-been-clicked')598 locations = link.text.match(/^Has been clicked at (?<x>[\d.-]+),(?<y>[\d.-]+)$/)599 # Resulting click location should be very close to 0, 0 relative to top left corner of the element, but may not be exact due to600 # integer/float conversions and rounding.601 expect(locations[:x].to_f).to be_within(1).of(5)602 expect(locations[:y].to_f).to be_within(1).of(5)603 end604 it 'should raise error if both x and y values are not passed' do605 js_page.visit_page606 el = html_page.find('#click-test')607 expect { el.click(x: 5) }.to raise_error ArgumentError608 expect { el.click(x: nil, y: 3) }.to raise_error ArgumentError609 end610 it 'should be able to click a table row', driver: :chrome_headless do611 visit('/tables')612 html_page.find('#agent_table tr:first-child').click613 .should.have_css('label', text: 'Clicked')614 end615 it 'should retry clicking', driver: :chrome_headless do616 visit('/animated')617 obscured = html_page.find('#obscured')618 html_page.execute_script("setTimeout(function(){ $('#cover').hide(); }, 700)")619 expect { obscured.click }.not_to raise_error620 end621 it 'should allow to retry longer', driver: :chrome_headless do622 visit('/animated')623 obscured = html_page.find('#obscured')624 html_page.execute_script("setTimeout(function(){ $('#cover').hide(); }, 3000)")625 expect { obscured.click(wait: 4) }.not_to raise_error626 end627 it 'should not retry clicking when wait is disabled', driver: :chrome_headless do628 visit('/animated')629 obscured = html_page.find('#obscured')630 html_page.execute_script("setTimeout(function(){ $('#cover').hide(); }, 2000)")631 expect { obscured.click(wait: 0) }.to(raise_error { |e| expect(e).to be_an_invalid_element_error })632 end633 context 'offset', driver: :chrome_headless do634 before do635 visit('/offset')636 end637 let :clicker do638 html_page.find(:id, 'clicker')639 end640 context 'when w3c_click_offset is false' do641 before do642 Capybara.w3c_click_offset = false643 end644 it 'should offset from top left of element' do645 clicker.click(x: 10, y: 5)646 html_page.should.have_text(/clicked at 110,105/)647 end648 it 'should offset outside the element' do649 clicker.click(x: -15, y: -10)650 html_page.should.have_text(/clicked at 85,90/)651 end652 it 'should default to click the middle' do653 clicker.click654 html_page.should.have_text(/clicked at 150,150/)655 end656 end657 context 'when w3c_click_offset is true' do658 before do659 Capybara.w3c_click_offset = true660 end661 it 'should offset from center of element' do662 clicker.click(x: 10, y: 5)663 html_page.should.have_text(/clicked at 160,155/)664 end665 it 'should offset outside from center of element' do666 clicker.click(x: -65, y: -60)667 html_page.should.have_text(/clicked at 85,90/)668 end669 it 'should default to click the middle' do670 clicker.click671 html_page.should.have_text(/clicked at 150,150/)672 end673 end674 end675 context 'delay', driver: :chrome_headless do676 it 'should delay the mouse up' do677 js_page.visit_page678 html_page.find('#click-test').click(delay: 2)679 delay = html_page.evaluate_script('window.click_delay')680 expect(delay).to be >= 2681 end682 end683 end684 describe '#double_click', driver: :chrome_headless do685 it 'should double click an element' do686 js_page.visit_page687 html_page.find('#click-test').double_click688 html_page.should.have_css('#has-been-double-clicked')689 end690 it 'should allow modifiers', driver: :chrome_headless do691 js_page.visit_page692 html_page.find('#click-test').double_click(:alt)693 expect(html_page).to have_link('Has been alt double clicked')694 end695 it 'should allow to adjust the offset', driver: :chrome_headless do696 js_page.visit_page697 html_page.find('#click-test').double_click(x: 10, y: 5)698 link = html_page.find(:link, 'has-been-double-clicked')699 locations = link.text.match(/^Has been double clicked at (?<x>[\d.-]+),(?<y>[\d.-]+)$/)700 # Resulting click location should be very close to 10, 5 relative to top left corner of the element, but may not be exact due701 # to integer/float conversions and rounding.702 expect(locations[:x].to_f).to be_within(1).of(10)703 expect(locations[:y].to_f).to be_within(1).of(5)704 end705 it 'should retry clicking', driver: :chrome_headless do706 visit('/animated')707 obscured = html_page.find('#obscured')708 html_page.execute_script("setTimeout(function(){ $('#cover').hide(); }, 700)")709 expect { obscured.double_click }.not_to raise_error710 end711 context 'offset', driver: :chrome_headless do712 before do713 visit('/offset')714 end715 let :clicker do716 html_page.find(:id, 'clicker')717 end718 context 'when w3c_click_offset is false' do719 before do720 Capybara.w3c_click_offset = false721 end722 it 'should offset from top left of element' do723 clicker.double_click(x: 10, y: 5)724 html_page.should.have_text(/clicked at 110,105/)725 end726 it 'should offset outside the element' do727 clicker.double_click(x: -15, y: -10)728 html_page.should.have_text(/clicked at 85,90/)729 end730 it 'should default to click the middle' do731 clicker.double_click732 html_page.should.have_text(/clicked at 150,150/)733 end734 end735 context 'when w3c_click_offset is true' do736 before do737 Capybara.w3c_click_offset = true738 end739 it 'should offset from center of element' do740 clicker.double_click(x: 10, y: 5)741 html_page.should.have_text(/clicked at 160,155/)742 end743 it 'should offset outside from center of element' do744 clicker.double_click(x: -65, y: -60)745 html_page.should.have_text(/clicked at 85,90/)746 end747 it 'should default to click the middle' do748 clicker.double_click749 html_page.should.have_text(/clicked at 150,150/)750 end751 end752 end753 end754 describe '#right_click', driver: :chrome_headless do755 it 'should right click an element' do756 js_page.visit_page757 html_page.find('#click-test').right_click758 html_page.should.have_css('#has-been-right-clicked')759 end760 it 'should allow modifiers', driver: :chrome_headless do761 js_page.visit_page762 html_page.find('#click-test').right_click(:meta)763 expect(html_page).to have_link('Has been meta right clicked')764 end765 it 'should allow to adjust the offset', driver: :chrome_headless do766 js_page.visit_page767 html_page.find('#click-test').right_click(x: 10, y: 10)768 link = html_page.find(:link, 'has-been-right-clicked')769 locations = link.text.match(/^Has been right clicked at (?<x>[\d.-]+),(?<y>[\d.-]+)$/)770 # Resulting click location should be very close to 10, 10 relative to top left corner of the element, but may not be exact due771 # to integer/float conversions and rounding772 expect(locations[:x].to_f).to be_within(1).of(10)773 expect(locations[:y].to_f).to be_within(1).of(10)774 end775 it 'should retry clicking', driver: :chrome_headless do776 visit('/animated')777 obscured = html_page.find('#obscured')778 html_page.execute_script("setTimeout(function(){ $('#cover').hide(); }, 700)")779 expect { obscured.right_click }.not_to raise_error780 end781 context 'offset', driver: :chrome_headless do782 before do783 visit('/offset')784 end785 let :clicker do786 html_page.find(:id, 'clicker')787 end788 context 'when w3c_click_offset is false' do789 before do790 Capybara.w3c_click_offset = false791 end792 it 'should offset from top left of element' do793 clicker.right_click(x: 10, y: 5)...
all_spec.rb
Source:all_spec.rb
...108 Capybara.ignore_hidden_elements = false109 expect(html_page.all(:simple_link).size).to eq(2)110 end111 end112 context 'with obscured filter', driver: :chrome_headless do113 it 'should only find nodes on top in the viewport when false' do114 expect(html_page.all(:simple_link, obscured: false).size).to eq(1)115 end116 it 'should not find nodes on top outside the viewport when false' do117 expect(html_page.all(:link, 'Download Me', obscured: false).size).to eq(0)118 html_page.scroll_to(html_page.find_link('Download Me'))119 expect(html_page.all(:link, 'Download Me', obscured: false).size).to eq(1)120 end121 it 'should find top nodes outside the viewport when true' do122 expect(html_page.all(:link, 'Download Me', obscured: true).size).to eq(1)123 html_page.scroll_to(html_page.find_link('Download Me'))124 expect(html_page.all(:link, 'Download Me', obscured: true).size).to eq(0)125 end126 it 'should only find non-top nodes when true' do127 # Also need visible: false so visibility is ignored128 expect(html_page.all(:simple_link, visible: false, obscured: true).size).to eq(1)129 end130 end131 context 'with element count filters' do132 context ':count' do133 it 'should succeed when the number of elements founds matches the expectation' do134 expect { html_page.all(:title_or_paragraph, count: 4) }.not_to raise_error135 end136 it 'should raise ExpectationNotMet when the number of elements founds does not match the expectation' do137 expect { html_page.all(:title_or_paragraph, count: 5) }.to raise_error(Capybara::ExpectationNotMet)138 end139 end140 context ':minimum' do141 it 'should succeed when the number of elements founds matches the expectation' do142 expect { html_page.all(:title_or_paragraph, minimum: 0) }.not_to raise_error...
obscured
Using AI Code Generation
1 def initialize(app, options = {})2 @browser = Browser.new(options)3 @connection = Connection.new(@browser)4 @connection.on(:disconnected) { reset! }5 @connection.on(:error) { reset! }6 @connection.on(:response) { |response| @last_response = response }7 @connection.on(:request) { |request| @last_request = request }8 @connection.on(:render) { |image_data| @last_render = image_data }9 @connection.on(:console) { |message| @last_console_message = message }10 @connection.on(:alert) { |message| @last_alert_message = message }11 @connection.on(:confirm) { |message| @last_confirm_message = message }12 @connection.on(:prompt) { |message, default| @last_prompt_message = [message, default] }13 @connection.on(:error) { |message| @last_error_message = message }14 @connection.on(:timeout) { |message| @last_timeout_message = message }15 @connection.on(:navigation) { |message| @last_navigation_message = message }16 @connection.on(:frame_created) { |id| @last_frame_created = id }17 @connection.on(:frame_loaded) { |id| @last_frame_loaded = id }18 @connection.on(:frame_deleted) { |id| @last_frame_deleted = id }19 @connection.on(:new_window) { |url| @last_new_window = url }20 @connection.on(:status) { |message| @last_status_message = message }21 @connection.on(:title) { |message| @last_title_message = message }22 @connection.on(:url) { |message| @last
obscured
Using AI Code Generation
1 config.allow_url("www.google.com")2 config.allow_url("www.google.com")3 config.allow_url("www.google.com")4 config.allow_url("www.google.com")5 config.allow_url("www.google.com")6 config.allow_url("www.google.com")7 config.allow_url("www.yahoo.com")8 config.allow_url("www.google.com")9 config.allow_url("www.yahoo.com")10 config.allow_url("www.yahoo.com")11 config.allow_url("www.google.com")12 config.allow_url("www.yahoo.com")13 config.allow_url("www.yahoo.com")14 config.block_url("www.yahoo.com")15 config.allow_url("www.google.com")
obscured
Using AI Code Generation
1 @rack_mock_session.instance_variable_get(:@rack_mock_session).instance_variable_get(:@pool).instance_variable_get(:@session)2 def session_id=(id)3 @rack_mock_session = Rack::MockSession.new(Rack::Session::Pool, "
obscured
Using AI Code Generation
1visit('/')2doc = Nokogiri::HTML(html)3doc.css('a').each do |link|4doc.css('img').each do |image|
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!!