njongto_duo 0.0.35 → 0.0.37

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/njongto_duo.rb +97 -38
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2415a9c469aa090ebc15f8e85c4d10f6b7eb89ccfa874420ae71f449fcbf4d2e
4
- data.tar.gz: 07256eb887f0bece4f4c19c5416afd826d140b76599a753e36583a99827b0da6
3
+ metadata.gz: 1526507244d8cd0dd3816213479befe8de8175207c83469944b2a95dbdbfde9b
4
+ data.tar.gz: ce3d0473037d5087f7d16bcb0d7c601a028313c744fdc7a6d6ec43e67bea1b1a
5
5
  SHA512:
6
- metadata.gz: c7c6f557f56adb7ff383f2031821a43c06fad7fba35c6c3fb83d260d0b7f1b6057e349807902b599237099265fcce500b7a219ef62a038e98ce85c44129f3d80
7
- data.tar.gz: 4214def14fc8de42e98c90d167f0917e2ce224e18fa7affcd4bc60c81e28a62454c6addce3864fb8efa11e560988678d9068b835aa0922daf0c8e96a419e3749
6
+ metadata.gz: 8006c574435c487fbb115b9672d1fd811f137faf49c6465bc4fed688c95c8248393339f5c5afdb3baa7e68ef093930738fa97d69ed9edfc1297762b0b7227188
7
+ data.tar.gz: a68abc66947a09fbb36b49b215cf748f3bddd9877ea1def43cfab17ccfc23db57be30ffae0ce5d2eb4e96ca88384ea4da70aeaa0076332d8e4080f7e0af1a74e
data/lib/njongto_duo.rb CHANGED
@@ -126,39 +126,57 @@ class Naver
126
126
  sleep(1)
127
127
 
128
128
  begin
129
- wait = Selenium::WebDriver::Wait.new(:timeout => 3)
129
+ wait = Selenium::WebDriver::Wait.new(:timeout => 7)
130
+ #요소가 나타날 때까지 3초 동안 기다립니다.
131
+ wait.until { @driver.find_element(:xpath, '//*[@class="MyView-module__btn_logout___bsTOJ"]') }
132
+ sleep(1.5)
133
+ check_cookie_login = 1
134
+ puts'[Step.02] 계정 세션 확인!! 로그인 skip.......'.yellow
135
+ sleep(2.5)
136
+ rescue
137
+ wait = Selenium::WebDriver::Wait.new(:timeout => 7)
130
138
  #요소가 나타날 때까지 3초 동안 기다립니다.
131
139
  wait.until { @driver.find_element(:xpath, '//*[@class="MyView-module__link_login___HpHMW"]') }
132
140
  sleep(1.5)
133
141
  @driver.find_element(:xpath, '//*[@class="MyView-module__link_login___HpHMW"]').click
134
142
  check_cookie_login = 0
135
143
  sleep(1)
136
- rescue
137
- check_cookie_login = 1
138
- puts'[Step.02] 계정 세션 확인!! 로그인 skip.......'.yellow
139
- sleep(2.5)
140
144
  end
141
145
 
142
146
  if check_cookie_login == 0
143
147
  puts'[Step.02] 계정 세션이 없거나 기간 만료로 인해 로그인 시도.......'.yellow
144
148
  # @driver.find_element(:xpath, '//*[@id="right-content-area"]/div[1]/div[1]/div/a').click
145
149
  sleep(3)
146
- wait = Selenium::WebDriver::Wait.new(:timeout => 3)
147
- #요소가 나타날 때까지 3초 동안 기다립니다.
148
- wait.until { @driver.find_element(:xpath, '//*[@for="switch"]') }
149
- sleep(1.5)
150
- @driver.find_element(:xpath, '//*[@id="login_keep_wrap"]/div[1]/label').click
151
- sleep(1.5)
152
- @driver.find_element(:xpath, '//*[@id="id"]').click
153
- Clipboard.copy(user_id)
154
- @driver.action.key_down(:control).send_keys('v').key_up(:control).perform
155
- sleep(1.5)
156
- @driver.find_element(:xpath, '//*[@id="pw"]').click
157
- Clipboard.copy(user_pw)
158
- @driver.action.key_down(:control).send_keys('v').key_up(:control).perform
159
- sleep(1.5)
160
- @driver.find_element(:xpath, '//*[@id="log.login"]').click
161
- sleep(2.5)
150
+ begin
151
+ wait = Selenium::WebDriver::Wait.new(:timeout => 7)
152
+ #요소가 나타날 때까지 3초 동안 기다립니다.
153
+ wait.until { @driver.find_element(:xpath, '//*[@for="switch"]') }
154
+ sleep(1.5)
155
+ @driver.find_element(:xpath, '//*[@id="login_keep_wrap"]/div[1]/label').click
156
+ sleep(1.5)
157
+ @driver.find_element(:xpath, '//*[@id="id"]').click
158
+ Clipboard.copy(user_id)
159
+ @driver.action.key_down(:control).send_keys('v').key_up(:control).perform
160
+ sleep(1.5)
161
+ @driver.find_element(:xpath, '//*[@id="pw"]').click
162
+ Clipboard.copy(user_pw)
163
+ @driver.action.key_down(:control).send_keys('v').key_up(:control).perform
164
+ sleep(1.5)
165
+ @driver.find_element(:xpath, '//*[@id="log.login"]').click
166
+ sleep(2.5)
167
+ rescue => e
168
+ puts '-[√] 로딩 지연 접속 실패.......'.red
169
+ @driver.window_handles.each do |handle|
170
+ @driver.switch_to.window(handle)
171
+ begin
172
+ # 로딩 중이거나, 페이지가 완전히 로딩되지 않더라도 탭을 닫기
173
+ @driver.close
174
+ rescue Selenium::WebDriver::Error::WebDriverError => e
175
+ puts "Failed to close tab: #{e.message}"
176
+ end
177
+ end
178
+ return 0
179
+ end
162
180
 
