{"id":13921,"date":"2016-07-14T12:15:27","date_gmt":"2016-07-14T09:15:27","guid":{"rendered":"https:\/\/www.webcodegeeks.com\/?p=13921"},"modified":"2016-07-13T17:03:55","modified_gmt":"2016-07-13T14:03:55","slug":"capybara-selenium-testing-scraping","status":"publish","type":"post","link":"https:\/\/www.webcodegeeks.com\/web-development\/capybara-selenium-testing-scraping\/","title":{"rendered":"Capybara and Selenium for Testing and Scraping"},"content":{"rendered":"<p><a href=\"https:\/\/github.com\/jnicklas\/capybara\">Capybara<\/a>, aside from being <a href=\"https:\/\/en.wikipedia.org\/wiki\/Capybara\">the largest rodent in the world<\/a>, is also a fantastic tool to aid you in interacting with browser functionality in your code, either for testing or just to interact with or scrape data from a website.<\/p>\n<p>Capybara isn\u2019t what actually interacts with the website \u2014 rather, it\u2019s a layer that sits between you and the actual web driver. This could be Selenium, PhantomJS, or any of the other drivers that Capybara supports. It provides a common interface and a large number of helper methods for extracting information, inputting data, testing, or clicking around.<\/p>\n<p>Just like any abstraction, sometimes you need to go deeper, and Capybara won\u2019t stop you from doing that. You can easily bypass it to get at the underlying drivers if you need more fine-tuned functionality.<\/p>\n<h2>Testing with Capybara<\/h2>\n<p>Capybara integrates really nicely with all of the common test frameworks used with Rails. It has extensions for RSpec, Cucumber, Test::Unit, and Minitest. It\u2019s used mostly with integration (or feature) tests, which test not so much a single piece of functionality but rather an entire user flow.<\/p>\n<p>You can use Capybara to test whether certain content exists on the page or to input data into a form and then submit it. This is where you try to ensure that the same key flows (such as registration, checkout, etc.) that your user will take work not just in isolation but flow nicely from one to another.<\/p>\n<p>With RSpec, we need to first ensure that in our <code>rspec_helper.rb<\/code> file we include the line <code>require 'capybara\/rails'<\/code>. Next, let\u2019s create a new folder called <code>features<\/code> where we\u2019ll put all of the tests which include Capybara.<\/p>\n<p>Imagine that we have an application for managing coffee farms. In this application, creating a coffee farm is one of the most important functions you can perform, and therefore should be tested thoroughly.<\/p>\n<pre class=\"brush:php\"># spec\/features\/creating_farm_spec.rb\r\nrequire 'rails_helper'\r\n\r\nRSpec.describe 'creating a farm', type: :feature do\r\n  it 'successfully creates farm' do\r\n    visit '\/farms'\r\n    click_link 'New Farm'\r\n\r\n    within '#new_farm' do\r\n      fill_in 'Acres', with: 10\r\n      fill_in 'Name', with: 'Castillo Andino'\r\n      fill_in 'Owner', with: 'Albita'\r\n      fill_in 'Address', with: 'Andes, Colombia'\r\n      fill_in 'Varieties', with: 'Colombia, Geisha, Bourbon'\r\n      fill_in 'Rating', with: 10\r\n    end\r\n    click_button 'Create Farm'\r\n\r\n    expect(page).to have_content 'Farm was successfully created.'\r\n    expect(page).to have_content 'Castillo Andino'\r\n  end\r\nend<\/pre>\n<p>There are a few things to note with Capybara. The first is that it provides a ton of great helpers such as <code>click_link<\/code>, <code>fill_in<\/code>, <code>click_button<\/code>, etc. Many of these helpers provide a variety of ways to actually find the HTML element that you\u2019re looking for.<\/p>\n<p>In the example above, we see CSS selectors used with the <code>within<\/code> method. We also see selecting and filling in an <code>input<\/code> field by using the text in its <code>label<\/code>.<\/p>\n<p>There\u2019s also a third way, not shown here, which allows you to select elements using <code>xpath<\/code>. While <code>xpath<\/code> is the most powerful for selecting, it\u2019s the least clear way. For the purposes of your own sanity, you should probably aim to include an <code>ID<\/code> or <code>class<\/code> property in your HTML to ensure that selecting is straightforward.<\/p>\n<h2>Scraping with Capybara<\/h2>\n<p>Capybara isn\u2019t only for testing. It can also be used in web scraping. I\u2019ll admit that it isn\u2019t the fastest method, and if all you are doing is visiting a page to extract information without too much interaction with the DOM in terms of data input or clicking, it may not be the best approach. For that, you may want to investigate something like <a href=\"https:\/\/github.com\/sparklemotion\/mechanize\">mechanize<\/a> or even <a href=\"https:\/\/github.com\/sparklemotion\/nokogiri\">nokogiri<\/a> if all you are doing is reading HTML to extract information from it.<\/p>\n<p>But for the situation where you maybe have to first log in as a user, click on a tab, and then extract some information, this is the sweet spot for Capybara.<\/p>\n<p>I\u2019ve recently had to rent a car, and I ended up using <a href=\"https:\/\/www.hotwire.com\">Hotwire<\/a> for this. Let\u2019s use Capybara to log in and retrieve my confirmation number. In this case, it would be more difficult to use a different scraping tool because it is an Angular SPA, so Capybara works perfectly.<\/p>\n<p>I\u2019ll create a Rake task which will log in to my account and then loop through all of the confirmation codes and print them to the screen. I\u2019ve used an <code>xpath<\/code> selector here to show that even if there isn\u2019t an easy CSS selector to use, you can still find the element that you\u2019re looking for. This also demonstrates how to use Capybara outside of your testing environment.<\/p>\n<pre class=\"brush:php\">namespace :automate do\r\n  desc 'Grab hotwire confirmation code'\r\n  task hotwire: :environment do |t, args|\r\n    session = Capybara::Session.new(:selenium)\r\n    session.visit 'https:\/\/www.hotwire.com\/checkout\/#!\/account\/login'\r\n\r\n    session.find('#sign-in-email').set(ENV.fetch('EMAIL'))\r\n    session.find(:xpath, '\/\/input[@type=\"password\"]').set(ENV.fetch('PASSWORD'))\r\n    session.find('.hw-btn-primary').click\r\n\r\n    session.all('.confirmation-code').each do |code|\r\n      puts code.text\r\n    end\r\n  end\r\nend<\/pre>\n<p>On the screen, we get <code>Car confirmation 31233321CA3<\/code> outputted (not my real confirmation number, of course).<\/p>\n<p>Any time we use the <code>find<\/code> method or <code>all<\/code>, we are given an instance of the <code>Capybara::Node::Element<\/code> object. This object allows us to <code>click<\/code> it, extract the <code>text<\/code>, ask for its DOM <code>path<\/code>, and interact with it in a variety of other ways.<\/p>\n<p>One other interesting method is the <code>native<\/code> method, which returns us the underlying driver\u2019s object. In this case, it\u2019s an instance of <code>Selenium::WebDriver::Element<\/code> because we are using Selenium. As useful of an abstraction as Capybara is, there will always be times when you need to gain access to the underlying layer.<\/p>\n<p>As you can see, this could be an easy way to automate a task that has no other alternative than to use the \u201cScreen Scraping\u201d approach. Keep in mind that this is quite brittle, as a slight change to one of their classes or IDs means that the whole thing will stop working.<\/p>\n<h2>Interacting with JavaScript<\/h2>\n<p>One of the things that Capybara gives you is the ability to interact with your webpages using JavaScript. You aren\u2019t limited to only using Ruby to find and interact with the DOM nodes on your page.<\/p>\n<p>Capybara gives you two methods to invoke some JavaScript:<\/p>\n<ul>\n<li><code>execute_script<\/code> (does not return values)<\/li>\n<li><code>evaluate_script<\/code> (does return values)<\/li>\n<\/ul>\n<p>These work great, but as usual you can bypass Capybara if needed and use the underlying driver to execute JavaScript. This allows us to pass arguments to our JavaScript code:<\/p>\n<pre class=\"brush:php\"># example of returning values from javascript\r\nclasses = session.driver.browser.execute_script(\r\n  \"return document.getElementById(arguments[0]).className;\",\r\n  'sign-in-password'\r\n)\r\nputs classes\r\n# =&gt; ng-pristine ng-untouched ng-invalid ng-invalid-required<\/pre>\n<p>The <code>execute_script<\/code> method allows you to return values from JS functions which are called. If you imagine that your code is being invoked like this:<\/p>\n<pre class=\"brush:php\">var result =\r\n  (function(arguments) {\r\n    return document.getElementById(arguments[0]).className;\r\n  })(['sign-in-password']);<\/pre>\n<p>You\u2019ll see that the arguments you pass in the second and higher parameter positions get placed into an array and passed to an anonymous function. The anonymous function contains, as its body, the code which was in the first parameter. This is why you must explicitly include a <code>return<\/code> statement if you want to use the value it returns.<\/p>\n<p>Selenium takes care of how to convert what would end up being a JavaScript return value into something you can use in Ruby.<\/p>\n<h2>Configuring Capybara<\/h2>\n<p>As I mentioned in the introduction, Capybara works by allowing you to work with a number of different web drivers. These could be lightweight headless drivers such as <a href=\"http:\/\/phantomjs.org\/\">PhantomJS<\/a> (via <a href=\"https:\/\/github.com\/teampoltergeist\/poltergeist\">poltergeist<\/a>) or RackTest, but it could also be <a href=\"http:\/\/www.seleniumhq.org\/\">Selenium<\/a> either running locally or connecting to a Selenium grid server remotely.<\/p>\n<p>Here is an example of how you might configure Capybara to work with a remote Selenium server.<\/p>\n<pre class=\"brush:php\">Capybara.register_driver(:firefox) do |app|\r\n  Capybara::Selenium::Driver.new(\r\n    app,\r\n    browser: :remote,\r\n    url: ENV.fetch('SELENIUM_URL'),\r\n    desired_capabilities: Selenium::WebDriver::Remote::Capabilities.firefox\r\n  )\r\nend<\/pre>\n<p>Which would now allow you to set the driver to <code>:firefox<\/code> with the code <code>Capybara.default_driver = :firefox<\/code>.<\/p>\n<h2>Debugging Capybara<\/h2>\n<p>With a headless driver, it is sometimes hard to see what the page looks like at the time you are interacting with it. Just because it is headless doesn\u2019t mean you need to be blind. You are able to request a screenshot of how the page looks and also extract the source code of the page.<\/p>\n<pre class=\"brush:php\">File.open('\/tmp\/source.html', 'w') do |file|\r\n  io = StringIO.new(session.driver.browser.page_source)\r\n  file.write(io.read)\r\nend\r\n\r\nFile.open('\/tmp\/screenshot.png', 'w', encoding: 'ascii-8bit') do |file|\r\n  io = StringIO.new(session.driver.browser.screenshot_as(:png))\r\n  file.write(io.read)\r\nend<\/pre>\n<p>Another way to help with debugging is by placing a <code>binding.pry<\/code> call, which will pause the script and allow you to step into the code and perform commands that interact with the web page. You can even open up the Firefox\/Chrome developer console and play with the JavaScript of the page in its current state.<\/p>\n<h2>Conclusion<\/h2>\n<p>The truth is that I don\u2019t generally use Capybara when testing my Rails applications. It slows the tests down and potentially binds your tests quite closely to the DOM.<\/p>\n<p>However, it does have its place, especially when you need to guarantee that certain important user flows work exactly as expected. It also finds the odd use in scraping when tools such as <code>mechanize<\/code> or <code>nokogiri<\/code> aren\u2019t enough.<\/p>\n<p>Capybara is a great tool to have in your Ruby toolbelt. Give it a try the next time you want to make sure that a certain key user flow works or you need to automate a task via scraping.<\/p>\n<div class=\"attribution\">\n<table>\n<tbody>\n<tr>\n<td><span class=\"reference\">Reference: <\/span><\/td>\n<td><a href=\"https:\/\/blog.codeship.com\/capybara-selenium-testing\/\">Capybara and Selenium for Testing and Scraping<\/a> from our <a href=\"http:\/\/www.webcodegeeks.com\/join-us\/wcg\/\">WCG partner<\/a> Leigh Halliday at the <a href=\"http:\/\/blog.codeship.com\/\">Codeship Blog<\/a> blog.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Capybara, aside from being the largest rodent in the world, is also a fantastic tool to aid you in interacting with browser functionality in your code, either for testing or just to interact with or scrape data from a website. Capybara isn\u2019t what actually interacts with the website \u2014 rather, it\u2019s a layer that sits &hellip;<\/p>\n","protected":false},"author":113,"featured_media":927,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[380,339,121],"class_list":["post-13921","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-web-development","tag-capybara","tag-selenium","tag-testing"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Capybara and Selenium for Testing and Scraping - Web Code Geeks - 2026<\/title>\n<meta name=\"description\" content=\"Capybara, aside from being the largest rodent in the world, is also a fantastic tool to aid you in interacting with browser functionality in your code,\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.webcodegeeks.com\/web-development\/capybara-selenium-testing-scraping\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Capybara and Selenium for Testing and Scraping - Web Code Geeks - 2026\" \/>\n<meta property=\"og:description\" content=\"Capybara, aside from being the largest rodent in the world, is also a fantastic tool to aid you in interacting with browser functionality in your code,\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.webcodegeeks.com\/web-development\/capybara-selenium-testing-scraping\/\" \/>\n<meta property=\"og:site_name\" content=\"Web Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/webcodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2016-07-14T09:15:27+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/web-dev-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Leigh Halliday\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@leighchalliday\" \/>\n<meta name=\"twitter:site\" content=\"@webcodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Leigh Halliday\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"8 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.webcodegeeks.com\/web-development\/capybara-selenium-testing-scraping\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/web-development\/capybara-selenium-testing-scraping\/\"},\"author\":{\"name\":\"Leigh Halliday\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/e496b17f78cdca27723b8e225dc6ab6b\"},\"headline\":\"Capybara and Selenium for Testing and Scraping\",\"datePublished\":\"2016-07-14T09:15:27+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/web-development\/capybara-selenium-testing-scraping\/\"},\"wordCount\":1351,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/web-development\/capybara-selenium-testing-scraping\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/web-dev-logo.jpg\",\"keywords\":[\"Capybara\",\"Selenium\",\"Testing\"],\"articleSection\":[\"Web Dev\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.webcodegeeks.com\/web-development\/capybara-selenium-testing-scraping\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.webcodegeeks.com\/web-development\/capybara-selenium-testing-scraping\/\",\"url\":\"https:\/\/www.webcodegeeks.com\/web-development\/capybara-selenium-testing-scraping\/\",\"name\":\"Capybara and Selenium for Testing and Scraping - Web Code Geeks - 2026\",\"isPartOf\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/web-development\/capybara-selenium-testing-scraping\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/web-development\/capybara-selenium-testing-scraping\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/web-dev-logo.jpg\",\"datePublished\":\"2016-07-14T09:15:27+00:00\",\"description\":\"Capybara, aside from being the largest rodent in the world, is also a fantastic tool to aid you in interacting with browser functionality in your code,\",\"breadcrumb\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/web-development\/capybara-selenium-testing-scraping\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.webcodegeeks.com\/web-development\/capybara-selenium-testing-scraping\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/web-development\/capybara-selenium-testing-scraping\/#primaryimage\",\"url\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/web-dev-logo.jpg\",\"contentUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/web-dev-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.webcodegeeks.com\/web-development\/capybara-selenium-testing-scraping\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.webcodegeeks.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Web Dev\",\"item\":\"https:\/\/www.webcodegeeks.com\/category\/web-development\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Capybara and Selenium for Testing and Scraping\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#website\",\"url\":\"https:\/\/www.webcodegeeks.com\/\",\"name\":\"Web Code Geeks\",\"description\":\"Web Developers Resource Center\",\"publisher\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.webcodegeeks.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\/\/www.webcodegeeks.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"contentUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/webcodegeeks\",\"https:\/\/x.com\/webcodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/e496b17f78cdca27723b8e225dc6ab6b\",\"name\":\"Leigh Halliday\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/bd40251a1acc424c292c35a3485264a801efa20efa7063c3e320a0a354ddafac?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/bd40251a1acc424c292c35a3485264a801efa20efa7063c3e320a0a354ddafac?s=96&d=mm&r=g\",\"caption\":\"Leigh Halliday\"},\"description\":\"Leigh is a developer at theScore. He writes about Ruby, Rails, and software development on his personal site.\",\"sameAs\":[\"http:\/\/www.leighhalliday.com\/\",\"https:\/\/x.com\/leighchalliday\"],\"url\":\"https:\/\/www.webcodegeeks.com\/author\/leigh-halliday\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Capybara and Selenium for Testing and Scraping - Web Code Geeks - 2026","description":"Capybara, aside from being the largest rodent in the world, is also a fantastic tool to aid you in interacting with browser functionality in your code,","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.webcodegeeks.com\/web-development\/capybara-selenium-testing-scraping\/","og_locale":"en_US","og_type":"article","og_title":"Capybara and Selenium for Testing and Scraping - Web Code Geeks - 2026","og_description":"Capybara, aside from being the largest rodent in the world, is also a fantastic tool to aid you in interacting with browser functionality in your code,","og_url":"https:\/\/www.webcodegeeks.com\/web-development\/capybara-selenium-testing-scraping\/","og_site_name":"Web Code Geeks","article_publisher":"https:\/\/www.facebook.com\/webcodegeeks","article_published_time":"2016-07-14T09:15:27+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/web-dev-logo.jpg","type":"image\/jpeg"}],"author":"Leigh Halliday","twitter_card":"summary_large_image","twitter_creator":"@leighchalliday","twitter_site":"@webcodegeeks","twitter_misc":{"Written by":"Leigh Halliday","Est. reading time":"8 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.webcodegeeks.com\/web-development\/capybara-selenium-testing-scraping\/#article","isPartOf":{"@id":"https:\/\/www.webcodegeeks.com\/web-development\/capybara-selenium-testing-scraping\/"},"author":{"name":"Leigh Halliday","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/e496b17f78cdca27723b8e225dc6ab6b"},"headline":"Capybara and Selenium for Testing and Scraping","datePublished":"2016-07-14T09:15:27+00:00","mainEntityOfPage":{"@id":"https:\/\/www.webcodegeeks.com\/web-development\/capybara-selenium-testing-scraping\/"},"wordCount":1351,"commentCount":0,"publisher":{"@id":"https:\/\/www.webcodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.webcodegeeks.com\/web-development\/capybara-selenium-testing-scraping\/#primaryimage"},"thumbnailUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/web-dev-logo.jpg","keywords":["Capybara","Selenium","Testing"],"articleSection":["Web Dev"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.webcodegeeks.com\/web-development\/capybara-selenium-testing-scraping\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.webcodegeeks.com\/web-development\/capybara-selenium-testing-scraping\/","url":"https:\/\/www.webcodegeeks.com\/web-development\/capybara-selenium-testing-scraping\/","name":"Capybara and Selenium for Testing and Scraping - Web Code Geeks - 2026","isPartOf":{"@id":"https:\/\/www.webcodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.webcodegeeks.com\/web-development\/capybara-selenium-testing-scraping\/#primaryimage"},"image":{"@id":"https:\/\/www.webcodegeeks.com\/web-development\/capybara-selenium-testing-scraping\/#primaryimage"},"thumbnailUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/web-dev-logo.jpg","datePublished":"2016-07-14T09:15:27+00:00","description":"Capybara, aside from being the largest rodent in the world, is also a fantastic tool to aid you in interacting with browser functionality in your code,","breadcrumb":{"@id":"https:\/\/www.webcodegeeks.com\/web-development\/capybara-selenium-testing-scraping\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.webcodegeeks.com\/web-development\/capybara-selenium-testing-scraping\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/web-development\/capybara-selenium-testing-scraping\/#primaryimage","url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/web-dev-logo.jpg","contentUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/web-dev-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/www.webcodegeeks.com\/web-development\/capybara-selenium-testing-scraping\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.webcodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Web Dev","item":"https:\/\/www.webcodegeeks.com\/category\/web-development\/"},{"@type":"ListItem","position":3,"name":"Capybara and Selenium for Testing and Scraping"}]},{"@type":"WebSite","@id":"https:\/\/www.webcodegeeks.com\/#website","url":"https:\/\/www.webcodegeeks.com\/","name":"Web Code Geeks","description":"Web Developers Resource Center","publisher":{"@id":"https:\/\/www.webcodegeeks.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.webcodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.webcodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.webcodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/webcodegeeks","https:\/\/x.com\/webcodegeeks"]},{"@type":"Person","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/e496b17f78cdca27723b8e225dc6ab6b","name":"Leigh Halliday","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/bd40251a1acc424c292c35a3485264a801efa20efa7063c3e320a0a354ddafac?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/bd40251a1acc424c292c35a3485264a801efa20efa7063c3e320a0a354ddafac?s=96&d=mm&r=g","caption":"Leigh Halliday"},"description":"Leigh is a developer at theScore. He writes about Ruby, Rails, and software development on his personal site.","sameAs":["http:\/\/www.leighhalliday.com\/","https:\/\/x.com\/leighchalliday"],"url":"https:\/\/www.webcodegeeks.com\/author\/leigh-halliday\/"}]}},"_links":{"self":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts\/13921","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/users\/113"}],"replies":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/comments?post=13921"}],"version-history":[{"count":0,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts\/13921\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/media\/927"}],"wp:attachment":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/media?parent=13921"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/categories?post=13921"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/tags?post=13921"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}