kobot 1.2.4 → 1.2.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/lib/kobot/engine.rb +27 -14
- data/lib/kobot/selector.rb +40 -0
- data/lib/kobot/version.rb +1 -1
- data/lib/kobot.rb +1 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f35251b3ce8549b6b268a9741ecc88398f4fca4e1fbe27c343e2a1c35d456ca0
|
4
|
+
data.tar.gz: 1af276cc34607f075650b5be4df65c9666449c761b410fb5cc63629fe0392ff7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a1a76b64eb1aa1019a12b4f1d4a2d34c84d79cf020b0ebc7cee7c1bd4902b180aec70790ee236883100bfd2501bbee9846f61b5b40dd8fb3996159e58b94b0df
|
7
|
+
data.tar.gz: a81c35396d3dde1a74ab9aad3c3535e92699268f49a133f9f43514b192bae808a84f1974c9f9c537690ce3561c942251c044591fc363b54c619b44586ede7670
|
data/CHANGELOG.md
CHANGED
data/lib/kobot/engine.rb
CHANGED
@@ -97,6 +97,12 @@ module Kobot
|
|
97
97
|
Kobot.logger.info("Navigate to: #{@top_url}")
|
98
98
|
@browser.get @top_url
|
99
99
|
@wait.until { @browser.find_element(id: 'modal_window') }
|
100
|
+
modal_title_element = @wait.until { @browser.find_element(css: '.modal-title') }
|
101
|
+
@selector = if modal_title_element.text.downcase.include? 'password'
|
102
|
+
Selector.en
|
103
|
+
else
|
104
|
+
Selector.ja
|
105
|
+
end
|
100
106
|
Kobot.logger.info "Page title: #{@browser.title}"
|
101
107
|
Kobot.logger.debug do
|
102
108
|
"Login with id=#{Credential.kot_id} and password=#{Credential.kot_password}"
|
@@ -106,10 +112,14 @@ module Kobot
|
|
106
112
|
@browser.find_element(css: 'div.btn-control-message').click
|
107
113
|
|
108
114
|
Kobot.logger.info 'Login successful'
|
109
|
-
@wait.until
|
115
|
+
@wait.until do
|
116
|
+
@browser.find_element(id: 'notification_content').text.include?(@selector.login_success_notification_text)
|
117
|
+
end
|
110
118
|
if Config.browser_geolocation
|
111
119
|
begin
|
112
|
-
@wait.until
|
120
|
+
@wait.until do
|
121
|
+
@browser.find_element(id: 'location_area').text.include?(@selector.location_area_notification_text)
|
122
|
+
end
|
113
123
|
rescue StandardError => e
|
114
124
|
Kobot.logger.warn "Get geolocation failed: #{e.message}"
|
115
125
|
end
|
@@ -119,21 +129,21 @@ module Kobot
|
|
119
129
|
|
120
130
|
def logout
|
121
131
|
if @browser.current_url.include? 'admin'
|
122
|
-
Kobot.logger.info('Logout from タイムカード page')
|
132
|
+
Kobot.logger.info('Logout from Time Card (タイムカード) page')
|
123
133
|
@browser.find_element(css: 'div.htBlock-header_logoutButton').click
|
124
134
|
else
|
125
|
-
Kobot.logger.info('Logout from Myレコーダー page')
|
135
|
+
Kobot.logger.info('Logout from My Recorder (Myレコーダー) page')
|
126
136
|
@wait.until { @browser.find_element(id: 'menu_icon') }.click
|
127
|
-
@wait.until { @browser.find_element(link:
|
137
|
+
@wait.until { @browser.find_element(link: @selector.logout_menu_link_text) }.click
|
128
138
|
@browser.switch_to.alert.accept
|
129
139
|
end
|
130
140
|
Kobot.logger.info 'Logout successful'
|
131
141
|
end
|
132
142
|
|
133
143
|
def read_today_record
|
134
|
-
Kobot.logger.info('Navigate to タイムカード page')
|
144
|
+
Kobot.logger.info('Navigate to Time Card (タイムカード) page')
|
135
145
|
@wait.until { @browser.find_element(id: 'menu_icon') }.click
|
136
|
-
@wait.until { @browser.find_element(link:
|
146
|
+
@wait.until { @browser.find_element(link: @selector.time_card_menu_link_text) }.click
|
137
147
|
|
138
148
|
time_table = @wait.until { @browser.find_element(css: 'div.htBlock-adjastableTableF_inner > table') }
|
139
149
|
time_table.find_elements(css: 'tbody > tr').each do |tr|
|
@@ -226,9 +236,9 @@ module Kobot
|
|
226
236
|
@browser.get @top_url
|
227
237
|
clock_in_button = @wait.until { @browser.find_element(css: 'div.record-clock-in') }
|
228
238
|
if Config.dryrun
|
229
|
-
Kobot.logger.info('[Dryrun]
|
239
|
+
Kobot.logger.info('[Dryrun] Clock-in button (出勤) would have been clicked')
|
230
240
|
else
|
231
|
-
Kobot.logger.info('Clicking the
|
241
|
+
Kobot.logger.info('Clicking the Clock-in button (出勤)')
|
232
242
|
clock_in_button.click
|
233
243
|
end
|
234
244
|
end
|
@@ -238,9 +248,9 @@ module Kobot
|
|
238
248
|
@browser.get @top_url
|
239
249
|
clock_out_button = @wait.until { @browser.find_element(css: 'div.record-clock-out') }
|
240
250
|
if Config.dryrun
|
241
|
-
Kobot.logger.info('[Dryrun]
|
251
|
+
Kobot.logger.info('[Dryrun] Clock-out button (退勤) would have been clicked')
|
242
252
|
else
|
243
|
-
Kobot.logger.info('Clicking the
|
253
|
+
Kobot.logger.info('Clicking the Clock-out button (退勤)')
|
244
254
|
clock_out_button.click
|
245
255
|
end
|
246
256
|
end
|
@@ -257,18 +267,21 @@ module Kobot
|
|
257
267
|
end
|
258
268
|
|
259
269
|
def kot_weekend?
|
260
|
-
|
270
|
+
[
|
271
|
+
@selector.kot_date_saturday,
|
272
|
+
@selector.kot_date_sunday
|
273
|
+
].any? { |weekend| @kot_today&.include? weekend }
|
261
274
|
end
|
262
275
|
|
263
276
|
def kot_public_holiday?
|
264
|
-
return true if @kot_today_type&.include?
|
277
|
+
return true if @kot_today_type&.include? @selector.kot_workday_time_off_text
|
265
278
|
|
266
279
|
kot_today_highlighted = %w[sunday saturday].any? do |css|
|
267
280
|
@kot_today_css_class&.include? css
|
268
281
|
end
|
269
282
|
if kot_today_highlighted
|
270
283
|
Kobot.logger.warn(
|
271
|
-
"Today=#{@kot_today} is highlighted (holiday) but not marked as
|
284
|
+
"Today=#{@kot_today} is highlighted (holiday) but not marked as #{@selector.kot_workday_time_off_text}"
|
272
285
|
)
|
273
286
|
end
|
274
287
|
kot_today_highlighted
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Kobot
|
4
|
+
# The texts used in selectors to identify the elements on KOT UI.
|
5
|
+
class Selector
|
6
|
+
attr_accessor :login_success_notification_text,
|
7
|
+
:location_area_notification_text,
|
8
|
+
:time_card_menu_link_text,
|
9
|
+
:kot_date_saturday,
|
10
|
+
:kot_date_sunday,
|
11
|
+
:kot_workday_time_off_text,
|
12
|
+
:logout_menu_link_text
|
13
|
+
|
14
|
+
class << self
|
15
|
+
def en
|
16
|
+
selector = Selector.new
|
17
|
+
selector.login_success_notification_text = 'Data has been obtained'
|
18
|
+
selector.location_area_notification_text = 'Obtained location'
|
19
|
+
selector.time_card_menu_link_text = 'Time Card'
|
20
|
+
selector.kot_date_saturday = 'Sat'
|
21
|
+
selector.kot_date_sunday = 'Sun'
|
22
|
+
selector.kot_workday_time_off_text = 'time-off'
|
23
|
+
selector.logout_menu_link_text = 'Sign out'
|
24
|
+
selector
|
25
|
+
end
|
26
|
+
|
27
|
+
def ja
|
28
|
+
selector = Selector.new
|
29
|
+
selector.login_success_notification_text = 'データを取得しました'
|
30
|
+
selector.location_area_notification_text = '位置情報取得済み'
|
31
|
+
selector.time_card_menu_link_text = 'タイムカード'
|
32
|
+
selector.kot_date_saturday = '土'
|
33
|
+
selector.kot_date_sunday = '日'
|
34
|
+
selector.kot_workday_time_off_text = '休日'
|
35
|
+
selector.logout_menu_link_text = 'ログアウト'
|
36
|
+
selector
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
data/lib/kobot/version.rb
CHANGED
data/lib/kobot.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kobot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andy Jiang
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-12-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: webdrivers
|
@@ -83,6 +83,7 @@ files:
|
|
83
83
|
- lib/kobot/logger.rb
|
84
84
|
- lib/kobot/mailer.rb
|
85
85
|
- lib/kobot/option.rb
|
86
|
+
- lib/kobot/selector.rb
|
86
87
|
- lib/kobot/version.rb
|
87
88
|
homepage: https://github.com/yuan-jiang/kobot
|
88
89
|
licenses:
|
@@ -107,7 +108,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
107
108
|
- !ruby/object:Gem::Version
|
108
109
|
version: '0'
|
109
110
|
requirements: []
|
110
|
-
rubygems_version: 3.
|
111
|
+
rubygems_version: 3.1.2
|
111
112
|
signing_key:
|
112
113
|
specification_version: 4
|
113
114
|
summary: Kobot automates the clock in/out of KING OF TIME.
|