cafe_buy_duo 0.0.33 → 0.0.35

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/cafe_buy_duo.rb +100 -37
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ce8b54555066ca35a4cbd69db95ce064bd71c2b4016e3b7710d66b857e16968d
4
- data.tar.gz: 85a7c33f9d410fdc7461de7e81b4336794c72c8c7436b01f3f31237c8d6e1d3f
3
+ metadata.gz: de3263f339749fd119cb25d439baf58d0df4fdab1a8634cf4001661d4fb5a645
4
+ data.tar.gz: 24c67dcdba0dcf69bf4ed96bbb1ec227c791cd245bf4f6ab2d0838d88d734aed
5
5
  SHA512:
6
- metadata.gz: 183ae497834939d56e4d3a3aa9c93e528728aca4382faaf2754e93d28220e103cd0e9b26c0257df5db0c61ea1d57ddf809908e22d353c36cd38e5d12f88ae0cd
7
- data.tar.gz: 45394e3e146f09ee5ce735dcd2b35395ddff0e26a3b57b47d90318cef4449e646c38fd23438bc8cfb22bb2944f370e774fd28e3fa65e78cf9f0b50ee4981483d
6
+ metadata.gz: 0a4025efa5cd6ba94f022ed3123b6fe4c832291b2f756bebefbc0552d4d3022a93efbcf6718463b32f6f85809e5c957e86a8a27faecb6e4cdc59a5a4f0b73d3f
7
+ data.tar.gz: a4a2e80bbebe90fb54794069d18a4c8cb61ddce8f9d0662efb42f2cf0e4609e681698afc6634531629d10f88703f49fa2e3fb960fa5c11f6ad1592209d3133f8
data/lib/cafe_buy_duo.rb CHANGED
@@ -310,39 +310,57 @@ class Naver
310
310
  sleep(1)
311
311
 
312
312
  begin
313
- wait = Selenium::WebDriver::Wait.new(:timeout => 3)
313
+ wait = Selenium::WebDriver::Wait.new(:timeout => 7)
314
+ #요소가 나타날 때까지 3초 동안 기다립니다.
315
+ wait.until { @driver.find_element(:xpath, '//*[@class="MyView-module__btn_logout___bsTOJ"]') }
316
+ sleep(1.5)
317
+ check_cookie_login = 1
318
+ puts'[Step.02] 계정 세션 확인!! 로그인 skip.......'.yellow
319
+ sleep(2.5)
320
+ rescue
321
+ wait = Selenium::WebDriver::Wait.new(:timeout => 7)
314
322
  #요소가 나타날 때까지 3초 동안 기다립니다.
315
323
  wait.until { @driver.find_element(:xpath, '//*[@class="MyView-module__link_login___HpHMW"]') }
316
324
  sleep(1.5)
317
325
  @driver.find_element(:xpath, '//*[@class="MyView-module__link_login___HpHMW"]').click
318
326
  check_cookie_login = 0
319
327
  sleep(1)
320
- rescue
321
- check_cookie_login = 1
322
- puts'[Step.02] 계정 세션 확인!! 로그인 skip.......'.yellow
323
- sleep(2.5)
324
328
  end
325
329
 
326
330
  if check_cookie_login == 0
327
331
  puts'[Step.02] 계정 세션이 없거나 기간 만료로 인해 로그인 시도.......'.yellow
328
332
  # @driver.find_element(:xpath, '//*[@id="right-content-area"]/div[1]/div[1]/div/a').click
329
333
  sleep(3)
330
- wait = Selenium::WebDriver::Wait.new(:timeout => 3)
331
- #요소가 나타날 때까지 3초 동안 기다립니다.
332
- wait.until { @driver.find_element(:xpath, '//*[@for="switch"]') }
333
- sleep(1.5)
334
- @driver.find_element(:xpath, '//*[@id="login_keep_wrap"]/div[1]/label').click
335
- sleep(1.5)
336
- @driver.find_element(:xpath, '//*[@id="id"]').click
337
- Clipboard.copy(user_id)
338
- @driver.action.key_down(:control).send_keys('v').key_up(:control).perform
339
- sleep(1.5)
340
- @driver.find_element(:xpath, '//*[@id="pw"]').click
341
- Clipboard.copy(user_pw)
342
- @driver.action.key_down(:control).send_keys('v').key_up(:control).perform
343
- sleep(1.5)
344
- @driver.find_element(:xpath, '//*[@id="log.login"]').click
345
- sleep(2.5)
334
+ begin
335
+ wait = Selenium::WebDriver::Wait.new(:timeout => 7)
336
+ #요소가 나타날 때까지 3초 동안 기다립니다.
337
+ wait.until { @driver.find_element(:xpath, '//*[@for="switch"]') }
338
+ sleep(1.5)
339
+ @driver.find_element(:xpath, '//*[@id="login_keep_wrap"]/div[1]/label').click
340
+ sleep(1.5)
341
+ @driver.find_element(:xpath, '//*[@id="id"]').click
342
+ Clipboard.copy(user_id)
343
+ @driver.action.key_down(:control).send_keys('v').key_up(:control).perform
344
+ sleep(1.5)
345
+ @driver.find_element(:xpath, '//*[@id="pw"]').click
346
+ Clipboard.copy(user_pw)
347
+ @driver.action.key_down(:control).send_keys('v').key_up(:control).perform
348
+ sleep(1.5)
349
+ @driver.find_element(:xpath, '//*[@id="log.login"]').click
350
+ sleep(2.5)
351
+ rescue => e
352
+ puts '-[√] 로딩 지연 접속 실패.......'.red
353
+ @driver.window_handles.each do |handle|
354
+ @driver.switch_to.window(handle)
355
+ begin
356
+ # 로딩 중이거나, 페이지가 완전히 로딩되지 않더라도 탭을 닫기
357
+ @driver.close
358
+ rescue Selenium::WebDriver::Error::WebDriverError => e
359
+ puts "Failed to close tab: #{e.message}"
360
+ end
361
+ end
362
+ return 0
363
+ end
346
364
 
