...regex editors that help you by highlighting matching text and capture groups: Ruby: Rubular Javascript: RegExr Regular expression visualizer using railroad diagrams
...explained in this card. It will prevent attackers from reading your cookies by malicious Javascript and prevent the user's browser from sending it over insecure HTTP connections. Generally: prefer...
Plot graphs in Ruby WebGraphviz renders in your browser via JavaScript (to store the rendered graph, extract the SVG using your browser's DOM inspector) GraphViz with DOT: Online...
...emulation file below. Problems and Solutions while upgrade capybara and cucumber problems with capybara javascript emulation Remove the following line from your features/support/env.rb file if present. require 'cucumber/rails/capybara_javascript_emulation'
...still have problems with teh capybara javascript emulation, please download capybara_javascript_emulation.rb to features/support/. undefined method click' for class Capybara::Driver::RackTest::Node' (NameError) Capybara::Driver::RackTest namespace moved to Capybara...
...want to reference a card from a different deck, this bookmarklet might be useful: javascript:(function () { const doAlert = () => { alert("Maybe not a makandra card?") }; let cardsPathPattern = /(\/[\w-]+\/\d+)-.+/; if (window.location.pathname.match...
...that inherits from StandardError. A fun read is Ninja code (even though it's Javascript...
...if it closes the tab entirely. It will not be dispatched when navigating via JavaScript. In this case you need to listen to other events. Quirks The "default behavior" in...
...This is the same as finding an option with the { selected: true } property in JavaScript: select.querySelectorAll('option').find((option) => option.selected) What about the selected attribute? Note that option[selected] would...
...not once the user switched to a different value. It also won't work in JavaScript-heavy applications where you might not be rendering an option tag with the selected...
config.rb activate :livereload activate :sprockets configure :build do activate :minify_css activate :minify_javascript activate :asset_hash end # Middleman fails to reload helpers, although it notices their modification
Complex "static" pages might need some integration testing, especially if they contain complex Javascript code. To employ Cucumber with Spreewald and Selenium, add these gems to the Gemfile:
making the whole page position: sticky; left: 0 capturing the scroll position with JavaScript and turning it into a transform: translateX on the table itself. Note that the table...
...browsers has ended. Some more advantages of clipboard.js: it consists only of a single javascript file, so it does not trigger additional requests with rails it automagically provides user feedback...
Add clipboard.js to your project through bower or by downloading and adding the javascript file to the asset pipeline. Require it in your application.js: #= require clipboard Prepare your html...
...toBe passes when first === second. Unfortunately this is useless for non-primitive values because JavaScript is a horrible language. However, Jasmine comes with another matcher toEqual: expect(first).toEqual(second...
Browsers blocks abusable JavaScript API calls until the user has interacted with the document. Examples would be opening new tab or start playing video or audio. E.g. if you attempt...
...an element, click on it, and remove the element again. This unblocks the entire JavaScript API for the current page. You can include the following module in your test to...
...canvas.pad{:width => Signature::WIDTH, :height => Signature::HEIGHT} = form.hidden_field :signature, :value => nil, :class => 'output' :javascript $(function() { $('.signature_form') .signaturePad({ drawOnly: true, validateFields: false, lineTop: #{Signature::HEIGHT - 30} }) .regenerate(#{JSON.parse(@signature.signature...
...file into spec/fixtures. When /^I sign the form$/ do signature = File.read('spec/fixtures/signature.json') page.execute_script(<<-JAVASCRIPT) $('.signature_form').data('plugin-signaturePad').regenerate(#{signature}); JAVASCRIPT
Limitations The helper cannot inspect downloads that are triggered or created by JavaScript. The helper cannot inspect downloads from a different hostname than that of the application.
...measure to solve Selenium focus issues, but this would require you un-parallelize all @javascript scenarios, leading to decreased performance of your test suite. To un-parallelize all @javascript scenarios...
...change the code at the bottom to this: Around("@no_parallel, @javascript") do |scenario, block| NO_PARALLEL_MUTEX.acquire(&block)
The Rails asset pipeline improves delivery of application assets (javascripts, stylesheets, images, fonts). Here are some basic facts about its inner workings. No magic Manifests are the handle on your...
...files are just sub-manifests. The need the corresponding file ending (e.g. .js for Javascript files), because "Sprockets assumes you are requiring a .js file when done from within a...
In a web application you often need to move data between the client (HTML, Javascript) and the server (Ruby, Rails). Step 1: Moving HTML snippets Add a find-as-you...
...of HTML from the server. For the part of the implementation that lives in Javascript, implement a Search.match(query) method that returns a promise. You should be able to use...
...patiently will sometimes break: with_scope('.container') do # => this caches the container element # => here JavaScript swaps the container element page.find('.child') # => tries to find a child of the previously cached...
end with_scope('.container') do # => this caches the container element # => here JavaScript swaps the container element page.find('.child') # => tries to find a child of the previously cached...
...Basic HTML example # Javascript API (notable methods and properties) video = document.querySelector('video') video.play() video.pause() video.load() // Reset to the beginning and select the best available source video.currentSrc // The selected source video.currentTime...
...Web and native playback overview (April 2020) Full Documentation on the video element Attributes Javascript events
# when the browser has no focus. When /^I unfocus the "(.*?)" field to trigger javascript listeners$/ do |field_label| field = page.find_field(field_label) # Firing 'autocomplete:done' is a workaround...
field = $('#{field[:id]}') field.blur() field.fire('autocomplete:done') JS sleep 1 end In the javascript: /* * Listening on "blur" events does not work in tests because Firefox has a bug * deferring...
...content of $('#id'). To do the same in Rails 3, include usual rails-ujs JavaScript, and put this into your application.js: $(function() { $('[data-remote][data-replace]') .data('type', 'html')
...replaced event on the link. .unobtrusive version In case you are using our unobtrusive JavaScript helper, use the following code instead: $.unobtrusive(function() { $('[data-remote][data-replace]') .data('type', 'html...
...position receives the click A step which finds and clicks the desired link via javascript may solve the problem: When(/^I search and click on "([^"]*)"$/) do |text| page.execute_script("$(\":contains...
...text}'):not(:has(:contains('#{text}')))\").click()") end Note: "Clicking" via JavaScript might click elements which are actually not clickable, e.g. because a modal overlay covers them. Use with caution.
...production, non-parallel test run. super end end def fresh? # Stock Webpacker checks if JavaScript changed in app, yarn.lock or config/webpack. # We want to be a bit stricter about freshness...
...assets once before your end-to-end integration test suite. Otherwise the first rendered javascript_pack_tag would start compilation, causing the helper to freeze for a minute and current...