girbot 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: da32d54d8b5bee072cd244a31ba756b4d7724e92
4
- data.tar.gz: 7a3d56cde56d78b7d82e7b250eaccbcb265f4f80
3
+ metadata.gz: 548b6f82b9fe496d2ba7e4b7f68952b94a38f2c1
4
+ data.tar.gz: 8d56726e5e3ab874ae66e9c63cc6dbfa491bdf87
5
5
  SHA512:
6
- metadata.gz: 5c7b4330b81a3898af4c182ef38c32febac8c3b0365dae5b320263744d2479d86e024291195439dde89ac01b02c294f4aac6eb2a8883d021da06a9bdcb10b0b5
7
- data.tar.gz: 377c7cd1c6f8abf9fc930d759d3e0745e14683f4451febdb6c0b924bd798043a885dea7f15199480c46a7bcbeca53d820c8227838a5bbbbcab92864eceaff404
6
+ metadata.gz: fefc60f555993813fb382f4f025c834b67fb340231084184d5fa018c05a7acc64b8049c9de09a29c9c8f04da292ce8d0d91a7b826f4e1ebe9f61cca763c162c8
7
+ data.tar.gz: 640c64659120ded4b75c91d775933337a5b3bc644765ad89a59b5b48e77debea0bb453a55b98d175aab5c469ff0291d88fff68f6090cc934c2e16a9fd9a17a13
data/README.md CHANGED
@@ -13,6 +13,9 @@ Girbot::Step.run(
13
13
  # if the browser is hidden
14
14
  headless: true,
15
15
 
16
+ # if the browser should be maximized
17
+ maximize: true,
18
+
16
19
  # opens the browser in the BrowserHolder
17
20
  openBrowser: true,
18
21
 
data/girbot.gemspec CHANGED
@@ -9,9 +9,9 @@ Gem::Specification.new do |spec|
9
9
  spec.authors = ["Cristian Mircea Messel"]
10
10
  spec.email = ["mess110@gmail.com"]
11
11
 
12
- spec.summary = %q{Summary}
13
- spec.description = %q{Description}
14
- spec.homepage = "http://google.com"
12
+ spec.summary = %q{> bleep-blop wreak havoc bleep mischief - Girbot}
13
+ spec.description = %q{Girbot wants to help you automate boring tasks. You define steps which can be run in different browsers.}
14
+ spec.homepage = "https://github.com/mess110/girbot"
15
15
  spec.license = "MIT"
16
16
 
17
17
  spec.files = `git ls-files -z`.split("\x0").reject do |f|
@@ -8,6 +8,7 @@ module Girbot
8
8
 
9
9
  def take_whole_action options, openBrowser, closeBrowser
10
10
  @browser_holder.init if openBrowser
11
+ maximize if options[:maximize]
11
12
  validate_browser_presence
12
13
  action(options)
13
14
  close if closeBrowser
@@ -50,6 +51,7 @@ module Girbot
50
51
  raise 'invalid options[:details][:auth]' unless options[:details][:auth].is_a?(Hash)
51
52
  raise 'invalid options[:details][:auth][:user]' unless options[:details][:auth][:user].is_a?(String)
52
53
  raise 'invalid options[:details][:auth][:pass]' unless options[:details][:auth][:pass].is_a?(String)
54
+ options[:details][:auth]
53
55
  end
54
56
 
55
57
  def validate_card(options)
@@ -65,6 +67,7 @@ module Girbot
65
67
  # * expYear is a year
66
68
  # * expMonth is a month
67
69
  # * ccv is only digits
70
+ options[:details][:card]
68
71
  end
69
72
 
70
73
  def self.read path
@@ -76,6 +79,7 @@ module Girbot
76
79
  options[:headless] = true if options[:headless].nil?
77
80
  options[:openBrowser] = true if options[:openBrowser].nil?
78
81
  options[:closeBrowser] = true if options[:closeBrowser].nil?
82
+ options[:maximize] = false if options[:maximize].nil?
79
83
 
80
84
  step = self.new(options[:browser])
81
85
  if options[:headless]
@@ -1,3 +1,3 @@
1
1
  module Girbot
2
- VERSION = '0.1.2'
2
+ VERSION = '0.1.3'
3
3
  end
@@ -4,6 +4,14 @@ module Girbot
4
4
  @browser_holder.browser
5
5
  end
6
6
 
7
+ def maximize
8
+ browser.driver.manage.window.maximize
9
+ rescue Selenium::WebDriver::Error::UnknownError => e
10
+ puts 'Could not maximize. Moving on.'
11
+ puts e
12
+ puts e.backtrace
13
+ end
14
+
7
15
  def goto url
8
16
  browser.goto url
9
17
  end
@@ -12,8 +20,15 @@ module Girbot
12
20
  browser.text_field(query).set text
13
21
  end
14
22
 
15
- def fire query
16
- browser.checkbox(query).fire_event :click
23
+ def append_to_textfield text, query
24
+ input = browser.text_field(query)
25
+ text.chars.each do |c|
26
+ input.append(c)
27
+ end
28
+ end
29
+
30
+ def exec_js js
31
+ browser.execute_script(js)
17
32
  end
18
33
 
19
34
  def select_value(value, query)
@@ -29,6 +44,15 @@ module Girbot
29
44
  browser.send(type, query).click
30
45
  end
31
46
 
47
+ # Examples:
48
+ #
49
+ # fire_event(:checkbox, id: 'my-id')
50
+ # fire_event(:checkbox, class: 'my-class', :click)
51
+ #
52
+ def fire_event(type, query, event = :click)
53
+ browser.send(type, query).fire_event event
54
+ end
55
+
32
56
  def close
33
57
  browser.close
34
58
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: girbot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cristian Mircea Messel
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-03-06 00:00:00.000000000 Z
11
+ date: 2018-06-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -136,7 +136,8 @@ dependencies:
136
136
  - - '='
137
137
  - !ruby/object:Gem::Version
138
138
  version: 2.3.1
139
- description: Description
139
+ description: Girbot wants to help you automate boring tasks. You define steps which
140
+ can be run in different browsers.
140
141
  email:
141
142
  - mess110@gmail.com
142
143
  executables: []
@@ -159,8 +160,6 @@ files:
159
160
  - examples/cookie_clicker.rb
160
161
  - examples/details.json.example
161
162
  - examples/emag_search.rb
162
- - examples/plata_electrica.rb
163
- - examples/plata_eon.rb
164
163
  - examples/test_run.rb
165
164
  - girbot.gemspec
166
165
  - lib/girbot.rb
@@ -173,7 +172,7 @@ files:
173
172
  - lib/girbot/watir_shortcuts.rb
174
173
  - pass.txt
175
174
  - users.txt
176
- homepage: http://google.com
175
+ homepage: https://github.com/mess110/girbot
177
176
  licenses:
178
177
  - MIT
179
178
  metadata: {}
@@ -196,5 +195,5 @@ rubyforge_project:
196
195
  rubygems_version: 2.6.14
197
196
  signing_key:
198
197
  specification_version: 4
199
- summary: Summary
198
+ summary: "> bleep-blop wreak havoc bleep mischief - Girbot"
200
199
  test_files: []
@@ -1,46 +0,0 @@
1
- require "bundler/setup"
2
- require "girbot"
3
-
4
- class PlataElectrica < Girbot::Step
5
- def action options = {}
6
- validate_auth(options)
7
- validate_card(options)
8
-
9
- goto 'https://myelectrica.ro/index.php?pagina=login'
10
- text_in_textfield(options[:details][:auth][:user], id: 'myelectrica_utilizator')
11
- text_in_textfield(options[:details][:auth][:pass], id: 'myelectrica_pass')
12
- sleep 1
13
- click(:button, id: 'myelectrica_login_btn')
14
-
15
- goto 'https://myelectrica.ro/index.php?pagina=plateste-online'
16
- sleep 1
17
- fire id: 'myelectrica_checkall'
18
- click(:button, type: 'submit')
19
- sleep 1
20
- click(:button, id: 'requestMobilPay')
21
-
22
- text_in_textfield(options[:details][:card][:number], id: 'paymentCardNumber')
23
- text_in_textfield(options[:details][:card][:name], id: 'paymentCardName')
24
- browser.execute_script("document.getElementById('paymentExpMonth').style.opacity='1';")
25
- select_value(options[:details][:card][:expMonth], id: 'paymentExpMonth')
26
- browser.execute_script("document.getElementById('paymentExpYear').style.opacity='1';")
27
- select_value(options[:details][:card][:expYear], id: 'paymentExpYear')
28
- text_in_textfield(options[:details][:card][:ccv], id: 'paymentCVV2Number')
29
-
30
- click(:button, type: 'submit')
31
-
32
- loop do
33
- sleep 1
34
- end
35
- end
36
- end
37
-
38
- PlataElectrica.run(
39
- headless: false,
40
- closeBrowser: false,
41
- browser: Girbot::BrowserHolder.new(:chrome, nil),
42
- details: {
43
- auth: Girbot::Step.read('./examples/details.json')[:auth][0],
44
- card: Girbot::Step.read('./examples/details.json')[:cards][0]
45
- }
46
- )
@@ -1,46 +0,0 @@
1
- require "bundler/setup"
2
- require "girbot"
3
-
4
- class PlataEon < Girbot::Step
5
- def action options = {}
6
- validate_auth(options)
7
- validate_card(options)
8
-
9
- goto 'https://myline-eon.ro/login'
10
- text_in_textfield(options[:details][:auth][:user], id: 'username')
11
- text_in_textfield(options[:details][:auth][:pass], id: 'password')
12
- sleep 1
13
- click(:button, type: 'submit')
14
-
15
- # goto 'https://myelectrica.ro/index.php?pagina=plateste-online'
16
- # sleep 1
17
- # fire id: 'myelectrica_checkall'
18
- # click(:button, type: 'submit')
19
- # sleep 1
20
- # click(:button, id: 'requestMobilPay')
21
-
22
- # text_in_textfield(options[:details][:card][:number], id: 'paymentCardNumber')
23
- # text_in_textfield(options[:details][:card][:name], id: 'paymentCardName')
24
- # browser.execute_script("document.getElementById('paymentExpMonth').style.opacity='1';")
25
- # select_value(options[:details][:card][:expMonth], id: 'paymentExpMonth')
26
- # browser.execute_script("document.getElementById('paymentExpYear').style.opacity='1';")
27
- # select_value(options[:details][:card][:expYear], id: 'paymentExpYear')
28
- # text_in_textfield(options[:details][:card][:ccv], id: 'paymentCVV2Number')
29
-
30
- # click(:button, type: 'submit')
31
-
32
- loop do
33
- sleep 1
34
- end
35
- end
36
- end
37
-
38
- PlataEon.run(
39
- headless: false,
40
- closeBrowser: false,
41
- browser: Girbot::BrowserHolder.new(:chrome, nil),
42
- details: {
43
- auth: Girbot::Step.read('./examples/details.json')[:auth][0],
44
- card: Girbot::Step.read('./examples/details.json')[:cards][0]
45
- }
46
- )