Type text into Javascript prompt dialogs in Capybara/Selenium
Spreewald Show archive.org snapshot gives you steps like these:
When I enter "text" into the browser dialog
Also see Accept or deny JavaScript confirmation dialogs in Capybara/Selenium.
Related cards:
How to accept or deny JavaScript confirmation dialogs in Capybara/Selenium
These methods are available to you:
page.driver.browser.switch_to.alert.accept
page.driver.browser.switch_to.alert.dismiss
page.driver.browser.switch_to.alert.text # the confirmation text
[Spreewald](https://github.com/makandra/spree...
JavaScript bookmarklet to click an element and copy its text contents
Here is some JavaScript code that allows you to click the screen and get the clicked element's text contents (or value, in case of inputs).
The approach is simple: we place an overlay so you don't really click the target element. When you click t...
Howto prompt before accidentally discarding unsaved changes with JavaScript
Ask before leaving an unsaved CKEditor
Vanilla JavaScript way, but removes any other onbeforeunload
handlers:
$(function(){
document.body.onbeforeunload = function() {
for(editorName in CKEDITOR.instances) {
if (CKEDI...
JavaScript: Testing the type of a value
Checking if a JavaScript value is of a given type can be very confusing:
- There are two operators
typeof
andinstanceof
which work very differently. - JavaScript has some primitive types, like string literals, that are not objects (as oppose...
Paste X selections into your terminal with your keyboard
The buffer where text is put into when you double-click on text within X is called X selection.
You can paste this buffer (at least into a terminal window) by pressing Shift + Insert
.
JavaScript: Sharing content with the native share dialog
Mobile Chrome and Safari support the "web share API" which allow you to use the native share functionality of an Android or iOS phone. Some desktop OSs like Windows or MacOS also support native share dialogs. See [Can I Use](https://caniuse.com/?s...
Accessing JavaScript objects from Capybara/Selenium
When testing JavaScript functionality in Selenium (E2E), you may need to access a class or function inside of a evaluate_script
block in one of your steps. Capybara may only access definitions that are attached to the browser (over the window
...
Handling Keyboard Shortcuts in JavaScript
Despite the many JavaScript libraries that are available today, I cannot find one that makes it easy to add keyboard shortcuts(or accelerators) to your javascript app. This is because keyboard shortcuts where only used in JavaScript games - no ser...
When using "render :text", set a content type
When your Rails controller action responds with only a simple text, render text: 'Hello'
may not be what you want. You should not even use it on Rails 4.1+ any more.
By default, a "text" response from a Rails controller will still be a sent as ...
How to type accented characters on keyboard layouts without dead keys
Ubuntu comes with keyboard layouts like "Germany Eliminate Dead Keys", which are practical for programming.
If you need to type accented characters with such a layout, make sure to [configure a Compose key](https://makandracards.com/makandra/1030...