347
365
  else
348
366
  # @driver.switch_to.default_content
@@ -354,11 +372,18 @@ class Naver
354
372
  wait.until { @driver.find_element(:xpath, '//*[@class="MyView-module__btn_logout___bsTOJ"]') }
355
373
 
356
374
  rescue => e
357
- puts '-[√] 로그인 실패!!.......'.red
358
- puts e
359
- @driver.close
375
+ puts '-[√] 로그인 실패.......'.red
376
+ @driver.window_handles.each do |handle|
377
+ @driver.switch_to.window(handle)
378
+ begin
379
+ # 로딩 중이거나, 페이지가 완전히 로딩되지 않더라도 탭을 닫기
380
+ @driver.close
381
+ rescue Selenium::WebDriver::Error::WebDriverError => e
382
+ puts "Failed to close tab: #{e.message}"
383
+ end
384
+ end
360
385
  return 0
361
- end
386
+ end
362
387
  end
363
388
 
364
389
  def create_id
@@ -977,10 +1002,27 @@ end
977
1002
 
978
1003
 
979
1004
 
980
-
981
- sleep(1)
982
- @driver.find_element(:xpath, '//*[@id="app"]/div/div/section/div/div[2]/div[1]/div[1]/div[1]/div[2]/div/textarea').send_keys(title)
983
-
1005
+
1006
+ begin
1007
+ wait = Selenium::WebDriver::Wait.new(:timeout => 10)
1008
+ #요소가 나타날 때까지 60초 동안 기다립니다.
1009
+ wait.until { @driver.find_element(:xpath, '//*[@id="app"]/div/div/section/div/div[2]/div[1]/div[1]/div[1]/div[2]/div/textarea') }
1010
+ sleep(1)
1011
+ @driver.find_element(:xpath, '//*[@id="app"]/div/div/section/div/div[2]/div[1]/div[1]/div[1]/div[2]/div/textarea').send_keys(title)
1012
+ sleep(1)
1013
+ rescue => e
1014
+ puts '-[√] 제목 입력 필드 로딩 지연 접속 실패.......'.red
1015
+ @driver.window_handles.each do |handle|
1016
+ @driver.switch_to.window(handle)
1017
+ begin
1018
+ # 로딩 중이거나, 페이지가 완전히 로딩되지 않더라도 탭을 닫기
1019
+ @driver.close
1020
+ rescue Selenium::WebDriver::Error::WebDriverError => e
1021
+ puts "Failed to close tab: #{e.message}"
1022
+ end
1023
+ end
1024
+ return 0
1025
+ end
984
1026
 
985
1027
 
986
1028
 
@@ -988,14 +1030,27 @@ end
988
1030
  sleep(1)
989
1031
  @driver.action.send_keys(:page_down).perform
990
1032
  sleep(2)
991
-
992
-
993
-
994
-
1033
+
995
1034
  sleep(2)
996
- @driver.find_element(:xpath, '//*[@id="'+page_id+'"]/div[1]/div/header/div[2]/ul/li[5]/button').click()
997
- sleep(1)
998
- @driver.find_element(:xpath, '//*[@id="'+page_id+'"]/div[1]/div/header/div[2]/ul/li[5]/button').click()
1035
+ begin
1036
+ wait = Selenium::WebDriver::Wait.new(:timeout => 10)
1037
+ #요소가 나타날 때까지 60초 동안 기다립니다.
1038
+ wait.until { @driver.find_element(:xpath, '//li[@class="se-toolbar-item se-toolbar-item-bold"]/button[@data-type="toggle" and @data-name="bold"]') }
1039
+ @driver.find_element(:xpath, '//*[@id="'+page_id+'"]/div[1]/div/header/div[2]/ul/li[5]/button').click()
1040
+ @driver.find_element(:xpath, '//*[@id="'+page_id+'"]/div[1]/div/header/div[2]/ul/li[5]/button').click()
1041
+ rescue => e
1042
+ puts '-[√] 글 입력 필드 로딩 지연 접속 실패.......'.red
1043
+ @driver.window_handles.each do |handle|
1044
+ @driver.switch_to.window(handle)
1045
+ begin
1046
+ # 로딩 중이거나, 페이지가 완전히 로딩되지 않더라도 탭을 닫기
1047
+ @driver.close
1048
+ rescue Selenium::WebDriver::Error::WebDriverError => e
1049
+ puts "Failed to close tab: #{e.message}"
1050
+ end
1051
+ end
1052
+ return 0
1053
+ end
999
1054
  sleep(2)
1000
1055
  @driver.action.key_down(:control).key_down('a').key_up('a').key_up(:control).perform
1001
1056
  sleep(1)
@@ -1907,7 +1962,15 @@ end
1907
1962
 
1908
1963
 
1909
1964
  begin
1910
- @driver.close
1965
+ @driver.window_handles.each do |handle|
1966
+ @driver.switch_to.window(handle)
1967
+ begin
1968
+ # 로딩 중이거나, 페이지가 완전히 로딩되지 않더라도 탭을 닫기
1969
+ @driver.close
1970
+ rescue Selenium::WebDriver::Error::WebDriverError => e
1971
+ puts "Failed to close tab: #{e.message}"
1972
+ end
1973
+ end
1911
1974
  rescue
1912
1975
 
1913
1976
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cafe_buy_duo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.33
4
+ version: 0.0.35
5
5
  platform: ruby
6
6
  authors:
7
7
  - zon