163
181
  else
164
182
  # @driver.switch_to.default_content
@@ -170,11 +188,18 @@ class Naver
170
188
  wait.until { @driver.find_element(:xpath, '//*[@class="MyView-module__btn_logout___bsTOJ"]') }
171
189
 
172
190
  rescue => e
173
- puts '-[√] 로그인 실패!!.......'.red
174
- puts e
175
- @driver.close
191
+ puts '-[√] 로그인 실패.......'.red
192
+ @driver.window_handles.each do |handle|
193
+ @driver.switch_to.window(handle)
194
+ begin
195
+ # 로딩 중이거나, 페이지가 완전히 로딩되지 않더라도 탭을 닫기
196
+ @driver.close
197
+ rescue Selenium::WebDriver::Error::WebDriverError => e
198
+ puts "Failed to close tab: #{e.message}"
199
+ end
200
+ end
176
201
  return 0
177
- end
202
+ end
178
203
  end
179
204
 
180
205
  def create_id
@@ -210,11 +235,19 @@ class Naver
210
235
  puts'[기능 발동!!] 오픈톡 유형 감지 확인.......'.green
211
236
  puts'[Step.04] 제목 입력.......'.yellow
212
237
  @driver.find_element(:xpath, '//*[@placeholder="제목"]').send_keys(title)
213
- rescue
238
+ rescue => e
214
239
  puts '[Error] 제목 입력란을 찾을 수 없습니다. 브라우저를 종료합니다.'.red
215
- @driver.close
216
- return 0
217
- end
240
+ @driver.window_handles.each do |handle|
241
+ @driver.switch_to.window(handle)
242
+ begin
243
+ # 로딩 중이거나, 페이지가 완전히 로딩되지 않더라도 탭을 닫기
244
+ @driver.close
245
+ rescue Selenium::WebDriver::Error::WebDriverError => e
246
+ puts "Failed to close tab: #{e.message}"
247
+ end
248
+ end
249
+ return 0
250
+ end
218
251
  end
219
252
 
220
253
  #내용 입력
@@ -233,11 +266,19 @@ class Naver
233
266
  @driver.find_element(:xpath, '//*[@placeholder="내용을 입력해 주세요."]')
234
267
  puts'[Step.05] 내용 입력.......'.yellow
235
268
  @driver.find_element(:xpath, '//*[@placeholder="내용을 입력해 주세요."]').click
236
- rescue
269
+ rescue => e
237
270
  puts '[Error] 내용 입력란을 찾을 수 없습니다. 브라우저를 종료합니다.'.red
238
- @driver.close
239
- return 0
240
- end
271
+ @driver.window_handles.each do |handle|
272
+ @driver.switch_to.window(handle)
273
+ begin
274
+ # 로딩 중이거나, 페이지가 완전히 로딩되지 않더라도 탭을 닫기
275
+ @driver.close
276
+ rescue Selenium::WebDriver::Error::WebDriverError => e
277
+ puts "Failed to close tab: #{e.message}"
278
+ end
279
+ end
280
+ return 0
281
+ end
241
282
  end
242
283
 
243
284
  puts content
@@ -309,16 +350,34 @@ class Naver
309
350
  puts'[Step.06] 등록 버튼 클릭 (시도).......'.yellow
310
351
  @driver.find_element(:xpath, '//*[@data-nclicks="nbw.ok"]').click
311
352
  puts'[Step.07] 등록 버튼 클릭 (성공).......'.yellow
312
- rescue
353
+ rescue => e
313
354
  puts '[Error] 등록 버튼을 찾을 수 없습니다. 브라우저를 종료합니다.'.red
314
- @driver.close
315
- return 0
316
- end
355
+ @driver.window_handles.each do |handle|
356
+ @driver.switch_to.window(handle)
357
+ begin
358
+ # 로딩 중이거나, 페이지가 완전히 로딩되지 않더라도 탭을 닫기
359
+ @driver.close
360
+ rescue Selenium::WebDriver::Error::WebDriverError => e
361
+ puts "Failed to close tab: #{e.message}"
362
+ end
363
+ end
364
+ return 0
365
+ end
366
+
367
+
317
368
  end
318
369
  sleep(5)
319
370
  begin
320
371
  puts'[MISSION SUCCESS !! // 미션 성공 !!] 브라우저 종료.......'.green
321
- @driver.close
372
+ @driver.window_handles.each do |handle|
373
+ @driver.switch_to.window(handle)
374
+ begin
375
+ # 로딩 중이거나, 페이지가 완전히 로딩되지 않더라도 탭을 닫기
376
+ @driver.close
377
+ rescue Selenium::WebDriver::Error::WebDriverError => e
378
+ puts "Failed to close tab: #{e.message}"
379
+ end
380
+ end
322
381
  rescue
323
382
 
324
383
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: njongto_duo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.35
4
+ version: 0.0.37
5
5
  platform: ruby
6
6
  authors:
7
7
  - zon