dropybara 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/dropybara.rb +41 -0
- metadata +45 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 463fd6a6ec6b2869cde7a6bbd89d8bf69a171847
|
4
|
+
data.tar.gz: c1b0f06f74ac29cfc6da0908978ab890e08f64c3
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: dc43ede9689330b5ece4997b66ddc9208381ea5991c6bce62f7e7814c4cdbb3042e58a36b29a5f9b2790f6a9c04da9090b2e840d767fa5cdea930b6a0f2ca9b2
|
7
|
+
data.tar.gz: 3744d7f5ed39f4c7ce753362f3e12b78f4531b3e60bf5105c5533b5044d41e718bff6fde47626f838fd486efddf888e0f815686dd283b72bc671123efbb18dd3
|
data/lib/dropybara.rb
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
module Capybara
|
2
|
+
class Session
|
3
|
+
define_method 'drop_file' do |*args, &block|
|
4
|
+
current_scope.send('drop_file', *args, &block)
|
5
|
+
end
|
6
|
+
end
|
7
|
+
|
8
|
+
module Node
|
9
|
+
module Actions
|
10
|
+
def drop_file(locator, *args)
|
11
|
+
element_id = "dropybara_input_#{rand(1000)}"
|
12
|
+
|
13
|
+
driver.execute_script <<-JS
|
14
|
+
var input = document.createElement('input');
|
15
|
+
input.setAttribute('type', 'file');
|
16
|
+
input.setAttribute('id', '#{element_id}')
|
17
|
+
document.body.appendChild(input);
|
18
|
+
JS
|
19
|
+
|
20
|
+
attach_file(element_id, *args).tap do
|
21
|
+
driver.execute_script <<-JS
|
22
|
+
var input = document.getElementById('#{element_id}');
|
23
|
+
var target = document.querySelector('#{locator}');
|
24
|
+
var data = new DataTransfer();
|
25
|
+
data.files = input.files;
|
26
|
+
data.items.add(input.files[0]);
|
27
|
+
data.types = ['Files'];
|
28
|
+
|
29
|
+
var event = new DragEvent('drop', {
|
30
|
+
target: target,
|
31
|
+
dataTransfer: data
|
32
|
+
});
|
33
|
+
target.dispatchEvent(event);
|
34
|
+
|
35
|
+
document.body.removeChild(input);
|
36
|
+
JS
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
metadata
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: dropybara
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Sam Boylett
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-02-05 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description:
|
14
|
+
email: sam.boylett@piksel.com
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- lib/dropybara.rb
|
20
|
+
homepage: https://github.com/pikselpalette/dropybara
|
21
|
+
licenses:
|
22
|
+
- Apache License 2.0
|
23
|
+
metadata:
|
24
|
+
source_code_uri: https://github.com/pikselpalette/dropybara
|
25
|
+
post_install_message:
|
26
|
+
rdoc_options: []
|
27
|
+
require_paths:
|
28
|
+
- lib
|
29
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
35
|
+
requirements:
|
36
|
+
- - ">="
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '0'
|
39
|
+
requirements: []
|
40
|
+
rubyforge_project:
|
41
|
+
rubygems_version: 2.6.10
|
42
|
+
signing_key:
|
43
|
+
specification_version: 4
|
44
|
+
summary: Drag and drop files in Capybara
|
45
|
+
test_files: []
|