true_automation 0.3.4 → 0.3.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +53 -7
- data/lib/true_automation/client.rb +12 -26
- data/lib/true_automation/driver/capybara.rb +6 -4
- data/lib/true_automation/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3355f74c9a473cd7b9b70072486452f12ed52ca1
|
4
|
+
data.tar.gz: c3c07946636cc8afc43ff29170a07bf8a8ef1813
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 87a85bc1280d4d0c812a8508f52b156c0f6c626a36e52c9eec9cc97dd32ffbe74e9a25a29150a60ba097ee7ef4ed90e042f94d8ff97f6c58f2e192510b3e0999
|
7
|
+
data.tar.gz: 96ca25ec16a59b3736ecf92c81e69b9ce20dd10f3393abd539fbba66698bc9ba167208743a3f78eeee5db01208b73b082b25842be067b662e461180e38519679
|
data/README.md
CHANGED
@@ -7,13 +7,17 @@
|
|
7
7
|
**true_automation** gem provides helper DSL method, that can be used instead of Selenium/Capybara locators.
|
8
8
|
Initial setup aim is to make `ta` method visible for your code.
|
9
9
|
|
10
|
-
You need
|
11
|
-
We recommend to use [nvm](https://github.com/creationix/nvm) or [nvm-windows](https://github.com/coreybutler/nvm-windows)
|
12
|
-
to install Node.
|
10
|
+
You need TrueAutomation.IO client installed first.
|
13
11
|
|
14
|
-
|
12
|
+
To install it just run the following command in your terminal. Using cURL:
|
15
13
|
|
16
|
-
|
14
|
+
curl -o- http://trueautomation.io/installer.sh | bash
|
15
|
+
|
16
|
+
Or using wget
|
17
|
+
|
18
|
+
wget -qO- http://trueautomation.io/installer.sh | bash
|
19
|
+
|
20
|
+
Then restart your terminal to start using TrueAutomation.IO
|
17
21
|
|
18
22
|
|
19
23
|
### Automatic Setup
|
@@ -23,8 +27,8 @@ in your project. Currently we support Capybara/RSpec automatic setup only.
|
|
23
27
|
|
24
28
|
#### Capybara/RSpec
|
25
29
|
|
26
|
-
For Capybara/RSpec projects TrueAutomation installer adds **true_automation** gem to the Gemfile,
|
27
|
-
DSL to `rspec_helper.rb
|
30
|
+
For Capybara/RSpec projects TrueAutomation installer adds **true_automation** gem to the Gemfile, includes TrueAutomation
|
31
|
+
DSL to `rspec_helper.rb` and replaces WebDriver with TrueAutomaton.IO Driver
|
28
32
|
|
29
33
|
#### Other
|
30
34
|
|
@@ -43,6 +47,48 @@ And then execute:
|
|
43
47
|
|
44
48
|
$ bundle install
|
45
49
|
|
50
|
+
#### Using TrueAutomaton.IO Capybara WebDriver
|
51
|
+
|
52
|
+
```ruby
|
53
|
+
require 'true_automation/driver/capybara'
|
54
|
+
```
|
55
|
+
|
56
|
+
To initialize WebDriver for Capybara
|
57
|
+
```ruby
|
58
|
+
TrueAutomation::Driver::Capybara.new(app, port: 9515)
|
59
|
+
```
|
60
|
+
|
61
|
+
#### Controlling TrueAutomation.IO Driver lifecycle
|
62
|
+
|
63
|
+
```ruby
|
64
|
+
require 'true_automation/client'
|
65
|
+
```
|
66
|
+
|
67
|
+
Initialize the client
|
68
|
+
|
69
|
+
```ruby
|
70
|
+
ta_client = TrueAutomation::Client.new
|
71
|
+
```
|
72
|
+
|
73
|
+
Start the client:
|
74
|
+
```ruby
|
75
|
+
ta_client.start(port: 9515)
|
76
|
+
```
|
77
|
+
|
78
|
+
Wait until client is started:
|
79
|
+
```ruby
|
80
|
+
ta_client.wait_until_start
|
81
|
+
```
|
82
|
+
|
83
|
+
Stop the client:
|
84
|
+
```ruby
|
85
|
+
ta_client.stop
|
86
|
+
```
|
87
|
+
|
88
|
+
Client automatically writes the log in `./log/trueautomation-<date-time>.log`
|
89
|
+
|
90
|
+
#### Using TrueAutomation.IO locators
|
91
|
+
|
46
92
|
Add TrueAutomation DSL to your test file
|
47
93
|
|
48
94
|
```ruby
|
@@ -1,42 +1,28 @@
|
|
1
1
|
require 'open3'
|
2
2
|
require 'json'
|
3
|
+
require 'mkmf'
|
3
4
|
|
4
5
|
module TrueAutomation
|
5
6
|
class Client
|
6
7
|
@pid = nil
|
7
8
|
|
8
|
-
def start
|
9
|
-
begin
|
10
|
-
node_ver = `node -v`
|
11
|
-
node_ver = node_ver[1..-1]
|
12
|
-
node_versions = node_ver.split('.')
|
13
|
-
major_version = node_versions[0]
|
9
|
+
def start(options)
|
14
10
|
|
15
|
-
|
16
|
-
|
17
|
-
exit
|
18
|
-
end
|
19
|
-
rescue e
|
20
|
-
puts 'Node executable can not be found. node version 9+ is required to run TrueAutomation.IO tests.'
|
21
|
-
exit
|
22
|
-
end
|
23
|
-
|
24
|
-
begin
|
25
|
-
trueautomation_version = `trueautomation --version`
|
11
|
+
@port = options[:port] || 9515
|
12
|
+
@executable = ENV['TRUEAUTOMATION_EXEC'] || 'trueautomation'
|
26
13
|
|
27
|
-
|
28
|
-
|
29
|
-
puts 'TrueAutomation.IO npm package is not installed. Run `npm install -g trueautomation` to install it first.'
|
30
|
-
exit
|
14
|
+
if find_executable(@executable).nil?
|
15
|
+
raise "`#{@executable}` not found. Can not find TrueAutomation.IO client"
|
31
16
|
end
|
32
17
|
|
33
|
-
|
18
|
+
trueautomation_version = `#{@executable} --version`
|
19
|
+
puts "TrueAutomation.IO client #{trueautomation_version.strip}"
|
34
20
|
|
21
|
+
Dir.mkdir('log') unless File.exist?('log')
|
35
22
|
logfile = "log/trueautomation-#{Time.now.strftime('%Y%m%dT%H%M%S')}.log"
|
36
23
|
|
37
|
-
@pid = spawn(
|
38
|
-
|
39
|
-
puts "Started TrueAutomation.IO client with pid #{@pid}"
|
24
|
+
@pid = spawn("#{@executable} --log-file #{logfile} --port #{@port}")
|
25
|
+
puts "Started TrueAutomation.IO client with pid #{@pid} listening to port #{@port}"
|
40
26
|
|
41
27
|
@pid
|
42
28
|
end
|
@@ -61,7 +47,7 @@ module TrueAutomation
|
|
61
47
|
private
|
62
48
|
|
63
49
|
def check_connection
|
64
|
-
Socket.tcp('localhost',
|
50
|
+
Socket.tcp('localhost', @port, connect_timeout: 2) { true } rescue false
|
65
51
|
end
|
66
52
|
end
|
67
53
|
end
|
@@ -4,20 +4,22 @@ module TrueAutomation
|
|
4
4
|
module Driver
|
5
5
|
class Capybara < Capybara::Selenium::Driver
|
6
6
|
def initialize(app, **options)
|
7
|
+
@port = options.delete(:port) || 9515
|
8
|
+
|
7
9
|
super(app, options)
|
8
10
|
|
9
11
|
@ta_client = TrueAutomation::Client.new
|
10
12
|
|
11
|
-
@options.merge!(
|
12
|
-
url:
|
13
|
+
@options.merge!(browser: :remote,
|
14
|
+
url: "http://localhost:#{@port}/",
|
13
15
|
desired_capabilities: {
|
14
16
|
browser: :chrome
|
15
|
-
}
|
17
|
+
})
|
16
18
|
end
|
17
19
|
|
18
20
|
def browser
|
19
21
|
unless @browser
|
20
|
-
@ta_client.start
|
22
|
+
@ta_client.start(port: @port)
|
21
23
|
|
22
24
|
@ta_client.wait_until_start
|
23
25
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: true_automation
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- TrueAutomation.IO
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-03-
|
11
|
+
date: 2018-03-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|