posting_zon 0.0.67 → 0.0.71

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/posting_zon.rb +1400 -911
  3. metadata +2 -2
data/lib/posting_zon.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  require 'glimmer-dsl-libui'
2
2
  require 'selenium-webdriver'
3
- # require 'webdrivers'
3
+ require 'webdrivers'
4
4
  require 'iconv'
5
5
  require 'nokogiri'
6
6
  require 'open-uri'
@@ -27,42 +27,71 @@ using Rainbow
27
27
 
28
28
 
29
29
  class Naver
30
-
31
- def chrome_start(proxy)
30
+ def initialize
31
+
32
+ begin
33
+ # webdrivers가 사용자의 Chrome 버전에 맞는 chromedriver 다운로드 시도
34
+
35
+ # Webdrivers가 드라이버를 다운로드할 경로를 설정
36
+ Webdrivers.cache_time = 86_400 # 하루로 설정 (기본값: 86_400초)
37
+ Webdrivers.install_dir = "./" # 크롬드라이버를 수동으로 설치할 경로를 설정
38
+ # 크롬드라이버 자동 업데이트 시도
39
+ Webdrivers::Chromedriver.update
40
+ puts "chromedriver 자동 다운로드 성공"
41
+ rescue => e
42
+ puts "chromedriver 자동 다운로드 실패: #{e.message}"
43
+ puts "폴더내 크롬드라이버를 사용합니다."
44
+ puts "크롬드라이버가 오래된 경우 오류 발생될 수 있으며, 만일 오류 발생시 아래 지침을 따라주세요."
45
+ puts "1.크롬 업데이트 2.프로그램 폴더 내부에 ★tip★-시작시-크롬창이....파일을 열어 드라이버를 교체하세요."
46
+ chromedriver_path = './chromedriver.exe' # 수동 경로를 인스턴스 변수로 설정
47
+ Selenium::WebDriver::Chrome::Service.driver_path = chromedriver_path
48
+ end
49
+
50
+ end
51
+
52
+
53
+ def chrome_setup(proxy, board_cookie_dir = "C:/board_cookie")
54
+ board_cookie_dir = "C:/board_cookie"
55
+ FileUtils.mkdir_p(board_cookie_dir) unless File.exist?(board_cookie_dir)
56
+
57
+ if proxy == ''
58
+ system(%{"C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe" --window-position=0,0 --remote-debugging-port=9222 --user-data-dir=C:/board_cookie --no-first-run --no-default-browser-check --disable-sync https://chromewebstore.google.com/detail/captcha-solver-auto-recog/ifibfemgeogfhoebkmokieepdoobkbpo?hl=ko})
59
+ else
60
+ system(%{"C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe" --window-position=0,0 --remote-debugging-port=9222 --user-data-dir=C:/board_cookie --proxy-server=#{proxy.to_s.force_encoding('utf-8').to_s} --no-first-run --no-default-browser-check --disable-sync https://chromewebstore.google.com/detail/captcha-solver-auto-recog/ifibfemgeogfhoebkmokieepdoobkbpo?hl=ko})
61
+ end
62
+ end
63
+
64
+
65
+
66
+ def chrome_start(proxy, board_cookie_dir = "C:/board_cookie")
67
+ board_cookie_dir = "C:/board_cookie"
68
+ FileUtils.mkdir_p(board_cookie_dir) unless File.exist?(board_cookie_dir)
32
69
  if proxy == ''
33
70
  begin
34
-
35
- Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
36
71
  options = Selenium::WebDriver::Chrome::Options.new
37
- options.add_extension('./crx/free.crx')
38
- options.add_extension('./crx/app.crx')
72
+ options.add_argument('--no-first-run') # 자동 실행 시 나타나는 "첫 실행" 화면 방지
73
+ #options.add_argument('--disable-extensions') # 확장 프로그램 초기화 화면 방지
74
+ options.add_argument('--disable-sync') # Chrome 동기화 비활성화
75
+ options.add_argument('--disable-popup-blocking') # 팝업 방지 (로그인 창이 뜨는 경우 대비)
76
+ options.add_argument('--no-default-browser-check')
39
77
  options.page_load_strategy = :normal
40
- options.timeouts = { page_load: 20_000 }
78
+ options.timeouts = {page_load: 30_000}
79
+ options.page_load_strategy = 'none'
80
+ options.add_argument('--disable-blink-features=AutomationControlled') #자동화된 환경에서 실행되는 것을 감지하는 기능을 비활성화합니다.
41
81
  options.add_argument('--disable-gpu')
42
- options.add_argument('--start-maximized')
43
- options.add_argument('user-agent=Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.6723.59 Safari/537.36') # user-agent 위조
44
- options.add_argument('--disable-blink-features=AutomationControlled') # 자동화된 환경에서 실행되는 것을 감지하는 기능 비활성화
45
- options.add_argument('--disable-web-security') # 보안 비활성화
46
- options.add_argument('--allow-running-insecure-content') # HTTPS 사이트에서 HTTP 컨텐츠 실행 허용
47
- options.add_argument('--no-sandbox') # 샌드박스 모드 비활성화
48
- options.exclude_switches = ['enable-automation'] # 자동화 테스트 제거
49
- options.add_preference("profile.password_manager_enabled", false) # 비밀번호 관리자 비활성화
50
- options.add_preference("credentials_enable_service", false) # 비밀번호 저장 기능 비활성화
51
- options.add_preference("profile.default_content_setting_values.notifications", 2) # 알림 차단
52
- options.add_argument("--disable-save-password-bubble") # 비밀번호 저장 팝업 차단
53
- options.add_argument('--disable-software-rasterizer') # 소프트웨어 렌더링 비활성화
54
- options.add_argument('--remote-debugging-port=9222') # 디버깅 포트 설정
55
- options.add_argument("--disable-logging")
56
- options.add_argument("--silent") # 로그를 최소화 (최소한의 경고만)
57
- options.add_argument("--log-level=3") # LogLevel: 3 = ERROR
58
-
82
+ options.add_argument('--remote-debugging-port=9222')
83
+ options.add_argument('user-data-dir=C:/board_cookie')
84
+
85
+ options.add_argument('--disable-save-password-bubble') # 비밀번호 저장 팝업 비활성화
86
+ options.add_argument('--disable-password-manager') # 비밀번호 관리 비활성화
87
+
88
+
59
89
  # 'capabilities'과 'options' 배열로 설정
60
90
  capabilities = Selenium::WebDriver::Remote::Capabilities.chrome
61
91
  capabilities["goog:chromeOptions"] = options.as_json
62
92
 
63
93
  # Selenium 4에서는 'capabilities'만 사용하는 방식
64
94
  @driver = Selenium::WebDriver.for(:chrome, capabilities: [capabilities, options])
65
-
66
95
 
67
96
  @driver.execute_script("Object.defineProperty(navigator, 'webdriver', {get: function(){ return false; }});") # 셀레니움 감지 방지
68
97
 
@@ -71,35 +100,23 @@ class Naver
71
100
  end
72
101
  else
73
102
  begin
74
- puts '프록시 연결합니다.......'.magenta
75
- puts '프록시 연결시 프록시 서버에 의해 인터넷속도가 낮아질수있어.......'.magenta
76
- puts '원활한 작업이 되지않을수있습니다.......'.magenta
77
103
  Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
78
104
  options = Selenium::WebDriver::Chrome::Options.new
105
+ options.add_argument('--no-first-run') # 자동 실행 시 나타나는 "첫 실행" 화면 방지
106
+ options.add_argument('--disable-extensions') # 확장 프로그램 초기화 화면 방지
107
+ options.add_argument('--disable-sync') # Chrome 동기화 비활성화
108
+ options.add_argument('--disable-popup-blocking') # 팝업 방지 (로그인 창이 뜨는 경우 대비)
109
+ options.add_argument('--no-default-browser-check')
79
110
  options.add_argument '--proxy-server='+proxy.to_s.force_encoding('utf-8').to_s
80
- options.add_extension('./crx/free.crx')
81
- options.add_extension('./crx/app.crx')
82
111
  options.page_load_strategy = :normal
83
- options.timeouts = { page_load: 20_000 }
112
+ options.timeouts = {page_load: 30_000}
113
+ options.page_load_strategy = 'none'
114
+ options.add_argument('--disable-blink-features=AutomationControlled') #자동화된 환경에서 실행되는 것을 감지하는 기능을 비활성화합니다.
84
115
  options.add_argument('--disable-gpu')
85
- options.add_argument('--start-maximized')
86
- options.add_argument('user-agent=Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.6723.59 Safari/537.36') # user-agent 위조
87
- options.add_argument('--disable-blink-features=AutomationControlled') # 자동화된 환경에서 실행되는 것을 감지하는 기능 비활성화
88
- options.add_argument('--disable-web-security') # 웹 보안 비활성화
89
- options.add_argument('--allow-running-insecure-content') # HTTPS 사이트에서 HTTP 컨텐츠 실행 허용
90
- options.add_argument('--no-sandbox') # 샌드박스 모드 비활성화
91
- options.exclude_switches = ['enable-automation'] # 자동화 테스트 제거
92
- options.add_preference("profile.password_manager_enabled", false) # 비밀번호 관리자 비활성화
93
- options.add_preference("credentials_enable_service", false) # 비밀번호 저장 기능 비활성화
94
- options.add_preference("profile.default_content_setting_values.notifications", 2) # 알림 차단
95
- options.add_argument("--disable-save-password-bubble") # 비밀번호 저장 팝업 차단
96
- options.add_argument('--disable-software-rasterizer') # 소프트웨어 렌더링 비활성화
97
- options.add_argument('--remote-debugging-port=9222') # 디버깅 포트 설정
98
- options.add_argument("--disable-logging")
99
- options.add_argument("--silent") # 로그를 최소화 (최소한의 경고만)
100
- options.add_argument("--log-level=3") # LogLevel: 3 = ERROR
101
-
102
-
116
+ options.add_argument('--remote-debugging-port=9222')
117
+ options.add_argument('user-data-dir=C:/board_cookie')
118
+
119
+
103
120
  # 'capabilities'과 'options' 배열로 설정
104
121
  capabilities = Selenium::WebDriver::Remote::Capabilities.chrome
105
122
  capabilities["goog:chromeOptions"] = options.as_json
@@ -108,35 +125,27 @@ class Naver
108
125
  @driver = Selenium::WebDriver.for(:chrome, capabilities: [capabilities, options])
109
126
 
110
127
  @driver.execute_script("Object.defineProperty(navigator, 'webdriver', {get: function(){ return false; }});") # 셀레니움 감지 방지
111
-
112
128
  rescue => e
113
129
  puts e
114
130
  puts 'proxy error...'
115
131
  begin
116
132
  Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
117
133
  options = Selenium::WebDriver::Chrome::Options.new
118
- options.add_extension('./crx/free.crx')
119
- options.add_extension('./crx/app.crx')
134
+ options.add_argument('--no-first-run') # 자동 실행 시 나타나는 "첫 실행" 화면 방지
135
+ options.add_argument('--disable-extensions') # 확장 프로그램 초기화 화면 방지
136
+ options.add_argument('--disable-sync') # Chrome 동기화 비활성화
137
+ options.add_argument('--disable-popup-blocking') # 팝업 방지 (로그인 창이 뜨는 경우 대비)
138
+ options.add_argument('--no-default-browser-check')
120
139
  options.page_load_strategy = :normal
121
- options.timeouts = { page_load: 20_000 }
140
+ options.timeouts = {page_load: 30_000}
141
+ options.page_load_strategy = 'none'
142
+ options.add_argument('--disable-blink-features=AutomationControlled') #자동화된 환경에서 실행되는 것을 감지하는 기능을 비활성화합니다.
122
143
  options.add_argument('--disable-gpu')
123
- options.add_argument('--start-maximized')
124
- options.add_argument('user-agent=Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.6723.59 Safari/537.36') # user-agent 위조
125
- options.add_argument('--disable-blink-features=AutomationControlled') # 자동화된 환경에서 실행되는 것을 감지하는 기능 비활성화
126
- options.add_argument('--disable-web-security') # 웹 보안 비활성화
127
- options.add_argument('--allow-running-insecure-content') # HTTPS 사이트에서 HTTP 컨텐츠 실행 허용
128
- options.add_argument('--no-sandbox') # 샌드박스 모드 비활성화
129
- options.exclude_switches = ['enable-automation'] # 자동화 테스트 제거
130
- options.add_preference("profile.password_manager_enabled", false) # 비밀번호 관리자 비활성화
131
- options.add_preference("credentials_enable_service", false) # 비밀번호 저장 기능 비활성화
132
- options.add_preference("profile.default_content_setting_values.notifications", 2) # 알림 차단
133
- options.add_argument("--disable-save-password-bubble") # 비밀번호 저장 팝업 차단
134
- options.add_argument('--disable-software-rasterizer') # 소프트웨어 렌더링 비활성화
135
- options.add_argument('--remote-debugging-port=9222') # 디버깅 포트 설정
136
- options.add_argument("--disable-logging")
137
- options.add_argument("--silent") # 로그를 최소화 (최소한의 경고만)
138
- options.add_argument("--log-level=3") # LogLevel: 3 = ERROR
139
-
144
+ options.add_argument('--remote-debugging-port=9222')
145
+ options.add_argument('user-data-dir=C:/board_cookie')
146
+
147
+
148
+
140
149
  # 'capabilities'과 'options' 배열로 설정
141
150
  capabilities = Selenium::WebDriver::Remote::Capabilities.chrome
142
151
  capabilities["goog:chromeOptions"] = options.as_json
@@ -151,51 +160,394 @@ class Naver
151
160
  end
152
161
  end
153
162
  end
154
-
155
-
156
- def login(proxy)
157
- chrome_start(proxy)
158
163
 
159
- @driver.get('about:blank')
160
- sleep(2)
164
+ def login(proxy, captcha_key, board_cookie_dir = "C:/board_cookie")
165
+ @captcha_key = captcha_key
166
+ @board_cookie_dir = "C:/board_cookie"
167
+ current_dir = File.dirname(__FILE__)
168
+ board_cookie_dir = "C:/board_cookie"
169
+ FileUtils.mkdir_p(board_cookie_dir) unless File.exist?(board_cookie_dir)
170
+
171
+ unless File.exist?(board_cookie_dir)
172
+ driverfile_src = File.join(current_dir, 'driverfile')
173
+ if Dir.exist?(driverfile_src)
174
+ FileUtils.cp_r(driverfile_src, board_cookie_dir)
175
+ end
176
+ end
161
177
 
178
+ # 새로운 스레드 생성 및 실행
179
+ Thread.new { chrome_setup(proxy, board_cookie_dir) }
180
+
181
+ # 충분한 대기 시간을 두고 실행
182
+ sleep(1)
183
+
184
+ chrome_start(proxy, board_cookie_dir)
185
+
162
186
  # 열린 모든 탭 핸들 확인
163
187
  all_windows = @driver.window_handles
164
- puts "현재 열려 있는 탭 수: #{all_windows.size}" # 열린 탭 수 출력
165
-
166
- # 탭만 남기고 나머지 탭 닫기
188
+ #puts "현재 열려 있는 탭 수: #{all_windows.size}" # 열린 탭 수 출력
189
+
190
+ # 원하는 URL
191
+ target_url = "https://chromewebstore.google.com/detail/captcha-solver-auto-recog/ifibfemgeogfhoebkmokieepdoobkbpo?hl=ko"
192
+
193
+ # 각 탭을 순회하면서
167
194
  all_windows.each do |window|
168
- @driver.switch_to.window(window)
169
- current_url = @driver.current_url
170
- puts "탭 URL: #{current_url}" # 각 탭 URL 출력
171
-
172
- # 'chrome-extension://'로 시작하는 확장 프로그램 탭을 제외하고 닫기
173
- if current_url.start_with?('chrome-extension://')
174
- puts "확장 프로그램 탭을 닫지 않음: #{current_url}"
175
- else
176
- @driver.close # 등 다른 탭은 닫기
177
- puts " 또는 확장 프로그램이 아닌 탭을 닫았습니다."
178
- end
195
+ @driver.switch_to.window(window)
196
+ current_url = @driver.current_url
197
+ #puts "탭 URL: #{current_url}" # 각 탭 URL 출력
198
+
199
+ # 원하는 URL이 아니면 탭을 닫기
200
+ if current_url != target_url
201
+ begin
202
+ @driver.close # 다른 탭을 닫기
203
+ rescue Selenium::WebDriver::Error::WebDriverError => e
204
+ #puts "탭을 닫는 오류 발생: #{e.message}"
205
+ end
179
206
  end
180
-
181
- # 빈 탭을 남긴 후, 빈 탭으로 다시 전환
207
+ end
208
+
209
+ # 남아 있는 탭으로 전환
182
210
  all_windows = @driver.window_handles # 남은 탭 리스트 갱신
183
- if all_windows.size == 1
184
- @driver.switch_to.window(all_windows.first) # 남은 탭으로 전환
185
- puts "빈 탭으로 전환됨."
211
+ if all_windows.size > 0
212
+ @driver.switch_to.window(all_windows.first) # 남아 있는 첫 번째 탭으로 전환
186
213
  else
187
- puts " 탭을 찾을 수 없습니다."
214
+ #puts "남은 탭이 없습니다."
188
215
  end
189
-
190
- sleep(1)
191
-
192
- # 빈 탭에서 원하는 작업을 진행하거나, 옵션 페이지로 이동
193
- @driver.get('chrome-extension://ifibfemgeogfhoebkmokieepdoobkbpo/options/options.html')
216
+
217
+
218
+
219
+ @driver.manage.window.maximize
194
220
  sleep(1)
195
- end
196
-
197
-
198
-
221
+ begin
222
+ wait = Selenium::WebDriver::Wait.new(:timeout => 3)
223
+ wait.until { @driver.find_element(xpath: '//section[@class="lwrbTd"]//button[@jsname="ajZLRd"]') } #추가 되어 있음
224
+ check_cookie_login = 1
225
+ puts'[Step.01] CAPTCHA 세션 및 브라우저 설정 완료 상태 확인!!.......'.yellow
226
+ rescue
227
+ begin
228
+ wait = Selenium::WebDriver::Wait.new(:timeout => 3)
229
+ wait.until { @driver.find_element(xpath: '//section[@class="lwrbTd"]//button[@jsname="wQO0od"]') } #추가 안되어 있음
230
+ sleep(1.5)
231
+ @driver.find_element(xpath: '//section[@class="lwrbTd"]//button[@jsname="wQO0od"]').click
232
+ puts'[Step.01] CAPTCHA 세션 연결 없음!! 브라우저 필요 설정 미 완료 상태!!.......'.yellow
233
+ puts'[Step.02] CAPTCHA 세션 연결 및 브라우저 필요 설정 진행 시작!!.......'.yellow
234
+ sleep(1.5)
235
+ mouse_move_percentage(0.3,0.02)
236
+ sleep(0.5)
237
+ left_click
238
+ sleep(1)
239
+ key_stroke('tab')
240
+ sleep(0.5)
241
+ key_stroke('enter')
242
+ check_cookie_login = 0
243
+ sleep(1)
244
+ rescue
245
+ @driver.quit
246
+ return 0
247
+ end
248
+ end
249
+
250
+ if check_cookie_login == 0
251
+ sleep(10)
252
+ begin
253
+
254
+ begin
255
+ # 열린 모든 탭 핸들 확인
256
+ all_windows = @driver.window_handles
257
+ puts "현재 열려 있는 탭 수: #{all_windows.size}" # 열린 탭 수 출력
258
+
259
+ # 각 탭을 순회하면서
260
+ all_windows.each do |window|
261
+ @driver.switch_to.window(window)
262
+ current_url = @driver.current_url
263
+ puts "탭 URL: #{current_url}" # 각 탭 URL 출력
264
+
265
+ # 확장 프로그램 탭인지 확인
266
+ if current_url.include?('chrome-extension://ifibfemgeogfhoebkmokieepdoobkbpo/options/options.html')
267
+ begin
268
+ @driver.close # 확장 프로그램 탭을 닫기
269
+
270
+ rescue Selenium::WebDriver::Error::WebDriverError => e
271
+ end
272
+ else
273
+ end
274
+ end
275
+
276
+ # 남아 있는 탭으로 전환
277
+ all_windows = @driver.window_handles # 남은 탭 리스트 갱신
278
+ if all_windows.size > 0
279
+ @driver.switch_to.window(all_windows.first) # 남아 있는 첫 번째 탭으로 전환
280
+ else
281
+ end
282
+
283
+ sleep(1)
284
+
285
+ rescue => e
286
+ @driver.quit if @driver
287
+ end
288
+
289
+
290
+
291
+
292
+
293
+ # 빈 탭에서 원하는 작업을 진행하거나, 옵션 페이지로 이동
294
+ @driver.get('chrome-extension://ifibfemgeogfhoebkmokieepdoobkbpo/options/options.html')
295
+ sleep(1)
296
+
297
+
298
+
299
+
300
+
301
+ begin
302
+ puts '-[√] 캡챠 연결 설정 1차 시도.......'.green
303
+ # 요소 찾기 타임아웃을 10초로 설정
304
+ wait = Selenium::WebDriver::Wait.new(:timeout => 5)
305
+ #요소가 나타날 때까지 60초 동안 기다립니다.
306
+ wait.until { @driver.find_element(:xpath, '/html/body/div/div[1]/table/tbody/tr[1]/td[2]/input') }
307
+ @driver.find_element(:xpath, '/html/body/div/div[1]/table/tbody/tr[1]/td[2]/input').click
308
+ sleep(1)
309
+ Clipboard.copy(captcha_key)
310
+ @driver.action.key_down(:control).send_keys('v').key_up(:control).perform
311
+ sleep(1)
312
+ @driver.find_element(:xpath, '//*[@id="connect"]').click
313
+ sleep(1)
314
+
315
+ begin
316
+ wait = Selenium::WebDriver::Wait.new(:timeout => 10)
317
+ wait.until do
318
+ begin
319
+ alert = @driver.switch_to.alert
320
+ alert.accept
321
+ sleep(1)
322
+ true
323
+ rescue Selenium::WebDriver::Error::NoSuchAlertError
324
+ false
325
+ end
326
+ end
327
+ rescue Selenium::WebDriver::Error::TimeoutError
328
+ puts "alert이 없으므로 버튼 클릭"
329
+ @driver.find_element(:xpath, '//*[@id="connect"]').click
330
+ begin
331
+ wait = Selenium::WebDriver::Wait.new(:timeout => 10)
332
+ wait.until do
333
+ begin
334
+ alert = @driver.switch_to.alert
335
+ alert.accept
336
+ sleep(1)
337
+ true
338
+ rescue Selenium::WebDriver::Error::NoSuchAlertError
339
+ false
340
+ end
341
+ end
342
+ puts "두 번째 alert 처리 완료"
343
+ rescue Selenium::WebDriver::Error::TimeoutError
344
+ puts "두 번째 alert이 10초 내에 나타나지 않음. Chrome 종료."
345
+ system('taskkill /F /IM chrome.exe')
346
+ @driver.quit if @driver
347
+ end
348
+ end
349
+ puts '-[√] 브라우저 필요 설정 1차 시도.......'.green
350
+ @driver.get('chrome://settings/security')
351
+ sleep(2)
352
+ mouse_move_percentage(0.3,0.02)
353
+ sleep(0.5)
354
+ left_click
355
+ sleep(1)
356
+ # 루비에서 'tab' 키를 0.5초마다 7번 누르기
357
+ 6.times do
358
+ key_stroke('tab') # 'tab' 키를 입력
359
+ sleep(0.5) # 0.5초 대기
360
+ end
361
+ key_stroke('enter')
362
+ sleep(1)
363
+
364
+ @driver.get('chrome://password-manager/settings')
365
+ sleep(2)
366
+ mouse_move_percentage(0.3,0.02)
367
+ sleep(0.5)
368
+ left_click
369
+ sleep(1)
370
+ # 루비에서 'tab' 키를 0.5초마다 7번 누르기
371
+ 3.times do
372
+ key_stroke('tab') # 'tab' 키를 입력
373
+ sleep(0.5) # 0.5초 대기
374
+ end
375
+ key_stroke('enter')
376
+ sleep(1)
377
+
378
+ rescue
379
+ begin
380
+ puts '-[√] 캡챠 연결 설정 2차 시도.......'.green
381
+ sleep(1)
382
+ #@driver.switch_to.window(@driver.window_handles[0])
383
+
384
+
385
+ # 요소 찾기 타임아웃을 10초로 설정
386
+ wait = Selenium::WebDriver::Wait.new(:timeout => 5)
387
+ #요소가 나타날 때까지 60초 동안 기다립니다.
388
+ wait.until { @driver.find_element(:xpath, '//*[@name="apiKey"]') }
389
+ @driver.find_element(:xpath, '//*[@name="apiKey"]').click
390
+ sleep(1)
391
+ begin
392
+ @driver.find_element(:xpath, '//*[@name="apiKey"]').click
393
+ rescue
394
+
395
+ puts '-[√] 로딩 및 코드인식 실패등 기타 이유로 다음 게시판 작업으로 이동합니다.......'.red
396
+ puts '-[√] 다음 작업 준비로 약 1초~60초 내외 시간이 소요됩니다.......'.red
397
+
398
+ end
399
+
400
+ Clipboard.copy(captcha_key)
401
+ @driver.action.key_down(:control).send_keys('v').key_up(:control).perform
402
+ sleep(1)
403
+ begin
404
+ @driver.find_element(:xpath, '//*[@class="default-btn"]').click
405
+ sleep(1)
406
+
407
+ begin
408
+ wait = Selenium::WebDriver::Wait.new(:timeout => 10)
409
+ wait.until do
410
+ begin
411
+ alert = @driver.switch_to.alert
412
+ alert.accept
413
+ sleep(1)
414
+ true
415
+ rescue Selenium::WebDriver::Error::NoSuchAlertError
416
+ false
417
+ end
418
+ end
419
+ rescue Selenium::WebDriver::Error::TimeoutError
420
+ puts "alert이 없으므로 버튼 클릭"
421
+ @driver.find_element(:xpath, '//*[@class="default-btn"]').click
422
+ begin
423
+ wait = Selenium::WebDriver::Wait.new(:timeout => 10)
424
+ wait.until do
425
+ begin
426
+ alert = @driver.switch_to.alert
427
+ alert.accept
428
+ sleep(1)
429
+ true
430
+ rescue Selenium::WebDriver::Error::NoSuchAlertError
431
+ false
432
+ end
433
+ end
434
+ puts "두 번째 alert 처리 완료"
435
+ rescue Selenium::WebDriver::Error::TimeoutError
436
+ puts "두 번째 alert이 10초 내에 나타나지 않음. Chrome 종료."
437
+ system('taskkill /F /IM chrome.exe')
438
+ @driver.quit if @driver
439
+ end
440
+ end
441
+
442
+ rescue => e
443
+ @driver.window_handles.each do |handle|
444
+ @driver.switch_to.window(handle)
445
+ begin
446
+ # 로딩 중이거나, 페이지가 완전히 로딩되지 않더라도 탭을 닫기
447
+ @driver.close
448
+ rescue Selenium::WebDriver::Error::WebDriverError => e
449
+ puts "크롬 브라우저 종료: #{e.message}"
450
+ end
451
+ end
452
+ return 0
453
+ @driver.quit
454
+ end
455
+ puts '-[√] 브라우저 필요 설정 2차 시도.......'.green
456
+ @driver.get('chrome://settings/security')
457
+ sleep(2)
458
+ mouse_move_percentage(0.3,0.02)
459
+ sleep(0.5)
460
+ left_click
461
+ sleep(1)
462
+ # 루비에서 'tab' 키를 0.5초마다 7번 누르기
463
+ 6.times do
464
+ key_stroke('tab') # 'tab' 키를 입력
465
+ sleep(0.5) # 0.5초 대기
466
+ end
467
+ key_stroke('enter')
468
+ sleep(1)
469
+
470
+ @driver.get('chrome://password-manager/settings')
471
+ sleep(2)
472
+ mouse_move_percentage(0.3,0.02)
473
+ sleep(0.5)
474
+ left_click
475
+ sleep(1)
476
+ # 루비에서 'tab' 키를 0.5초마다 7번 누르기
477
+ 3.times do
478
+ key_stroke('tab') # 'tab' 키를 입력
479
+ sleep(0.5) # 0.5초 대기
480
+ end
481
+ key_stroke('enter')
482
+ sleep(1)
483
+
484
+ rescue => e
485
+ puts '-[√] 로딩 및 코드인식 실패등 기타 이유로 다음 게시판 작업으로 이동합니다.......'.red
486
+ puts '-[√] 다음 작업 준비로 약 1초~60초 내외 시간이 소요됩니다.......'.red
487
+ @driver.window_handles.each do |handle|
488
+ @driver.switch_to.window(handle)
489
+ begin
490
+ # 로딩 중이거나, 페이지가 완전히 로딩되지 않더라도 탭을 닫기
491
+ @driver.close
492
+ rescue Selenium::WebDriver::Error::WebDriverError => e
493
+ puts "크롬 브라우저 종료: #{e.message}"
494
+ end
495
+ end
496
+ return 0
497
+ @driver.quit
498
+ end
499
+
500
+ end
501
+
502
+ rescue => e
503
+ puts '-[√] 로딩 지연 접속 실패.......'.red
504
+ @driver.window_handles.each do |handle|
505
+ @driver.switch_to.window(handle)
506
+ begin
507
+ # 로딩 중이거나, 페이지가 완전히 로딩되지 않더라도 탭을 닫기
508
+ @driver.close
509
+ rescue Selenium::WebDriver::Error::WebDriverError => e
510
+ puts "Failed to close tab: #{e.message}"
511
+ end
512
+ end
513
+ @driver.quit
514
+ return 0
515
+ end
516
+
517
+ else
518
+ # @driver.switch_to.default_content
519
+ end
520
+
521
+ begin
522
+
523
+
524
+
525
+ @driver.get('https://chromewebstore.google.com/detail/captcha-solver-auto-recog/ifibfemgeogfhoebkmokieepdoobkbpo?hl=ko')
526
+
527
+ wait = Selenium::WebDriver::Wait.new(:timeout => 5)
528
+ #요소가 나타날 때까지 3초 동안 기다립니다.
529
+ wait.until { @driver.find_element(xpath: '//section[@class="lwrbTd"]//button[@jsname="ajZLRd"]') } #추가 되어 있음
530
+
531
+
532
+
533
+ rescue => e
534
+ puts '-[√] 로그인 실패.......'.red
535
+ @driver.window_handles.each do |handle|
536
+ @driver.switch_to.window(handle)
537
+ begin
538
+ # 로딩 중이거나, 페이지가 완전히 로딩되지 않더라도 탭을 닫기
539
+ @driver.close
540
+ rescue Selenium::WebDriver::Error::WebDriverError => e
541
+ puts "Failed to close tab: #{e.message}"
542
+ end
543
+ end
544
+ @driver.quit
545
+ return 0
546
+ end
547
+ end
548
+
549
+
550
+
199
551
 
200
552
 
201
553
  def update(user_id, user_pw, title, content, option, post_url, signup_url, login_url, cc_check_url, image_url_cheng, img_link2, category, more_txt1, more_txt2, more_txt3, more_txt4, captcha_key, keyword)
@@ -218,210 +570,81 @@ def update(user_id, user_pw, title, content, option, post_url, signup_url, login
218
570
 
219
571
 
220
572
  ####################탭나누기 수정중######################################
221
- begin
222
- puts '-[√] 투 캡챠 api 입력 시도 1.......'.green
223
-
224
- #@driver.switch_to.window(@driver.window_handles[0])
225
-
226
573
 
227
- # 요소 찾기 타임아웃을 10초로 설정
228
- wait = Selenium::WebDriver::Wait.new(:timeout => 5)
229
- #요소가 나타날 때까지 60초 동안 기다립니다.
230
- wait.until { @driver.find_element(:xpath, '/html/body/div/div[1]/table/tbody/tr[1]/td[2]/input') }
231
- @driver.find_element(:xpath, '/html/body/div/div[1]/table/tbody/tr[1]/td[2]/input').click
232
- sleep(1)
233
- Clipboard.copy(captcha_key)
234
- @driver.action.key_down(:control).send_keys('v').key_up(:control).perform
235
- sleep(1)
236
- @driver.find_element(:xpath, '/html/body/div/div[1]/table/tbody/tr[1]/td[3]/button').click
237
- sleep(1)
238
-
239
- begin
240
- wait = Selenium::WebDriver::Wait.new(:timeout => 10)
241
- wait.until do
242
- begin
243
- alert = @driver.switch_to.alert
244
- alert.accept
245
- true
246
- rescue Selenium::WebDriver::Error::NoSuchAlertError
247
- false
248
- end
249
- end
250
- rescue Selenium::WebDriver::Error::TimeoutError
251
- puts "alert이 없으므로 버튼 클릭"
252
- @driver.find_element(:xpath, '/html/body/div/div[1]/table/tbody/tr[1]/td[3]/button').click
253
- begin
254
- wait = Selenium::WebDriver::Wait.new(:timeout => 10)
255
- wait.until do
256
- begin
257
- alert = @driver.switch_to.alert
258
- alert.accept
259
- true
260
- rescue Selenium::WebDriver::Error::NoSuchAlertError
261
- false
262
- end
263
- end
264
- puts "두 번째 alert 처리 완료"
265
- rescue Selenium::WebDriver::Error::TimeoutError
266
- puts "두 번째 alert이 10초 내에 나타나지 않음. Chrome 종료."
267
- system('taskkill /F /IM chrome.exe')
268
- @driver.quit if @driver
269
- end
270
- end
271
-
272
574
 
273
- rescue
274
- begin
275
- puts '-[√] 투 캡챠 api 입력 시도 2.......'.green
276
- sleep(1)
277
- #@driver.switch_to.window(@driver.window_handles[0])
575
+
576
+ signup_url = option['signup_url'].to_s
278
577
 
279
578
 
280
- # 요소 찾기 타임아웃을 10초로 설정
281
- wait = Selenium::WebDriver::Wait.new(:timeout => 5)
282
- #요소가 나타날 때까지 60초 동안 기다립니다.
283
- wait.until { @driver.find_element(:xpath, '//*[@name="apiKey"]') }
284
- @driver.find_element(:xpath, '//*[@name="apiKey"]').click
285
- sleep(1)
286
- begin
287
- @driver.find_element(:xpath, '//*[@name="apiKey"]').click
288
- rescue
289
-
290
- puts '-[√] 로딩 및 코드인식 실패등 기타 이유로 다음 게시판 작업으로 이동합니다.......'.red
291
- puts '-[√] 다음 작업 준비로 약 1초~60초 내외 시간이 소요됩니다.......'.red
292
-
293
- end
294
579
 
295
- Clipboard.copy(captcha_key)
296
- @driver.action.key_down(:control).send_keys('v').key_up(:control).perform
297
- sleep(1)
298
- begin
299
- @driver.find_element(:class_name, 'default-btn').click
300
- sleep(1)
301
580
 
581
+ begin
582
+ if signup_url == '' or signup_url == '회원가입 페이지 url'
583
+
584
+ else
585
+ @driver.get(signup_url)
586
+ puts '-[√] 회원가입 페이지 URL 이동.......'.magenta
587
+
588
+
589
+
590
+
591
+
302
592
  begin
303
- wait = Selenium::WebDriver::Wait.new(:timeout => 10)
304
- wait.until do
305
- begin
306
- alert = @driver.switch_to.alert
307
- alert.accept
308
- true
309
- rescue Selenium::WebDriver::Error::NoSuchAlertError
310
- false
311
- end
593
+ # 부분을 통해 페이지 내에서 "사이트에 연결할 수 없음" 텍스트를 찾습니다.
594
+ error_text = @driver.find_element(:xpath, '//*[contains(text(),"사이트에 연결할 수 없음")]')
595
+ if error_text
596
+ puts '사이트 문제 발견!! 사이트에 접근할수 없습니다 창을 닫습니다.'
597
+ @driver.quit if @driver
598
+ return 0
312
599
  end
313
- rescue Selenium::WebDriver::Error::TimeoutError
314
- puts "alert이 없으므로 버튼 클릭"
315
- @driver.find_element(:xpath, '/html/body/div/div[1]/table/tbody/tr[1]/td[3]/button').click
316
- begin
317
- wait = Selenium::WebDriver::Wait.new(:timeout => 10)
318
- wait.until do
319
- begin
320
- alert = @driver.switch_to.alert
321
- alert.accept
322
- true
323
- rescue Selenium::WebDriver::Error::NoSuchAlertError
324
- false
325
- end
326
- end
327
- puts "두 번째 alert 처리 완료"
328
- rescue Selenium::WebDriver::Error::TimeoutError
329
- puts "두 번째 alert이 10초 내에 나타나지 않음. Chrome 종료."
330
- system('taskkill /F /IM chrome.exe')
331
- @driver.quit if @driver
332
- end
600
+ rescue
333
601
  end
334
-
335
- rescue => e
336
- @driver.window_handles.each do |handle|
337
- @driver.switch_to.window(handle)
338
- begin
339
- # 로딩 중이거나, 페이지가 완전히 로딩되지 않더라도 탭을 닫기
340
- @driver.close
341
- rescue Selenium::WebDriver::Error::WebDriverError => e
342
- puts "크롬 브라우저 종료: #{e.message}"
343
- end
344
- end
345
- return 0
346
- @driver.quit
347
- end
348
602
 
349
- rescue => e
350
- puts '-[√] 로딩 코드인식 실패등 기타 이유로 다음 게시판 작업으로 이동합니다.......'.red
351
- puts '-[√] 다음 작업 준비로 약 1초~60초 내외 시간이 소요됩니다.......'.red
352
- @driver.window_handles.each do |handle|
353
- @driver.switch_to.window(handle)
354
- begin
355
- # 로딩 중이거나, 페이지가 완전히 로딩되지 않더라도 탭을 닫기
356
- @driver.close
357
- rescue Selenium::WebDriver::Error::WebDriverError => e
358
- puts "크롬 브라우저 종료: #{e.message}"
603
+ begin
604
+ # 부분을 통해 페이지 내에서 "사이트에 연결할 없음" 텍스트를 찾습니다.
605
+ error_text = @driver.find_element(:xpath, '//*[contains(text(),"Connection timed out")]')
606
+ if error_text
607
+ puts '사이트 문제 발견!! 사이트에 접근할수 없습니다 창을 닫습니다.'
608
+ @driver.quit if @driver
609
+ return 0
359
610
  end
611
+ rescue
360
612
  end
361
- return 0
362
- @driver.quit
363
- end
364
-
365
- end
366
- #@driver.switch_to.window(@driver.window_handles[0])
367
- ####################탭나누기 수정중######################################
368
- sleep(2)
369
-
370
613
 
614
+ begin
615
+ wait = Selenium::WebDriver::Wait.new(:timeout => 2) # 3초 대기
616
+ alert = wait.until { @driver.switch_to.alert } # alert가 나타날 때까지 기다림
617
+ alert.accept # 알림을 확인
618
+ rescue
619
+ end
371
620
 
372
- ##################
373
- signup_url = option['signup_url'].to_s
374
-
621
+
622
+ sleep(1)
623
+
624
+
625
+
375
626
 
376
627
 
377
628
 
378
- begin
379
- if signup_url == '' or signup_url == '회원가입 페이지 url'
380
629
 
381
- else
382
-
630
+ #오른쪽 마우스 해제 코드
383
631
  begin
384
- wait = Selenium::WebDriver::Wait.new(:timeout => 30) # 최대 20초 대기
385
- wait.until { @driver.execute_script("return document.readyState") == "complete" }
386
- @driver.get(signup_url)
387
- sleep(1)
388
- puts '-[√] 회원가입 페이지 URL 이동.......'.magenta
389
-
390
- # Alert 처리 부분
391
- begin
392
- wait = Selenium::WebDriver::Wait.new(:timeout => 3) # 3초 대기
393
- alert = wait.until { @driver.switch_to.alert } # alert가 나타날 때까지 기다림
394
- alert.accept # 알림을 확인
395
- rescue
396
- # 알림이 나타나지 않으면 예외 처리하고 넘어감
397
- end
398
-
399
-
400
- rescue Selenium::WebDriver::Error::UnknownError => e
401
- puts "#{signup_url} 해당 사이트의 문제로 접속이 불가능합니다." # 오류 메시지 출력
402
- # 열린 모든 창을 닫음
403
- @driver.window_handles.each do |handle|
404
- @driver.switch_to.window(handle)
405
- begin
406
- @driver.close
407
- rescue Selenium::WebDriver::Error::WebDriverError => e
408
- puts "사이트 내부에 예외 발생: #{e.message}"
409
- end
410
- end
411
-
412
- # 드라이버 종료
413
- @driver.quit if @driver
414
- return 0
415
-
416
- rescue Selenium::WebDriver::Error::TimeoutError => e
417
- puts "웹 페이지 로드가 시간 초과되었습니다: #{e.message}"
418
- @driver.quit if @driver
419
- return 0
420
-
421
- rescue
422
- end
423
-
424
-
632
+ @driver.execute_script <<-JS
633
+ document.querySelectorAll('body').forEach(function(element) {
634
+ element.oncontextmenu = null;
635
+ });
636
+ document.removeEventListener('contextmenu', function(e) { e.preventDefault(); }, false);
637
+ JS
638
+
639
+ @driver.execute_script <<-JS
640
+ document.addEventListener('contextmenu', function(e) {
641
+ e.stopImmediatePropagation();
642
+ }, true);
643
+ JS
644
+
645
+ @driver.execute_script("window.oncontextmenu = null;")
646
+ rescue
647
+ end
425
648
 
426
649
 
427
650
 
@@ -435,6 +658,8 @@ sleep(2)
435
658
  puts '-[√] 3 캡챠 발생 유무 확인.......'.green
436
659
  sleep(2)
437
660
 
661
+
662
+
438
663
  begin
439
664
  @driver.find_element(:xpath, '//*[@class="amzn-captcha-state-container"]')
440
665
  puts '-[√] 아임웹 캡챠 확인!! 해제 실행.......'.green
@@ -610,9 +835,22 @@ sleep(2)
610
835
  begin
611
836
  sleep(1)
612
837
  @driver.switch_to.alert.accept
838
+ sleep(1)
613
839
  rescue
614
840
  end
615
841
 
842
+ begin
843
+ # 이 부분을 통해 페이지 내에서 "사이트에 연결할 수 없음" 텍스트를 찾습니다.
844
+ error_text = @driver.find_element(:xpath, '//*[contains(text(),"사이트에 연결할 수 없음")]')
845
+ if error_text
846
+ puts '사이트에 연결할 수 없음 텍스트가 발견되었습니다. 창을 닫습니다.'
847
+ @driver.quit if @driver
848
+ return 0
849
+ end
850
+ rescue Selenium::WebDriver::Error::NoSuchElementError
851
+ # 해당 텍스트가 없으면 아무 작업 안함
852
+ end
853
+
616
854
 
617
855
  ##체크박스1-1 코드 확인 및 제거 부분─────────────────────────────────────────────────────────────────────>
618
856
  puts '-[√] 회원가입 체크박스 1차 탐색.......'.yellow
@@ -1468,15 +1706,28 @@ sleep(2)
1468
1706
 
1469
1707
 
1470
1708
 
1471
-
1472
-
1473
-
1474
-
1475
1709
 
1476
1710
 
1477
1711
  sleep(1)
1478
1712
  ##캡챠 이미지,2캡챠,,등등 코드 부분─────────────────────────────────────────────────────────────────────>
1479
-
1713
+ #오른쪽 마우스 해제 코드
1714
+ begin
1715
+ @driver.execute_script <<-JS
1716
+ document.querySelectorAll('body').forEach(function(element) {
1717
+ element.oncontextmenu = null;
1718
+ });
1719
+ document.removeEventListener('contextmenu', function(e) { e.preventDefault(); }, false);
1720
+ JS
1721
+
1722
+ @driver.execute_script <<-JS
1723
+ document.addEventListener('contextmenu', function(e) {
1724
+ e.stopImmediatePropagation();
1725
+ }, true);
1726
+ JS
1727
+
1728
+ @driver.execute_script("window.oncontextmenu = null;")
1729
+ rescue
1730
+ end
1480
1731
  sleep(1)
1481
1732
  ##캡챠 이미지,2캡챠,,등등 코드 부분─────────────────────────────────────────────────────────────────────>
1482
1733
  puts '-[√] 캡챠 유형 탐색.......'.green
@@ -1575,12 +1826,7 @@ rescue
1575
1826
  rescue
1576
1827
  begin
1577
1828
  @driver.switch_to.default_content()
1578
- @driver.find_elements(:tag_name, 'img').each do |img|
1579
- if img.attribute('src').include?('kboard_captcha')
1580
- el = img # 캡챠 이미지를 el에 저장
1581
- break # 첫 번째 이미지를 찾으면 루프 종료
1582
- end
1583
- end
1829
+ el = @driver.find_element(:xpath, '//img[contains(@src, "kboard_captcha")]')
1584
1830
  puts '-[√] 캡챠 발견!! 캡차 해제를 위한 환경설정 약 10초 소요.......'.red
1585
1831
  puts '-[√] 챕챠 해제 중~ 해제 완료까지 마우스 움직이지 마세요.......'.red
1586
1832
  puts '-[√] 챕챠 코드 code 5-1.......'.red
@@ -1597,11 +1843,13 @@ rescue
1597
1843
  @driver.action.key_down(:shift).key_stroke('m').key_up(:shift).perform #단축키
1598
1844
  sleep(1)
1599
1845
  puts '-[√] 캡챠 코드 타겟 완료1.......'.blue
1846
+
1847
+
1600
1848
  rescue
1601
1849
  begin
1602
1850
  @driver.switch_to.default_content()
1603
1851
  #@driver.find_element(:xpath, '//*[@for="kboard-input-captcha"]')
1604
- el = @driver.find_element(:css, 'label[for="kboard-input-captcha"] img')
1852
+ el = @driver.find_element(:xpath, '//*[@for="kboard-input-captcha"] img')
1605
1853
  puts '-[√] 캡챠 발견!! 캡차 해제를 위한 환경설정 약 10초 소요.......'.red
1606
1854
  puts '-[√] 챕챠 해제 중~ 해제 완료까지 마우스 움직이지 마세요.......'.red
1607
1855
  puts '-[√] 챕챠 코드 code 5-2.......'.red
@@ -2444,6 +2692,7 @@ end
2444
2692
  wait = Selenium::WebDriver::Wait.new(:timeout => 3) # 3초 대기
2445
2693
  alert = wait.until { @driver.switch_to.alert } # alert가 나타날 때까지 기다림
2446
2694
  alert.accept # 알림을 확인
2695
+ sleep(1)
2447
2696
  rescue
2448
2697
  # 알림이 나타나지 않으면 예외 처리하고 넘어감
2449
2698
  end
@@ -2465,58 +2714,69 @@ login_url = option['login_url'].to_s
2465
2714
  if login_url == '' or login_url == '로그인 페이지 url'
2466
2715
 
2467
2716
  else
2468
-
2717
+ @driver.get(login_url)
2718
+ puts '-[√] 로그인 페이지 URL 이동.......'.magenta
2719
+
2720
+
2721
+
2722
+
2723
+
2469
2724
  begin
2470
- wait = Selenium::WebDriver::Wait.new(:timeout => 30) # 최대 20초 대기
2471
- wait.until { @driver.execute_script("return document.readyState") == "complete" }
2472
- @driver.get(login_url)
2473
- sleep(1)
2474
- puts '-[√] 로그인 페이지 URL 이동.......'.magenta
2475
- # Alert 처리 부분
2476
- begin
2477
- wait = Selenium::WebDriver::Wait.new(:timeout => 3) # 3초 대기
2478
- alert = wait.until { @driver.switch_to.alert } # alert가 나타날 때까지 기다림
2479
- alert.accept # 알림을 확인
2480
- rescue
2481
- # 알림이 나타나지 않으면 예외 처리하고 넘어감
2482
- end
2483
-
2484
- rescue Selenium::WebDriver::Error::UnknownError => e
2485
- puts "#{login_url} 해당 사이트의 문제로 접속이 불가능합니다." # 오류 메시지 출력
2486
- # 열린 모든 창을 닫음
2487
- @driver.window_handles.each do |handle|
2488
- @driver.switch_to.window(handle)
2489
- begin
2490
- @driver.close
2491
- rescue Selenium::WebDriver::Error::WebDriverError => e
2492
- puts "사이트 내부에 예외 발생: #{e.message}"
2493
- end
2494
- end
2495
-
2496
- # 드라이버 종료
2725
+ # 부분을 통해 페이지 내에서 "사이트에 연결할 수 없음" 텍스트를 찾습니다.
2726
+ error_text = @driver.find_element(:xpath, '//*[contains(text(),"사이트에 연결할 수 없음")]')
2727
+ if error_text
2728
+ puts '사이트 문제 발견!! 사이트에 접근할수 없습니다 창을 닫습니다.'
2497
2729
  @driver.quit if @driver
2498
- return 0
2499
-
2500
- rescue Selenium::WebDriver::Error::TimeoutError => e
2501
- puts "웹 페이지 로드가 시간 초과되었습니다: #{e.message}"
2730
+ return 0
2731
+ end
2732
+ rescue
2733
+ end
2734
+
2735
+ begin
2736
+ # 이 부분을 통해 페이지 내에서 "사이트에 연결할 수 없음" 텍스트를 찾습니다.
2737
+ error_text = @driver.find_element(:xpath, '//*[contains(text(),"Connection timed out")]')
2738
+ if error_text
2739
+ puts '사이트 문제 발견!! 사이트에 접근할수 없습니다 창을 닫습니다.'
2502
2740
  @driver.quit if @driver
2503
2741
  return 0
2504
-
2505
- rescue
2506
2742
  end
2507
-
2508
-
2509
-
2510
- sleep(1)
2743
+ rescue
2744
+ end
2745
+
2746
+ begin
2747
+ wait = Selenium::WebDriver::Wait.new(:timeout => 2) # 3초 대기
2748
+ alert = wait.until { @driver.switch_to.alert } # alert가 나타날 때까지 기다림
2749
+ alert.accept # 알림을 확인
2750
+ rescue
2751
+ end
2752
+
2753
+
2754
+
2755
+ sleep(1)
2756
+
2511
2757
  ##캡챠 해제 입력 코드 부분─────────────────────────────────────────────────────────────────────>
2758
+ #오른쪽 마우스 해제 코드
2759
+ begin
2760
+ @driver.execute_script <<-JS
2761
+ document.querySelectorAll('body').forEach(function(element) {
2762
+ element.oncontextmenu = null;
2763
+ });
2764
+ document.removeEventListener('contextmenu', function(e) { e.preventDefault(); }, false);
2765
+ JS
2512
2766
 
2513
- puts '-[√] 1 캡챠 발생 유무 확인.......'.green
2514
- sleep(1)
2515
- puts '-[√] 2 캡챠 발생 유무 확인.......'.green
2516
- sleep(1)
2517
- puts '-[√] 3 캡챠 발생 유무 확인.......'.green
2518
- sleep(1)
2519
-
2767
+ @driver.execute_script <<-JS
2768
+ document.addEventListener('contextmenu', function(e) {
2769
+ e.stopImmediatePropagation();
2770
+ }, true);
2771
+ JS
2772
+
2773
+ @driver.execute_script("window.oncontextmenu = null;")
2774
+ rescue
2775
+ end
2776
+
2777
+ sleep(5)
2778
+
2779
+
2520
2780
  begin
2521
2781
  @driver.find_element(:xpath, '//*[@class="amzn-captcha-state-container"]')
2522
2782
  puts '-[√] 아임웹 캡챠 확인!! 해제 실행.......'.green
@@ -2612,7 +2872,7 @@ login_url = option['login_url'].to_s
2612
2872
  rescue
2613
2873
  begin
2614
2874
  # 타임아웃을 3초로 설정
2615
- wait = Selenium::WebDriver::Wait.new(:timeout => 5)
2875
+ wait = Selenium::WebDriver::Wait.new(:timeout => 2)
2616
2876
  # 요소가 나타날 때까지 30초 동안 기다립니다.
2617
2877
  wait.until { @driver.find_element(:xpath, '//*[@data-state="ready"]') }
2618
2878
  sleep(1)
@@ -2700,7 +2960,7 @@ login_url = option['login_url'].to_s
2700
2960
 
2701
2961
 
2702
2962
  begin
2703
- puts '-[√] 숨김 code 탐색 중 (발견시 제거).......'.green
2963
+
2704
2964
  chat_box = @driver.find_element(:xpath, '//*[@class="adsbygoogle adsbygoogle-noablate"]')
2705
2965
  @driver.execute_script("arguments[0].remove();", chat_box)
2706
2966
  puts '-[√] 숨김 code 1 제거 완료.......'.green
@@ -2709,7 +2969,7 @@ login_url = option['login_url'].to_s
2709
2969
  end
2710
2970
 
2711
2971
  begin
2712
- puts '-[√] 숨김 code 탐색 중 (발견시 제거).......'.green
2972
+
2713
2973
  chat_box = @driver.find_element(:xpath, '//*[@class="google-auto-placed"]')
2714
2974
  @driver.execute_script("arguments[0].remove();", chat_box)
2715
2975
  puts '-[√] 숨김 code 2 제거 완료.......'.green
@@ -2718,7 +2978,7 @@ login_url = option['login_url'].to_s
2718
2978
  end
2719
2979
 
2720
2980
  begin
2721
- puts '-[√] 숨김 code 탐색 중 (발견시 제거).......'.green
2981
+
2722
2982
  chat_box = @driver.find_elements(:xpath, '//*[@class="adsbygoogle adsbygoogle-noablate"]')[1]
2723
2983
  @driver.execute_script("arguments[0].remove();", chat_box)
2724
2984
  puts '-[√] 숨김 code 3 제거 완료.......'.green
@@ -2727,7 +2987,7 @@ login_url = option['login_url'].to_s
2727
2987
  end
2728
2988
 
2729
2989
  begin
2730
- puts '-[√] 숨김 code 탐색 중 (발견시 제거).......'.green
2990
+
2731
2991
  chat_box = @driver.find_elements(:xpath, '//*[@class="adsbygoogle adsbygoogle-noablate"]')[2]
2732
2992
  @driver.execute_script("arguments[0].remove();", chat_box)
2733
2993
  puts '-[√] 숨김 code 4 제거 완료.......'.green
@@ -2736,7 +2996,7 @@ login_url = option['login_url'].to_s
2736
2996
  end
2737
2997
 
2738
2998
  begin
2739
- puts '-[√] 숨김 code 탐색 중 (발견시 제거).......'.green
2999
+
2740
3000
  chat_box = @driver.find_elements(:xpath, '//*[@class="adsbygoogle adsbygoogle-noablate"]')[3]
2741
3001
  @driver.execute_script("arguments[0].remove();", chat_box)
2742
3002
  puts '-[√] 숨김 code 5 제거 완료.......'.green
@@ -2757,11 +3017,10 @@ login_url = option['login_url'].to_s
2757
3017
  rescue
2758
3018
  end
2759
3019
 
2760
-
2761
3020
 
2762
3021
 
2763
3022
  ##팝업 코드 확인 및 제거 부분─────────────────────────────────────────────────────────────────────>
2764
- puts '-[√] 팝업 여부 확인 체크 01.......'.yellow
3023
+
2765
3024
 
2766
3025
  begin
2767
3026
  @driver.find_element(:partial_link_text, '더 이상 보지 않기').click #요소같고 텍스트가 다를때 텍스트로 타겟
@@ -2843,7 +3102,7 @@ login_url = option['login_url'].to_s
2843
3102
  @driver.find_element(:xpath, '//*[@id="hd_pops_1"]/div[2]/button[1]').click
2844
3103
  sleep(1)
2845
3104
  rescue
2846
- puts '.......'.yellow
3105
+
2847
3106
 
2848
3107
  end
2849
3108
 
@@ -2873,7 +3132,7 @@ login_url = option['login_url'].to_s
2873
3132
 
2874
3133
  ##<─────────────────────────────────────────────────────────────────────팝업 코드 확인 및 제거 부분
2875
3134
  ##팝업 코드 확인 및 제거 부분─────────────────────────────────────────────────────────────────────>
2876
- puts '-[√] 팝업 여부 확인 체크 02.......'.yellow
3135
+
2877
3136
 
2878
3137
  begin
2879
3138
  @driver.find_element(:partial_link_text, '더 이상 보지 않기').click #요소같고 텍스트가 다를때 텍스트로 타겟
@@ -2955,7 +3214,7 @@ login_url = option['login_url'].to_s
2955
3214
  @driver.find_element(:xpath, '//*[@id="hd_pops_2"]/div[2]/button[1]').click
2956
3215
  sleep(1)
2957
3216
  rescue
2958
- puts '.......'.yellow
3217
+
2959
3218
 
2960
3219
  end
2961
3220
 
@@ -2985,7 +3244,7 @@ login_url = option['login_url'].to_s
2985
3244
  end
2986
3245
  ##<─────────────────────────────────────────────────────────────────────팝업 코드 확인 및 제거 부분
2987
3246
  ##팝업 코드 확인 및 제거 부분─────────────────────────────────────────────────────────────────────>
2988
- puts '-[√] 팝업 여부 확인 체크 03.......'.yellow
3247
+
2989
3248
 
2990
3249
  begin
2991
3250
  @driver.find_element(:partial_link_text, '더 이상 보지 않기').click #요소같고 텍스트가 다를때 텍스트로 타겟
@@ -3067,7 +3326,7 @@ login_url = option['login_url'].to_s
3067
3326
  @driver.find_element(:xpath, '//*[@id="hd_pops_3"]/div[2]/button[1]').click
3068
3327
  sleep(1)
3069
3328
  rescue
3070
- puts '.......'.yellow
3329
+
3071
3330
 
3072
3331
  end
3073
3332
 
@@ -3097,7 +3356,7 @@ login_url = option['login_url'].to_s
3097
3356
  end
3098
3357
  ##<─────────────────────────────────────────────────────────────────────팝업 코드 확인 및 제거 부분
3099
3358
  ##팝업 코드 확인 및 제거 부분─────────────────────────────────────────────────────────────────────>
3100
- puts '-[√] 팝업 여부 확인 체크 04.......'.yellow
3359
+
3101
3360
 
3102
3361
  begin
3103
3362
  @driver.find_element(:partial_link_text, '더 이상 보지 않기').click #요소같고 텍스트가 다를때 텍스트로 타겟
@@ -3179,7 +3438,7 @@ login_url = option['login_url'].to_s
3179
3438
  @driver.find_element(:xpath, '//*[@id="hd_pops_4"]/div[2]/button[1]').click
3180
3439
  sleep(1)
3181
3440
  rescue
3182
- puts '.......'.yellow
3441
+
3183
3442
 
3184
3443
  end
3185
3444
 
@@ -3209,7 +3468,7 @@ login_url = option['login_url'].to_s
3209
3468
  end
3210
3469
  ##<─────────────────────────────────────────────────────────────────────팝업 코드 확인 및 제거 부분
3211
3470
  ##팝업 코드 확인 및 제거 부분─────────────────────────────────────────────────────────────────────>
3212
- puts '-[√] 팝업 여부 확인 체크 05.......'.yellow
3471
+
3213
3472
 
3214
3473
  begin
3215
3474
  @driver.find_element(:partial_link_text, '더 이상 보지 않기').click #요소같고 텍스트가 다를때 텍스트로 타겟
@@ -3291,7 +3550,7 @@ login_url = option['login_url'].to_s
3291
3550
  @driver.find_element(:xpath, '//*[@id="hd_pops_5"]/div[2]/button[1]').click
3292
3551
  sleep(1)
3293
3552
  rescue
3294
- puts '.......'.yellow
3553
+
3295
3554
 
3296
3555
  end
3297
3556
 
@@ -3321,10 +3580,20 @@ login_url = option['login_url'].to_s
3321
3580
  ##<─────────────────────────────────────────────────────────────────────팝업 코드 확인 및 제거 부분
3322
3581
 
3323
3582
 
3324
-
3583
+ begin
3584
+ # 이 부분을 통해 페이지 내에서 "사이트에 연결할 수 없음" 텍스트를 찾습니다.
3585
+ error_text = @driver.find_element(:xpath, '//*[contains(text(),"사이트에 연결할 수 없음")]')
3586
+ if error_text
3587
+ puts '사이트에 연결할 수 없음 텍스트가 발견되었습니다. 창을 닫습니다.'
3588
+ @driver.quit if @driver
3589
+ return 0
3590
+ end
3591
+ rescue Selenium::WebDriver::Error::NoSuchElementError
3592
+ # 해당 텍스트가 없으면 아무 작업 안함
3593
+ end
3325
3594
 
3326
3595
  ##아이디 입력 코드 부분─────────────────────────────────────────────────────────────────────>
3327
- puts '-[√] 로그인 ID/PW 입력 필드 탐색.......'.cyan
3596
+
3328
3597
  sleep(1)
3329
3598
  begin
3330
3599
  @driver.find_element(:xpath, '//*[@name="mb_id"]').send_keys(user_id)
@@ -3421,20 +3690,7 @@ login_url = option['login_url'].to_s
3421
3690
  begin
3422
3691
  @driver.find_element(:xpath, '//*[@class="username"]').send_keys(user_id)
3423
3692
  sleep(3)
3424
- rescue => e
3425
- puts '-[√] 로그인 페이지 접속 시도 실패 (페이지 로딩 지연 및 접속 불량).......'.red
3426
- puts '-[√] 다음 작업 준비로 약 1초~60초 내외 시간이 소요됩니다.......'.red
3427
- @driver.window_handles.each do |handle|
3428
- @driver.switch_to.window(handle)
3429
- begin
3430
- # 로딩 중이거나, 페이지가 완전히 로딩되지 않더라도 탭을 닫기
3431
- @driver.close
3432
- rescue Selenium::WebDriver::Error::WebDriverError => e
3433
- puts "크롬 브라우저 종료: #{e.message}"
3434
- end
3435
- end
3436
- return 0
3437
- @driver.quit
3693
+ rescue
3438
3694
  end
3439
3695
 
3440
3696
  end
@@ -3555,7 +3811,7 @@ login_url = option['login_url'].to_s
3555
3811
  end
3556
3812
  end
3557
3813
  end
3558
- puts '-[√] 로그인 ID/PW 입력 필드 종료.......'.cyan
3814
+
3559
3815
  sleep(1)
3560
3816
  end
3561
3817
  ##패스워드 입력 코드 부분─────────────────────────────────────────────────────────────────────<
@@ -3594,47 +3850,53 @@ login_url = option['login_url'].to_s
3594
3850
  sleep(3)
3595
3851
  rescue
3596
3852
  begin
3597
- @driver.find_element(:xpath, '//*[@alt="로그인"]').click
3853
+ @driver.find_element(:xpath, '//*[@class="btn btn-color pull-right"]').click
3598
3854
  puts '-[√] 로그인 버튼 코드 7 타겟.......'.cyan
3599
3855
  sleep(3)
3600
3856
  rescue
3601
3857
  begin
3602
- @driver.find_element(:xpath, '//*[@id="mb_login"]/form/div[5]/button').click
3858
+ @driver.find_element(:xpath, '//*[@alt="로그인"]').click
3603
3859
  puts '-[√] 로그인 버튼 코드 8 타겟.......'.cyan
3604
3860
  sleep(3)
3605
3861
  rescue
3606
3862
  begin
3607
- @driver.find_element(:xpath, '//*[@id="ol_submit"]').click
3863
+ @driver.find_element(:xpath, '//*[@id="mb_login"]/form/div[5]/button').click
3608
3864
  puts '-[√] 로그인 버튼 코드 9 타겟.......'.cyan
3609
3865
  sleep(3)
3610
3866
  rescue
3611
3867
  begin
3612
- @driver.find_element(:xpath, '//*[@alt="login"]').click
3868
+ @driver.find_element(:xpath, '//*[@id="ol_submit"]').click
3613
3869
  puts '-[√] 로그인 버튼 코드 10 타겟.......'.cyan
3614
3870
  sleep(3)
3615
3871
  rescue
3616
3872
  begin
3617
- @driver.find_element(:xpath, '//*[@title="login"]').click
3873
+ @driver.find_element(:xpath, '//*[@alt="login"]').click
3618
3874
  puts '-[√] 로그인 버튼 코드 11 타겟.......'.cyan
3619
3875
  sleep(3)
3620
3876
  rescue
3621
3877
  begin
3622
- @driver.find_element(:xpath, '//*[@id="signIn_1"]').click
3878
+ @driver.find_element(:xpath, '//*[@title="login"]').click
3623
3879
  puts '-[√] 로그인 버튼 코드 12 타겟.......'.cyan
3624
3880
  sleep(3)
3625
3881
  rescue
3626
3882
  begin
3627
- @driver.find_element(:xpath, '//*[@id="btn_login"]').click
3883
+ @driver.find_element(:xpath, '//*[@id="signIn_1"]').click
3628
3884
  puts '-[√] 로그인 버튼 코드 13 타겟.......'.cyan
3629
3885
  sleep(3)
3630
3886
  rescue
3631
3887
  begin
3632
- @driver.find_element(:xpath, '//*[@name="wp-submit"]').click
3888
+ @driver.find_element(:xpath, '//*[@id="btn_login"]').click
3633
3889
  puts '-[√] 로그인 버튼 코드 14 타겟.......'.cyan
3634
3890
  sleep(3)
3635
3891
  rescue
3636
- @driver.action.key_down(:enter).key_up(:enter).perform #엔터
3637
- sleep(3)
3892
+ begin
3893
+ @driver.find_element(:xpath, '//*[@name="wp-submit"]').click
3894
+ puts '-[√] 로그인 버튼 코드 15 타겟.......'.cyan
3895
+ sleep(3)
3896
+ rescue
3897
+ @driver.action.key_down(:enter).key_up(:enter).perform #엔터
3898
+ sleep(3)
3899
+ end
3638
3900
  end
3639
3901
  end
3640
3902
  end
@@ -3651,11 +3913,14 @@ login_url = option['login_url'].to_s
3651
3913
  end
3652
3914
  ##로그인 버튼 코드 부분─────────────────────────────────────────────────────────────────────<
3653
3915
 
3916
+
3917
+
3654
3918
  # Alert 처리 부분
3655
3919
  begin
3656
3920
  wait = Selenium::WebDriver::Wait.new(:timeout => 3) # 3초 대기
3657
3921
  alert = wait.until { @driver.switch_to.alert } # alert가 나타날 때까지 기다림
3658
3922
  alert.accept # 알림을 확인
3923
+ sleep(1)
3659
3924
  rescue
3660
3925
  # 알림이 나타나지 않으면 예외 처리하고 넘어감
3661
3926
  end
@@ -3666,7 +3931,7 @@ login_url = option['login_url'].to_s
3666
3931
 
3667
3932
 
3668
3933
  rescue => e
3669
- puts '-[√] 로그인 PASS.......'.cyan
3934
+ #puts '-[√] 로그인 PASS.......'.cyan
3670
3935
  puts e
3671
3936
  end
3672
3937
 
@@ -3684,57 +3949,68 @@ begin
3684
3949
 
3685
3950
  else
3686
3951
 
3952
+ @driver.get(cc_check_url)
3953
+ puts '-[√] 출석 체크 페이지 URL 이동.......'.magenta
3954
+
3955
+
3956
+
3957
+
3958
+
3687
3959
  begin
3688
- wait = Selenium::WebDriver::Wait.new(:timeout => 30) # 최대 20초 대기
3689
- wait.until { @driver.execute_script("return document.readyState") == "complete" }
3690
- @driver.get(cc_check_url)
3691
- sleep(1)
3692
- puts '-[√] 출석체크 페이지 URL 이동.......'.magenta
3693
- # Alert 처리 부분
3694
- begin
3695
- wait = Selenium::WebDriver::Wait.new(:timeout => 3) # 3초 대기
3696
- alert = wait.until { @driver.switch_to.alert } # alert가 나타날 때까지 기다림
3697
- alert.accept # 알림을 확인
3698
- rescue
3699
- # 알림이 나타나지 않으면 예외 처리하고 넘어감
3700
- end
3701
-
3702
- rescue Selenium::WebDriver::Error::UnknownError => e
3703
- puts "#{cc_check_url} 해당 사이트의 문제로 접속이 불가능합니다." # 오류 메시지 출력
3704
- # 열린 모든 창을 닫음
3705
- @driver.window_handles.each do |handle|
3706
- @driver.switch_to.window(handle)
3707
- begin
3708
- @driver.close
3709
- rescue Selenium::WebDriver::Error::WebDriverError => e
3710
- puts "사이트 내부에 예외 발생: #{e.message}"
3711
- end
3712
- end
3713
-
3714
- # 드라이버 종료
3960
+ # 부분을 통해 페이지 내에서 "사이트에 연결할 수 없음" 텍스트를 찾습니다.
3961
+ error_text = @driver.find_element(:xpath, '//*[contains(text(),"사이트에 연결할 수 없음")]')
3962
+ if error_text
3963
+ puts '사이트 문제 발견!! 사이트에 접근할수 없습니다 창을 닫습니다.'
3715
3964
  @driver.quit if @driver
3716
- return 0
3717
-
3718
- rescue Selenium::WebDriver::Error::TimeoutError => e
3719
- puts "웹 페이지 로드가 시간 초과되었습니다: #{e.message}"
3965
+ return 0
3966
+ end
3967
+ rescue
3968
+ end
3969
+
3970
+ begin
3971
+ # 이 부분을 통해 페이지 내에서 "사이트에 연결할 수 없음" 텍스트를 찾습니다.
3972
+ error_text = @driver.find_element(:xpath, '//*[contains(text(),"Connection timed out")]')
3973
+ if error_text
3974
+ puts '사이트 문제 발견!! 사이트에 접근할수 없습니다 창을 닫습니다.'
3720
3975
  @driver.quit if @driver
3721
3976
  return 0
3722
-
3723
- rescue
3724
3977
  end
3978
+ rescue
3979
+ end
3725
3980
 
3726
-
3981
+ begin
3982
+ wait = Selenium::WebDriver::Wait.new(:timeout => 2) # 3초 대기
3983
+ alert = wait.until { @driver.switch_to.alert } # alert가 나타날 때까지 기다림
3984
+ alert.accept # 알림을 확인
3985
+ rescue
3986
+ end
3727
3987
 
3988
+
3728
3989
 
3729
3990
  sleep(1)
3991
+ #오른쪽 마우스 해제 코드
3992
+ begin
3993
+ @driver.execute_script <<-JS
3994
+ document.querySelectorAll('body').forEach(function(element) {
3995
+ element.oncontextmenu = null;
3996
+ });
3997
+ document.removeEventListener('contextmenu', function(e) { e.preventDefault(); }, false);
3998
+ JS
3999
+
4000
+ @driver.execute_script <<-JS
4001
+ document.addEventListener('contextmenu', function(e) {
4002
+ e.stopImmediatePropagation();
4003
+ }, true);
4004
+ JS
4005
+
4006
+ @driver.execute_script("window.oncontextmenu = null;")
4007
+ rescue
4008
+ end
3730
4009
  ##캡챠 해제 입력 코드 부분─────────────────────────────────────────────────────────────────────>
3731
4010
  begin
3732
- puts '-[√] 1 캡챠 발생 유무 확인.......'.green
3733
- sleep(1)
3734
- puts '-[√] 2 캡챠 발생 유무 확인.......'.green
3735
- sleep(1)
3736
- puts '-[√] 3 캡챠 발생 유무 확인.......'.green
3737
- sleep(1)
4011
+ sleep(5)
4012
+
4013
+
3738
4014
  # 타임아웃을 3초로 설정
3739
4015
  wait = Selenium::WebDriver::Wait.new(:timeout => 3)
3740
4016
  # 요소가 나타날 때까지 30초 동안 기다립니다.
@@ -3773,7 +4049,7 @@ begin
3773
4049
  end
3774
4050
  ##<─────────────────────────────────────────────────────────────────────캡챠 해제 입력 코드 부분
3775
4051
 
3776
- begin
4052
+ begin
3777
4053
  # 요소 찾기 타임아웃을 10초로 설정
3778
4054
  wait = Selenium::WebDriver::Wait.new(:timeout => 20)
3779
4055
  #요소가 나타날 때까지 20초 동안 기다립니다.
@@ -3798,6 +4074,19 @@ begin
3798
4074
  end
3799
4075
  end
3800
4076
 
4077
+ begin
4078
+ # 이 부분을 통해 페이지 내에서 "사이트에 연결할 수 없음" 텍스트를 찾습니다.
4079
+ error_text = @driver.find_element(:xpath, '//*[contains(text(),"사이트에 연결할 수 없음")]')
4080
+ if error_text
4081
+ puts '사이트에 연결할 수 없음 텍스트가 발견되었습니다. 창을 닫습니다.'
4082
+ @driver.quit if @driver
4083
+ return 0
4084
+ end
4085
+ rescue Selenium::WebDriver::Error::NoSuchElementError
4086
+ # 해당 텍스트가 없으면 아무 작업 안함
4087
+ end
4088
+
4089
+
3801
4090
  ##출석 체크 입력 코드 부분─────────────────────────────────────────────────────────────────────>
3802
4091
  cctxt_value = ['ㅊㅊ','출석체크','출석 체크해요','출첵~','추추','출석~','출석 체크 하고 가요','출석 체크 합니다.','안녕하세요','출첵왔어요','출석체크합니다.','출석체크~','출석했어요','출첵!!','출석 체크~,','출석 도장 쾅~!','출석 도장 쾅쾅!!','출석 하고 가요','출첵^^*','출석 체크~!^^','^^','^*^','출첵*_*','추추^^*'].sample
3803
4092
  begin
@@ -3908,6 +4197,7 @@ begin
3908
4197
  wait = Selenium::WebDriver::Wait.new(:timeout => 3) # 3초 대기
3909
4198
  alert = wait.until { @driver.switch_to.alert } # alert가 나타날 때까지 기다림
3910
4199
  alert.accept # 알림을 확인
4200
+ sleep(1)
3911
4201
  rescue
3912
4202
  # 알림이 나타나지 않으면 예외 처리하고 넘어감
3913
4203
  end
@@ -3924,71 +4214,67 @@ end
3924
4214
 
3925
4215
 
3926
4216
 
3927
- login_url = option['login_url'].to_s
4217
+ post_url = option['post_url'].to_s
3928
4218
 
3929
4219
  begin
3930
4220
  if post_url == '' or post_url == '게시판 글쓰기 url'
3931
4221
 
3932
4222
  else
3933
-
4223
+ @driver.get(post_url)
4224
+ puts '-[√] 게시판 페이지 URL 이동.......'.magenta
4225
+
4226
+
4227
+
4228
+
4229
+
3934
4230
  begin
3935
- wait = Selenium::WebDriver::Wait.new(:timeout => 30) # 최대 20초 대기
3936
- wait.until { @driver.execute_script("return document.readyState") == "complete" }
3937
- @driver.get(post_url)
3938
- sleep(1)
3939
- puts '-[√] 글쓰기 페이지 URL 이동.......'.magenta
3940
- # Alert 처리 부분
3941
- begin
3942
- wait = Selenium::WebDriver::Wait.new(:timeout => 3) # 3초 대기
3943
- alert = wait.until { @driver.switch_to.alert } # alert가 나타날 때까지 기다림
3944
- alert.accept # 알림을 확인
3945
- rescue
3946
- # 알림이 나타나지 않으면 예외 처리하고 넘어감
3947
- end
3948
-
3949
- rescue Selenium::WebDriver::Error::UnknownError => e
3950
- puts "#{post_url} 해당 사이트의 문제로 접속이 불가능합니다." # 오류 메시지 출력
3951
- # 열린 모든 창을 닫음
3952
- @driver.window_handles.each do |handle|
3953
- @driver.switch_to.window(handle)
3954
- begin
3955
- @driver.close
3956
- rescue Selenium::WebDriver::Error::WebDriverError => e
3957
- puts "사이트 내부에 예외 발생: #{e.message}"
3958
- end
3959
- end
3960
-
3961
- # 드라이버 종료
3962
- @driver.quit if @driver
3963
- return 0
3964
-
3965
- rescue Selenium::WebDriver::Error::TimeoutError => e
3966
- puts "웹 페이지 로드가 시간 초과되었습니다: #{e.message}"
4231
+ # 부분을 통해 페이지 내에서 "사이트에 연결할 수 없음" 텍스트를 찾습니다.
4232
+ error_text = @driver.find_element(:xpath, '//*[contains(text(),"사이트에 연결할 수 없음")]')
4233
+ if error_text
4234
+ puts '사이트 문제 발견!! 사이트에 접근할수 없습니다 창을 닫습니다.'
3967
4235
  @driver.quit if @driver
3968
4236
  return 0
3969
-
3970
- rescue
3971
4237
  end
4238
+ rescue
4239
+ end
3972
4240
 
4241
+ begin
4242
+ # 이 부분을 통해 페이지 내에서 "사이트에 연결할 수 없음" 텍스트를 찾습니다.
4243
+ error_text = @driver.find_element(:xpath, '//*[contains(text(),"Connection timed out")]')
4244
+ if error_text
4245
+ puts '사이트 문제 발견!! 사이트에 접근할수 없습니다 창을 닫습니다.'
4246
+ @driver.quit if @driver
4247
+ return 0
4248
+ end
4249
+ rescue
4250
+ end
3973
4251
 
4252
+ begin
4253
+ wait = Selenium::WebDriver::Wait.new(:timeout => 2) # 3초 대기
4254
+ alert = wait.until { @driver.switch_to.alert } # alert가 나타날 때까지 기다림
4255
+ alert.accept # 알림을 확인
4256
+ rescue
4257
+ end
3974
4258
 
3975
-
4259
+
3976
4260
  sleep(1)
4261
+
4262
+
3977
4263
  begin
3978
- puts '-[√] 글쓰기 버튼 클릭이 필수인지 탐색합니다.......'.green
4264
+
3979
4265
  el_post_btn = @driver.find_element(:xpath, '//*[@class="btn btn-primary btn-sm float_r"]')
3980
4266
  @driver.execute_script("arguments[0].scrollIntoView({block: 'center', inline: 'center'})", el_post_btn)
3981
4267
  sleep(1)
3982
4268
  @driver.find_element(:xpath, '//*[@class="btn btn-primary btn-sm float_r"]').click
3983
4269
  sleep(3.7)
3984
- puts '-[√] 글쓰기 버튼 code 1.......'.green
4270
+ puts '-[√] 글쓰기 버튼 클릭 확인 code 1 타겟.......'.green
3985
4271
  rescue
3986
4272
  begin
3987
4273
  el_post_btn = @driver.find_element(:xpath, '//*[@class="btn-block-right"]')
3988
4274
  @driver.execute_script("arguments[0].scrollIntoView({block: 'center', inline: 'center'})", el_post_btn)
3989
4275
  sleep(1)
3990
4276
  @driver.find_element(:xpath, '//*[@class="btn-block-right"]').click
3991
- puts '-[√] 글쓰기 버튼 code 2.......'.green
4277
+ puts '-[√] 글쓰기 버튼 클릭 확인 code 2 타겟.......'.green
3992
4278
  sleep(3.7)
3993
4279
  rescue
3994
4280
  begin
@@ -3996,7 +4282,7 @@ login_url = option['login_url'].to_s
3996
4282
  @driver.execute_script("arguments[0].scrollIntoView({block: 'center', inline: 'center'})", el_post_btn)
3997
4283
  sleep(1)
3998
4284
  @driver.find_element(:xpath, '//*[@class="write_btn"]').click
3999
- puts '-[√] 글쓰기 버튼 code 3.......'.green
4285
+ puts '-[√] 글쓰기 버튼 클릭 확인 code 3 타겟.......'.green
4000
4286
  sleep(3.7)
4001
4287
  rescue
4002
4288
  begin
@@ -4004,7 +4290,7 @@ login_url = option['login_url'].to_s
4004
4290
  @driver.execute_script("arguments[0].scrollIntoView({block: 'center', inline: 'center'})", el_post_btn)
4005
4291
  sleep(1)
4006
4292
  @driver.find_element(:xpath, '//*[@class="gRight"]').click
4007
- puts '-[√] 글쓰기 버튼 code 4.......'.green
4293
+ puts '-[√] 글쓰기 버튼 클릭 확인 code 4 타겟.......'.green
4008
4294
  sleep(3.7)
4009
4295
  rescue
4010
4296
 
@@ -4012,18 +4298,33 @@ login_url = option['login_url'].to_s
4012
4298
  end
4013
4299
  end
4014
4300
  end
4015
-
4301
+
4016
4302
  sleep(1)
4303
+ #오른쪽 마우스 해제 코드
4304
+ begin
4305
+ @driver.execute_script <<-JS
4306
+ document.querySelectorAll('body').forEach(function(element) {
4307
+ element.oncontextmenu = null;
4308
+ });
4309
+ document.removeEventListener('contextmenu', function(e) { e.preventDefault(); }, false);
4310
+ JS
4311
+
4312
+ @driver.execute_script <<-JS
4313
+ document.addEventListener('contextmenu', function(e) {
4314
+ e.stopImmediatePropagation();
4315
+ }, true);
4316
+ JS
4017
4317
 
4018
- ##캡챠 해제 입력 코드 부분─────────────────────────────────────────────────────────────────────>
4318
+ @driver.execute_script("window.oncontextmenu = null;")
4319
+ rescue
4320
+ end
4321
+
4322
+ ##캡챠 해제 입력 코드 부분─────────────────────────────────────────────────────────────────────>
4019
4323
 
4020
- puts '-[√] 1 캡챠 발생 유무 확인.......'.green
4021
- sleep(1)
4022
- puts '-[√] 2 캡챠 발생 유무 확인.......'.green
4023
- sleep(1)
4024
- puts '-[√] 3 캡챠 발생 유무 확인.......'.green
4025
- sleep(1)
4026
4324
 
4325
+ sleep(5)
4326
+
4327
+
4027
4328
  begin
4028
4329
  @driver.find_element(:xpath, '//*[@class="amzn-captcha-state-container"]')
4029
4330
  puts '-[√] 아임웹 캡챠 확인!! 해제 실행.......'.green
@@ -4161,7 +4462,7 @@ login_url = option['login_url'].to_s
4161
4462
  end
4162
4463
  end
4163
4464
  rescue
4164
- puts '-[√] 캡챠 발생 없음.......'.green
4465
+
4165
4466
  end
4166
4467
  end
4167
4468
  end
@@ -4200,6 +4501,7 @@ login_url = option['login_url'].to_s
4200
4501
  rescue => e
4201
4502
  begin
4202
4503
  @driver.switch_to.alert.accept
4504
+ sleep(1)
4203
4505
  rescue
4204
4506
  end
4205
4507
  puts '-[√] 글쓰기 페이지 접속 시도 실패 (페이지 로딩 지연 및 접속 불량).......'.red
@@ -4215,7 +4517,20 @@ login_url = option['login_url'].to_s
4215
4517
  sleep(2)
4216
4518
  rescue
4217
4519
  end
4218
-
4520
+
4521
+ begin
4522
+ # 이 부분을 통해 페이지 내에서 "사이트에 연결할 수 없음" 텍스트를 찾습니다.
4523
+ error_text = @driver.find_element(:xpath, '//*[contains(text(),"사이트에 연결할 수 없음")]')
4524
+ if error_text
4525
+ puts '사이트에 연결할 수 없음 텍스트가 발견되었습니다. 창을 닫습니다.'
4526
+ @driver.quit if @driver
4527
+ return 0
4528
+ end
4529
+ rescue Selenium::WebDriver::Error::NoSuchElementError
4530
+ # 해당 텍스트가 없으면 아무 작업 안함
4531
+ end
4532
+
4533
+
4219
4534
 
4220
4535
  begin
4221
4536
  chat_box = @driver.find_element(:xpath, '//*[@class="adsbygoogle adsbygoogle-noablate"]')
@@ -4354,63 +4669,77 @@ login_url = option['login_url'].to_s
4354
4669
 
4355
4670
 
4356
4671
  ##팝업 코드 확인 및 제거 부분─────────────────────────────────────────────────────────────────────>
4357
- puts '-[√] 팝업 여부 확인 체크 01.......'.yellow
4672
+
4358
4673
 
4359
4674
  begin
4360
4675
  @driver.find_element(:partial_link_text, '더 이상 보지 않기').click #요소같고 텍스트가 다를때 텍스트로 타겟
4361
4676
  sleep(1)
4677
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4362
4678
  rescue
4363
4679
  begin
4364
4680
  @driver.find_element(:xpath, '//*[@class="permanentClose"]').click
4365
4681
  sleep(1)
4682
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4366
4683
  rescue
4367
4684
  begin
4368
4685
  @driver.find_element(:xpath, '//*[@class="close"]').click
4369
4686
  sleep(1)
4687
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4370
4688
  rescue
4371
4689
  begin
4372
4690
  @driver.find_element(:partial_link_text, '닫기').click #요소같고 텍스트가 다를때 텍스트로 타겟
4373
4691
  sleep(1)
4692
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4374
4693
  rescue
4375
4694
  begin
4376
4695
  @driver.find_element(:xpath, '//*[@class="fas fa-angle-down"]').click
4377
4696
  sleep(1)
4697
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4378
4698
  rescue
4379
4699
  begin
4380
4700
  @driver.find_element(:xpath, '//*[@class="fa fa-check-square-o"]').click
4381
4701
  sleep(1)
4702
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4382
4703
  rescue
4383
4704
  begin
4384
4705
  @driver.find_element(:xpath, '//*[@title="Close"]').click
4385
4706
  sleep(1)
4707
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4386
4708
  rescue
4387
4709
  begin
4388
4710
  @driver.find_element(:xpath, '//*[@alt="Close"]').click
4389
4711
  sleep(1)
4712
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4390
4713
  rescue
4391
4714
  begin
4392
4715
  @driver.find_element(:xpath, '//*[@class="sgpb-popup-close-button-1"]').click
4393
4716
  sleep(1)
4717
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4394
4718
  rescue
4395
4719
  begin
4396
4720
  @driver.find_element(:partial_link_text, '시간 동안 다시 열람하지 않습니다.').click
4397
4721
  sleep(1)
4722
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4398
4723
  rescue
4399
4724
  begin
4400
4725
  @driver.find_element(:xpath, '//*[@class="btn skip"]').click
4401
4726
  sleep(1)
4727
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4402
4728
  rescue
4403
4729
  begin
4404
4730
  @driver.find_element(:xpath, '//*[@stroke="#FAFAFA"]').click
4405
4731
  sleep(1)
4732
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4406
4733
  rescue
4407
4734
  begin
4408
4735
  @driver.find_element(:xpath, '//*[@fill="#FAFAFA"]').click
4409
4736
  sleep(1)
4737
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4410
4738
  rescue
4411
4739
  begin
4412
4740
  @driver.find_element(:xpath, '//*[@stroke-linecap="square"]').click
4413
4741
  sleep(1)
4742
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4414
4743
  rescue
4415
4744
  begin
4416
4745
  @driver.switch_to.frame(@driver.find_element(:xpath, '//*[@title="Advertisement"]'))
@@ -4419,29 +4748,35 @@ login_url = option['login_url'].to_s
4419
4748
  sleep(1)
4420
4749
  @driver.switch_to.default_content()
4421
4750
  sleep(1)
4751
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4422
4752
  rescue
4423
4753
  begin
4424
4754
  @driver.find_element(:xpath, '//*[@id="footer-btn-icon"]').click
4425
4755
  sleep(1)
4756
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4426
4757
  rescue
4427
4758
  begin
4428
4759
  @driver.find_element(:xpath, '//*[@id="dismiss-button"]').click
4429
4760
  sleep(1)
4761
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4430
4762
  rescue
4431
4763
  begin
4432
4764
  @driver.find_element(:xpath, '//*[@id="banner"]/div[1]/div/div[1]').click
4433
4765
  sleep(1)
4766
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4434
4767
  rescue
4435
4768
 
4436
4769
  begin
4437
4770
  @driver.find_element(:xpath, '//*[@id="hd_pops_1"]/div[2]/button[1]').click
4438
4771
  sleep(1)
4772
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4439
4773
  rescue
4440
4774
  begin
4441
4775
  @driver.find_element(:xpath, '//*[@class="modal_close"]').click
4442
4776
  sleep(1)
4777
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4443
4778
  rescue
4444
- puts '.......'.yellow
4779
+
4445
4780
 
4446
4781
  end
4447
4782
 
@@ -4472,63 +4807,77 @@ login_url = option['login_url'].to_s
4472
4807
 
4473
4808
  ##<─────────────────────────────────────────────────────────────────────팝업 코드 확인 및 제거 부분
4474
4809
  ##팝업 코드 확인 및 제거 부분─────────────────────────────────────────────────────────────────────>
4475
- puts '-[√] 팝업 여부 확인 체크 02.......'.yellow
4810
+
4476
4811
 
4477
4812
  begin
4478
4813
  @driver.find_element(:partial_link_text, '더 이상 보지 않기').click #요소같고 텍스트가 다를때 텍스트로 타겟
4479
4814
  sleep(1)
4815
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4480
4816
  rescue
4481
4817
  begin
4482
4818
  @driver.find_element(:xpath, '//*[@class="permanentClose"]').click
4483
4819
  sleep(1)
4820
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4484
4821
  rescue
4485
4822
  begin
4486
4823
  @driver.find_element(:xpath, '//*[@class="close"]').click
4487
4824
  sleep(1)
4825
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4488
4826
  rescue
4489
4827
  begin
4490
4828
  @driver.find_element(:partial_link_text, '닫기').click #요소같고 텍스트가 다를때 텍스트로 타겟
4491
4829
  sleep(1)
4830
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4492
4831
  rescue
4493
4832
  begin
4494
4833
  @driver.find_element(:xpath, '//*[@class="fas fa-angle-down"]').click
4495
4834
  sleep(1)
4835
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4496
4836
  rescue
4497
4837
  begin
4498
4838
  @driver.find_element(:xpath, '//*[@class="fa fa-check-square-o"]').click
4499
4839
  sleep(1)
4840
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4500
4841
  rescue
4501
4842
  begin
4502
4843
  @driver.find_element(:xpath, '//*[@title="Close"]').click
4503
4844
  sleep(1)
4845
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4504
4846
  rescue
4505
4847
  begin
4506
4848
  @driver.find_element(:xpath, '//*[@alt="Close"]').click
4507
4849
  sleep(1)
4850
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4508
4851
  rescue
4509
4852
  begin
4510
4853
  @driver.find_element(:xpath, '//*[@class="sgpb-popup-close-button-1"]').click
4511
4854
  sleep(1)
4855
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4512
4856
  rescue
4513
4857
  begin
4514
4858
  @driver.find_element(:partial_link_text, '시간 동안 다시 열람하지 않습니다.').click
4515
4859
  sleep(1)
4860
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4516
4861
  rescue
4517
4862
  begin
4518
4863
  @driver.find_element(:xpath, '//*[@class="btn skip"]').click
4519
4864
  sleep(1)
4865
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4520
4866
  rescue
4521
4867
  begin
4522
4868
  @driver.find_element(:xpath, '//*[@stroke="#FAFAFA"]').click
4523
4869
  sleep(1)
4870
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4524
4871
  rescue
4525
4872
  begin
4526
4873
  @driver.find_element(:xpath, '//*[@fill="#FAFAFA"]').click
4527
4874
  sleep(1)
4875
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4528
4876
  rescue
4529
4877
  begin
4530
4878
  @driver.find_element(:xpath, '//*[@stroke-linecap="square"]').click
4531
4879
  sleep(1)
4880
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4532
4881
  rescue
4533
4882
  begin
4534
4883
  @driver.switch_to.frame(@driver.find_element(:xpath, '//*[@title="Advertisement"]'))
@@ -4537,25 +4886,29 @@ login_url = option['login_url'].to_s
4537
4886
  sleep(1)
4538
4887
  @driver.switch_to.default_content()
4539
4888
  sleep(1)
4889
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4540
4890
  rescue
4541
4891
  begin
4542
4892
  @driver.find_element(:xpath, '//*[@id="footer-btn-icon"]').click
4543
4893
  sleep(1)
4894
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4544
4895
  rescue
4545
4896
  begin
4546
4897
  @driver.find_element(:xpath, '//*[@id="dismiss-button"]').click
4547
4898
  sleep(1)
4899
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4548
4900
  rescue
4549
4901
  begin
4550
4902
  @driver.find_element(:xpath, '//*[@id="banner"]/div[2]/div/div[1]').click
4551
4903
  sleep(1)
4904
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4552
4905
  rescue
4553
4906
  begin
4554
4907
  @driver.find_element(:xpath, '//*[@id="hd_pops_2"]/div[2]/button[1]').click
4555
4908
  sleep(1)
4556
-
4909
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4557
4910
  rescue
4558
- puts '.......'.yellow
4911
+
4559
4912
 
4560
4913
  end
4561
4914
 
@@ -4585,63 +4938,76 @@ login_url = option['login_url'].to_s
4585
4938
  end
4586
4939
  ##<─────────────────────────────────────────────────────────────────────팝업 코드 확인 및 제거 부분
4587
4940
  ##팝업 코드 확인 및 제거 부분─────────────────────────────────────────────────────────────────────>
4588
- puts '-[√] 팝업 여부 확인 체크 03.......'.yellow
4589
4941
 
4590
4942
  begin
4591
4943
  @driver.find_element(:partial_link_text, '더 이상 보지 않기').click #요소같고 텍스트가 다를때 텍스트로 타겟
4592
4944
  sleep(1)
4945
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4593
4946
  rescue
4594
4947
  begin
4595
4948
  @driver.find_element(:xpath, '//*[@class="permanentClose"]').click
4596
4949
  sleep(1)
4950
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4597
4951
  rescue
4598
4952
  begin
4599
4953
  @driver.find_element(:xpath, '//*[@class="close"]').click
4600
4954
  sleep(1)
4955
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4601
4956
  rescue
4602
4957
  begin
4603
4958
  @driver.find_element(:partial_link_text, '닫기').click #요소같고 텍스트가 다를때 텍스트로 타겟
4604
4959
  sleep(1)
4960
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4605
4961
  rescue
4606
4962
  begin
4607
4963
  @driver.find_element(:xpath, '//*[@class="fas fa-angle-down"]').click
4608
4964
  sleep(1)
4965
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4609
4966
  rescue
4610
4967
  begin
4611
4968
  @driver.find_element(:xpath, '//*[@class="fa fa-check-square-o"]').click
4612
4969
  sleep(1)
4970
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4613
4971
  rescue
4614
4972
  begin
4615
4973
  @driver.find_element(:xpath, '//*[@title="Close"]').click
4616
4974
  sleep(1)
4975
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4617
4976
  rescue
4618
4977
  begin
4619
4978
  @driver.find_element(:xpath, '//*[@alt="Close"]').click
4620
4979
  sleep(1)
4980
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4621
4981
  rescue
4622
4982
  begin
4623
4983
  @driver.find_element(:xpath, '//*[@class="sgpb-popup-close-button-1"]').click
4624
4984
  sleep(1)
4985
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4625
4986
  rescue
4626
4987
  begin
4627
4988
  @driver.find_element(:partial_link_text, '시간 동안 다시 열람하지 않습니다.').click
4628
4989
  sleep(1)
4990
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4629
4991
  rescue
4630
4992
  begin
4631
4993
  @driver.find_element(:xpath, '//*[@class="btn skip"]').click
4632
4994
  sleep(1)
4995
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4633
4996
  rescue
4634
4997
  begin
4635
4998
  @driver.find_element(:xpath, '//*[@stroke="#FAFAFA"]').click
4636
4999
  sleep(1)
5000
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4637
5001
  rescue
4638
5002
  begin
4639
5003
  @driver.find_element(:xpath, '//*[@fill="#FAFAFA"]').click
4640
5004
  sleep(1)
5005
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4641
5006
  rescue
4642
5007
  begin
4643
5008
  @driver.find_element(:xpath, '//*[@stroke-linecap="square"]').click
4644
5009
  sleep(1)
5010
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4645
5011
  rescue
4646
5012
  begin
4647
5013
  @driver.switch_to.frame(@driver.find_element(:xpath, '//*[@title="Advertisement"]'))
@@ -4650,24 +5016,29 @@ login_url = option['login_url'].to_s
4650
5016
  sleep(1)
4651
5017
  @driver.switch_to.default_content()
4652
5018
  sleep(1)
5019
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4653
5020
  rescue
4654
5021
  begin
4655
5022
  @driver.find_element(:xpath, '//*[@id="footer-btn-icon"]').click
4656
5023
  sleep(1)
5024
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4657
5025
  rescue
4658
5026
  begin
4659
5027
  @driver.find_element(:xpath, '//*[@id="dismiss-button"]').click
4660
5028
  sleep(1)
5029
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4661
5030
  rescue
4662
5031
  begin
4663
5032
  @driver.find_element(:xpath, '//*[@id="banner"]/div[3]/div/div[1]').click
4664
5033
  sleep(1)
5034
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4665
5035
  rescue
4666
5036
  begin
4667
5037
  @driver.find_element(:xpath, '//*[@id="hd_pops_3"]/div[2]/button[1]').click
4668
5038
  sleep(1)
5039
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4669
5040
  rescue
4670
- puts '.......'.yellow
5041
+
4671
5042
 
4672
5043
  end
4673
5044
 
@@ -4697,63 +5068,77 @@ login_url = option['login_url'].to_s
4697
5068
  end
4698
5069
  ##<─────────────────────────────────────────────────────────────────────팝업 코드 확인 및 제거 부분
4699
5070
  ##팝업 코드 확인 및 제거 부분─────────────────────────────────────────────────────────────────────>
4700
- puts '-[√] 팝업 여부 확인 체크 04.......'.yellow
5071
+
4701
5072
 
4702
5073
  begin
4703
5074
  @driver.find_element(:partial_link_text, '더 이상 보지 않기').click #요소같고 텍스트가 다를때 텍스트로 타겟
4704
5075
  sleep(1)
5076
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4705
5077
  rescue
4706
5078
  begin
4707
5079
  @driver.find_element(:xpath, '//*[@class="permanentClose"]').click
4708
5080
  sleep(1)
5081
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4709
5082
  rescue
4710
5083
  begin
4711
5084
  @driver.find_element(:xpath, '//*[@class="close"]').click
4712
5085
  sleep(1)
5086
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4713
5087
  rescue
4714
5088
  begin
4715
5089
  @driver.find_element(:partial_link_text, '닫기').click #요소같고 텍스트가 다를때 텍스트로 타겟
4716
5090
  sleep(1)
5091
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4717
5092
  rescue
4718
5093
  begin
4719
5094
  @driver.find_element(:xpath, '//*[@class="fas fa-angle-down"]').click
4720
5095
  sleep(1)
5096
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4721
5097
  rescue
4722
5098
  begin
4723
5099
  @driver.find_element(:xpath, '//*[@class="fa fa-check-square-o"]').click
4724
5100
  sleep(1)
5101
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4725
5102
  rescue
4726
5103
  begin
4727
5104
  @driver.find_element(:xpath, '//*[@title="Close"]').click
4728
5105
  sleep(1)
5106
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4729
5107
  rescue
4730
5108
  begin
4731
5109
  @driver.find_element(:xpath, '//*[@alt="Close"]').click
4732
5110
  sleep(1)
5111
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4733
5112
  rescue
4734
5113
  begin
4735
5114
  @driver.find_element(:xpath, '//*[@class="sgpb-popup-close-button-1"]').click
4736
5115
  sleep(1)
5116
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4737
5117
  rescue
4738
5118
  begin
4739
5119
  @driver.find_element(:partial_link_text, '시간 동안 다시 열람하지 않습니다.').click
4740
5120
  sleep(1)
5121
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4741
5122
  rescue
4742
5123
  begin
4743
5124
  @driver.find_element(:xpath, '//*[@class="btn skip"]').click
4744
5125
  sleep(1)
5126
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4745
5127
  rescue
4746
5128
  begin
4747
5129
  @driver.find_element(:xpath, '//*[@stroke="#FAFAFA"]').click
4748
5130
  sleep(1)
5131
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4749
5132
  rescue
4750
5133
  begin
4751
5134
  @driver.find_element(:xpath, '//*[@fill="#FAFAFA"]').click
4752
5135
  sleep(1)
5136
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4753
5137
  rescue
4754
5138
  begin
4755
5139
  @driver.find_element(:xpath, '//*[@stroke-linecap="square"]').click
4756
5140
  sleep(1)
5141
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4757
5142
  rescue
4758
5143
  begin
4759
5144
  @driver.switch_to.frame(@driver.find_element(:xpath, '//*[@title="Advertisement"]'))
@@ -4762,24 +5147,29 @@ login_url = option['login_url'].to_s
4762
5147
  sleep(1)
4763
5148
  @driver.switch_to.default_content()
4764
5149
  sleep(1)
5150
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4765
5151
  rescue
4766
5152
  begin
4767
5153
  @driver.find_element(:xpath, '//*[@id="footer-btn-icon"]').click
4768
5154
  sleep(1)
5155
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4769
5156
  rescue
4770
5157
  begin
4771
5158
  @driver.find_element(:xpath, '//*[@id="dismiss-button"]').click
4772
5159
  sleep(1)
5160
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4773
5161
  rescue
4774
5162
  begin
4775
5163
  @driver.find_element(:xpath, '//*[@id="banner"]/div[4]/div/div[1]').click
4776
5164
  sleep(1)
5165
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4777
5166
  rescue
4778
5167
  begin
4779
5168
  @driver.find_element(:xpath, '//*[@id="hd_pops_4"]/div[2]/button[1]').click
4780
5169
  sleep(1)
5170
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4781
5171
  rescue
4782
- puts '.......'.yellow
5172
+
4783
5173
 
4784
5174
  end
4785
5175
 
@@ -4809,63 +5199,77 @@ login_url = option['login_url'].to_s
4809
5199
  end
4810
5200
  ##<─────────────────────────────────────────────────────────────────────팝업 코드 확인 및 제거 부분
4811
5201
  ##팝업 코드 확인 및 제거 부분─────────────────────────────────────────────────────────────────────>
4812
- puts '-[√] 팝업 여부 확인 체크 05.......'.yellow
5202
+
4813
5203
 
4814
5204
  begin
4815
5205
  @driver.find_element(:partial_link_text, '더 이상 보지 않기').click #요소같고 텍스트가 다를때 텍스트로 타겟
4816
5206
  sleep(1)
5207
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4817
5208
  rescue
4818
5209
  begin
4819
5210
  @driver.find_element(:xpath, '//*[@class="permanentClose"]').click
4820
5211
  sleep(1)
5212
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4821
5213
  rescue
4822
5214
  begin
4823
5215
  @driver.find_element(:xpath, '//*[@class="close"]').click
4824
5216
  sleep(1)
5217
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4825
5218
  rescue
4826
5219
  begin
4827
5220
  @driver.find_element(:partial_link_text, '닫기').click #요소같고 텍스트가 다를때 텍스트로 타겟
4828
5221
  sleep(1)
5222
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4829
5223
  rescue
4830
5224
  begin
4831
5225
  @driver.find_element(:xpath, '//*[@class="fas fa-angle-down"]').click
4832
5226
  sleep(1)
5227
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4833
5228
  rescue
4834
5229
  begin
4835
5230
  @driver.find_element(:xpath, '//*[@class="fa fa-check-square-o"]').click
4836
5231
  sleep(1)
5232
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4837
5233
  rescue
4838
5234
  begin
4839
5235
  @driver.find_element(:xpath, '//*[@title="Close"]').click
4840
5236
  sleep(1)
5237
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4841
5238
  rescue
4842
5239
  begin
4843
5240
  @driver.find_element(:xpath, '//*[@alt="Close"]').click
4844
5241
  sleep(1)
5242
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4845
5243
  rescue
4846
5244
  begin
4847
5245
  @driver.find_element(:xpath, '//*[@class="sgpb-popup-close-button-1"]').click
4848
5246
  sleep(1)
5247
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4849
5248
  rescue
4850
5249
  begin
4851
5250
  @driver.find_element(:partial_link_text, '시간 동안 다시 열람하지 않습니다.').click
4852
5251
  sleep(1)
5252
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4853
5253
  rescue
4854
5254
  begin
4855
5255
  @driver.find_element(:xpath, '//*[@class="btn skip"]').click
4856
5256
  sleep(1)
5257
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4857
5258
  rescue
4858
5259
  begin
4859
5260
  @driver.find_element(:xpath, '//*[@stroke="#FAFAFA"]').click
4860
5261
  sleep(1)
5262
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4861
5263
  rescue
4862
5264
  begin
4863
5265
  @driver.find_element(:xpath, '//*[@fill="#FAFAFA"]').click
4864
5266
  sleep(1)
5267
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4865
5268
  rescue
4866
5269
  begin
4867
5270
  @driver.find_element(:xpath, '//*[@stroke-linecap="square"]').click
4868
5271
  sleep(1)
5272
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4869
5273
  rescue
4870
5274
  begin
4871
5275
  @driver.switch_to.frame(@driver.find_element(:xpath, '//*[@title="Advertisement"]'))
@@ -4874,22 +5278,27 @@ login_url = option['login_url'].to_s
4874
5278
  sleep(1)
4875
5279
  @driver.switch_to.default_content()
4876
5280
  sleep(1)
5281
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4877
5282
  rescue
4878
5283
  begin
4879
5284
  @driver.find_element(:xpath, '//*[@id="footer-btn-icon"]').click
4880
5285
  sleep(1)
5286
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4881
5287
  rescue
4882
5288
  begin
4883
5289
  @driver.find_element(:xpath, '//*[@id="dismiss-button"]').click
4884
5290
  sleep(1)
5291
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4885
5292
  rescue
4886
5293
  begin
4887
5294
  @driver.find_element(:xpath, '//*[@id="banner"]/div[5]/div/div[1]').click
4888
5295
  sleep(1)
5296
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4889
5297
  rescue
4890
5298
  begin
4891
5299
  @driver.find_element(:xpath, '//*[@id="hd_pops_5"]/div[2]/button[1]').click
4892
5300
  sleep(1)
5301
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4893
5302
  rescue
4894
5303
  begin
4895
5304
  @driver.switch_to.frame(@driver.find_element(:xpath, '//*[@id="aswift_1"]'))
@@ -4898,8 +5307,9 @@ login_url = option['login_url'].to_s
4898
5307
  sleep(1)
4899
5308
  @driver.switch_to.default_content
4900
5309
  sleep(1)
5310
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4901
5311
  rescue
4902
- puts '.......'.yellow
5312
+
4903
5313
 
4904
5314
  end
4905
5315
 
@@ -4937,7 +5347,7 @@ login_url = option['login_url'].to_s
4937
5347
 
4938
5348
 
4939
5349
  ##닉네임 입력 코드 부분─────────────────────────────────────────────────────────────────────>
4940
- puts '-[√] 닉네임 입력 가능 여부 체크.......'.yellow
5350
+
4941
5351
 
4942
5352
  begin
4943
5353
  @driver.find_element(:xpath, '//*[@id="wr_name"]').send_keys(user_id)
@@ -4950,115 +5360,114 @@ begin
4950
5360
  puts '-[√] 닉네임 2코드 타겟.......'.yellow
4951
5361
  rescue
4952
5362
  begin
4953
- begin
4954
- @driver.find_element(:xpath, '//*[@name="member_display"]').send_keys(user_id)
4955
- sleep(1)
4956
- puts '-[√] 닉네임 3-1코드 타겟.......'.yellow
4957
- rescue
4958
- rows = @driver.find_elements(class: 'kboard-attr-row')
4959
- rows.each do |row|
4960
- begin
4961
- input_element = row.find_element(xpath: './/input[@name="member_display"]')
4962
- input_element.send_keys(user_id)
4963
- sleep(1)
4964
- puts '-[√] 닉네임 3-2코드 타겟.......'.yellow
4965
- rescue
4966
- next
4967
- end
4968
- end
4969
- end
5363
+ @driver.find_element(:xpath, '//*[@name="member_display"]').send_keys(user_id)
5364
+ sleep(1)
5365
+ puts '-[√] 닉네임 3-1코드 타겟.......'.yellow
4970
5366
  rescue
4971
5367
  begin
4972
- @driver.find_element(:xpath, '//*[@title="닉네임"]').send_keys(user_id)
5368
+ @driver.find_element(xpath: '//input[@name="member_display"]').send_keys(user_id)
4973
5369
  sleep(1)
4974
- puts '-[√] 닉네임 4코드 타겟.......'.yellow
5370
+ puts '-[√] 닉네임 3-2코드 타겟.......'.yellow
4975
5371
  rescue
4976
5372
  begin
4977
- @driver.find_element(:xpath, '//*[@name="name"]').send_keys(user_id)
5373
+ @driver.find_element(:xpath, '//*[@title="닉네임"]').send_keys(user_id)
4978
5374
  sleep(1)
4979
- puts '-[√] 닉네임 5코드 타겟.......'.yellow
5375
+ puts '-[√] 닉네임 4코드 타겟.......'.yellow
4980
5376
  rescue
4981
5377
  begin
4982
- @driver.find_element(:xpath, '//*[@name="writer"]').send_keys(user_id)
5378
+ @driver.find_element(:xpath, '//*[@name="name"]').send_keys(user_id)
4983
5379
  sleep(1)
4984
- puts '-[√] 닉네임 6코드 타겟.......'.yellow
5380
+ puts '-[√] 닉네임 5코드 타겟.......'.yellow
4985
5381
  rescue
4986
5382
  begin
4987
- @driver.find_element(:xpath, '//*[@name="hname"]').send_keys(user_id)
5383
+ @driver.find_element(:xpath, '//*[@name="writer"]').send_keys(user_id)
4988
5384
  sleep(1)
4989
- puts '-[√] 닉네임 7코드 타겟.......'.yellow
5385
+ puts '-[√] 닉네임 6코드 타겟.......'.yellow
4990
5386
  rescue
4991
5387
  begin
4992
- @driver.find_element(:xpath, '//*[@name="wr_name"]').send_keys(user_id)
5388
+ @driver.find_element(:xpath, '//*[@name="hname"]').send_keys(user_id)
4993
5389
  sleep(1)
4994
- puts '-[√] 닉네임 8코드 타겟.......'.yellow
5390
+ puts '-[√] 닉네임 7코드 타겟.......'.yellow
4995
5391
  rescue
4996
5392
  begin
4997
- @driver.find_element(:xpath, '//*[@name="post_nickname"]').send_keys(user_id)
5393
+ @driver.find_element(:xpath, '//*[@name="wr_name"]').send_keys(user_id)
4998
5394
  sleep(1)
4999
- puts '-[√] 닉네임 9코드 타겟.......'.yellow
5395
+ puts '-[√] 닉네임 8코드 타겟.......'.yellow
5000
5396
  rescue
5001
5397
  begin
5002
- @driver.find_element(:xpath, '//*[@name="user_name"]').send_keys(user_id)
5398
+ @driver.find_element(:xpath, '//*[@name="post_nickname"]').send_keys(user_id)
5003
5399
  sleep(1)
5004
- puts '-[√] 닉네임 10코드 타겟.......'.yellow
5400
+ puts '-[√] 닉네임 9코드 타겟.......'.yellow
5005
5401
  rescue
5006
5402
  begin
5007
- @driver.find_element(:xpath, '//*[@class="mb-user-name"]').send_keys(user_id)
5403
+ @driver.find_element(:xpath, '//*[@name="user_name"]').send_keys(user_id)
5008
5404
  sleep(1)
5009
- puts '-[√] 닉네임 11코드 타겟.......'.yellow
5405
+ puts '-[√] 닉네임 10코드 타겟.......'.yellow
5010
5406
  rescue
5011
5407
  begin
5012
- @driver.find_element(:xpath, '//*[@placeholder="비회원 닉네임"]').send_keys(user_id)
5408
+ @driver.find_element(:xpath, '//*[@class="mb-user-name"]').send_keys(user_id)
5013
5409
  sleep(1)
5014
- puts '-[√] 닉네임 12코드 타겟.......'.yellow
5410
+ puts '-[√] 닉네임 11코드 타겟.......'.yellow
5015
5411
  rescue
5016
5412
  begin
5017
- @driver.find_element(:xpath, '//*[@placeholder="이름"]').send_keys(user_id)
5413
+ @driver.find_element(:xpath, '//*[@placeholder="비회원 닉네임"]').send_keys(user_id)
5018
5414
  sleep(1)
5019
- puts '-[√] 닉네임 13코드 타겟.......'.yellow
5415
+ puts '-[√] 닉네임 12코드 타겟.......'.yellow
5020
5416
  rescue
5021
5417
  begin
5022
- @driver.find_element(:xpath, '//*[@name="nickname"]').send_keys(user_id)
5418
+ @driver.find_element(:xpath, '//*[@placeholder="이름"]').send_keys(user_id)
5023
5419
  sleep(1)
5024
- puts '-[√] 닉네임 14코드 타겟.......'.yellow
5420
+ puts '-[√] 닉네임 13코드 타겟.......'.yellow
5025
5421
  rescue
5026
5422
  begin
5027
- @driver.find_element(:xpath, '//*[@name="nick"]').send_keys(user_id)
5423
+ @driver.find_element(:xpath, '//*[@name="nickname"]').send_keys(user_id)
5028
5424
  sleep(1)
5029
- puts '-[√] 닉네임 15코드 타겟.......'.yellow
5425
+ puts '-[√] 닉네임 14코드 타겟.......'.yellow
5030
5426
  rescue
5031
5427
  begin
5032
- @driver.find_element(:xpath, '//*[@placeholder="작성자 이름"]').send_keys(user_id)
5428
+ @driver.find_element(:xpath, '//*[@name="nick"]').send_keys(user_id)
5033
5429
  sleep(1)
5034
- puts '-[√] 닉네임 16코드 타겟.......'.yellow
5430
+ puts '-[√] 닉네임 15코드 타겟.......'.yellow
5035
5431
  rescue
5036
5432
  begin
5037
- @driver.find_element(:xpath, '//*[@id="reg_name"]').send_keys(user_id)
5433
+ @driver.find_element(:xpath, '//*[@placeholder="작성자 이름"]').send_keys(user_id)
5038
5434
  sleep(1)
5039
- puts '-[√] 닉네임 17코드 타겟.......'.yellow
5435
+ puts '-[√] 닉네임 16코드 타겟.......'.yellow
5040
5436
  rescue
5041
5437
  begin
5042
- @driver.find_element(:xpath, '//*[@id="postWriter"]').send_keys(user_id)
5438
+ @driver.find_element(:xpath, '//*[@id="reg_name"]').send_keys(user_id)
5043
5439
  sleep(1)
5044
- puts '-[√] 닉네임 18코드 타겟.......'.yellow
5440
+ puts '-[√] 닉네임 17코드 타겟.......'.yellow
5045
5441
  rescue
5046
5442
  begin
5047
- @driver.find_element(:xpath, '//*[@id="kboard-input-member-display"]').send_keys(user_id)
5443
+ @driver.find_element(:xpath, '//*[@id="postWriter"]').send_keys(user_id)
5048
5444
  sleep(1)
5049
- puts '-[√] 닉네임 19코드 타겟.......'.yellow
5445
+ puts '-[√] 닉네임 18코드 타겟.......'.yellow
5050
5446
  rescue
5051
5447
  begin
5052
- @driver.find_element(:xpath, '//*[@name="nick_name"]').send_keys(user_id)
5448
+ @driver.find_element(:xpath, '//*[@id="kboard-input-member-display"]').send_keys(user_id)
5053
5449
  sleep(1)
5054
- puts '-[√] 닉네임 20코드 타겟.......'.yellow
5450
+ puts '-[√] 닉네임 19코드 타겟.......'.yellow
5055
5451
  rescue
5056
5452
  begin
5057
- @driver.find_element(:xpath, '//*[@name="write_name"]').send_keys(user_id)
5453
+ @driver.find_element(:xpath, '//*[@name="nick_name"]').send_keys(user_id)
5058
5454
  sleep(1)
5059
- puts '-[√] 닉네임 21코드 타겟.......'.yellow
5455
+ puts '-[√] 닉네임 20코드 타겟.......'.yellow
5060
5456
  rescue
5061
-
5457
+ begin
5458
+ @driver.find_element(:xpath, '//*[@name="write_name"]').send_keys(user_id)
5459
+ sleep(1)
5460
+ puts '-[√] 닉네임 21코드 타겟.......'.yellow
5461
+ rescue
5462
+ begin
5463
+ @driver.find_element(:xpath, '//*[@placeholder="작성자"]').send_keys(user_id)
5464
+ sleep(1)
5465
+ puts '-[√] 닉네임 22코드 타겟.......'.yellow
5466
+ rescue
5467
+
5468
+ end
5469
+
5470
+ end
5062
5471
  end
5063
5472
  end
5064
5473
  end
@@ -5079,13 +5488,13 @@ begin
5079
5488
  end
5080
5489
  end
5081
5490
  end
5082
- puts '-[√] 닉네임 입력 가능 여부 종료.......'.yellow
5491
+
5083
5492
  end
5084
5493
  ##<─────────────────────────────────────────────────────────────────────닉네임 입력 코드 부분
5085
5494
 
5086
5495
 
5087
5496
  ##패스워드 입력 코드 부분─────────────────────────────────────────────────────────────────────>
5088
- puts '-[√] 패스워드 입력 가능 여부 체크.......'.yellow
5497
+
5089
5498
  begin
5090
5499
  @driver.find_element(:xpath, '//*[@id="wr_password"]').send_keys(user_pw)
5091
5500
  sleep(1)
@@ -5176,7 +5585,7 @@ begin
5176
5585
  end
5177
5586
  end
5178
5587
  end
5179
- puts '-[√] 패스워드 입력 가능 여부 종료.......'.yellow
5588
+
5180
5589
  sleep(1)
5181
5590
  end
5182
5591
  ##<─────────────────────────────────────────────────────────────────────패스워드 입력 코드 부분
@@ -5221,7 +5630,7 @@ begin
5221
5630
  @driver.find_element(:xpath, '//*[@name="wr_10"]').send_keys(more_txt1)
5222
5631
  sleep(1)
5223
5632
  rescue
5224
- puts '-[√] 기타 입력 부분 탐색 1차 코드 탐색 종료.......'.yellow
5633
+
5225
5634
 
5226
5635
  end
5227
5636
 
@@ -5257,7 +5666,7 @@ begin
5257
5666
  @driver.find_element(:xpath, '//*[@name="wr_11"]').send_keys(more_txt1)
5258
5667
  sleep(1)
5259
5668
  rescue
5260
- puts '-[√] 기타 입력 부분 탐색 1차 코드 탐색 종료.......'.yellow
5669
+
5261
5670
 
5262
5671
  end
5263
5672
 
@@ -5293,7 +5702,7 @@ begin
5293
5702
  @driver.find_element(:xpath, '//*[@name="wr_12"]').send_keys(more_txt1)
5294
5703
  sleep(1)
5295
5704
  rescue
5296
- puts '-[√] 기타 입력 부분 탐색 1차 코드 탐색 종료.......'.yellow
5705
+
5297
5706
 
5298
5707
  end
5299
5708
 
@@ -5329,7 +5738,7 @@ begin
5329
5738
  @driver.find_element(:xpath, '//*[@name="wr_13"]').send_keys(more_txt1)
5330
5739
  sleep(1)
5331
5740
  rescue
5332
- puts '-[√] 기타 입력 부분 탐색 1차 코드 탐색 종료.......'.yellow
5741
+
5333
5742
 
5334
5743
  end
5335
5744
 
@@ -5365,7 +5774,7 @@ begin
5365
5774
  @driver.find_element(:xpath, '//*[@name="wr_14"]').send_keys(more_txt1)
5366
5775
  sleep(1)
5367
5776
  rescue
5368
- puts '-[√] 기타 입력 부분 탐색 1차 코드 탐색 종료.......'.yellow
5777
+
5369
5778
 
5370
5779
  end
5371
5780
 
@@ -5480,7 +5889,7 @@ begin
5480
5889
 
5481
5890
 
5482
5891
  ##체크박스 코드 부분─────────────────────────────────────────────────────────────────────>
5483
- puts '-[√] 체크 항목 탐색 시작.......'.yellow
5892
+ #puts '-[√] 체크 항목 탐색 시작.......'.yellow
5484
5893
  begin
5485
5894
  @driver.find_element(:xpath, '//*[@fw-label="개인정보보호정책"]').click
5486
5895
  sleep(1)
@@ -5558,12 +5967,12 @@ begin
5558
5967
 
5559
5968
  title = title.strip
5560
5969
  ##제목 입력 코드 부분─────────────────────────────────────────────────────────────────────>
5561
- puts '-[√] 제목 입력 필드 탐색 시작.......'.yellow
5970
+ #puts '-[√] 제목 입력 필드 탐색 시작.......'.yellow
5562
5971
 
5563
5972
  begin
5564
5973
  @driver.find_element(:xpath, '//*[@id="wr_subject"]').click
5565
5974
  sleep(1)
5566
- @driver.find_element(:xpath, '//*[@id="wr_subject"]').send_keys(:title)
5975
+ @driver.find_element(:xpath, '//*[@id="wr_subject"]').send_keys(title)
5567
5976
  puts '-[√] 제목 code 1.......'.yellow
5568
5977
  rescue
5569
5978
  begin
@@ -5666,7 +6075,7 @@ begin
5666
6075
  ########################################################2차@#######################################
5667
6076
  begin
5668
6077
 
5669
- @driver.find_element(:xpath, '//*[@id="wr_subject"]').send_keys(:title)
6078
+ @driver.find_element(:xpath, '//*[@id="wr_subject"]').send_keys(title)
5670
6079
  puts '-[√] 제목 code 19.......'.yellow
5671
6080
  rescue
5672
6081
  begin
@@ -5827,14 +6236,14 @@ begin
5827
6236
  end
5828
6237
  end
5829
6238
 
5830
- puts '-[√] 제목 입력 필드 탐색 종료.......'.yellow
6239
+ #puts '-[√] 제목 입력 필드 탐색 종료.......'.yellow
5831
6240
  sleep(1)
5832
6241
  ##<─────────────────────────────────────────────────────────────────────제목 입력 코드 부분
5833
6242
 
5834
6243
 
5835
6244
  ##HTML 버튼 코드 부분─────────────────────────────────────────────────────────────────────>
5836
- puts '-[√] HTML 코드 변경 버튼 탐색 시작.......'.yellow
5837
- sleep(1)
6245
+ # puts '-[√] HTML 코드 변경 버튼 탐색 시작.......'.yellow
6246
+
5838
6247
  begin
5839
6248
  #아이프레임에서 코드 선택
5840
6249
  @driver.switch_to.frame(@driver.find_element(:xpath, '//*[@scrolling="no"]'))
@@ -6094,13 +6503,12 @@ begin
6094
6503
  end
6095
6504
  end
6096
6505
 
6097
- puts '-[√] HTML 코드 변경 버튼 탐색 종료.......'.yellow
6098
- sleep(1)
6099
-
6506
+
6100
6507
 
6101
6508
  begin
6102
6509
  sleep(2)
6103
6510
  @driver.switch_to.alert.accept
6511
+ sleep(1)
6104
6512
  rescue
6105
6513
  sleep(1)
6106
6514
  end
@@ -6112,8 +6520,8 @@ begin
6112
6520
 
6113
6521
 
6114
6522
  ##내용 입력 필드 코드 부분─────────────────────────────────────────────────────────────────────>
6115
- puts '-[√] 내용 입력 부분 탐색 시작.......'.yellow
6116
- sleep(1)
6523
+ #puts '-[√] 내용 입력 부분 탐색 시작.......'.yellow
6524
+ #sleep(1)
6117
6525
  begin
6118
6526
  @driver.find_element(:xpath, '//*[@name="content"]').click
6119
6527
  sleep(1)
@@ -6337,20 +6745,7 @@ rescue
6337
6745
  sleep(1)
6338
6746
  puts '내용 항목 코드 타겟 39.......'.red
6339
6747
  rescue
6340
- begin
6341
- dev_tools = driver.execute_cdp_cmd('Emulate.DeviceMetrics', {
6342
- 'width' => 375, # 모바일 화면 너비 (예: iPhone X 너비)
6343
- 'height' => 667, # 모바일 화면 높이
6344
- 'deviceScaleFactor' => 3.0, # 화면 비율
6345
- 'mobile' => true # 모바일 모드 활성화
6346
- })
6347
- sleep(1)
6348
- @driver.find_element(:xpath, '//textarea[@name="kboard_content"]').click
6349
- sleep(1)
6350
- puts '내용 항목 코드 타겟 40.......'.red
6351
- rescue
6352
-
6353
- end
6748
+
6354
6749
  end
6355
6750
  end
6356
6751
  end
@@ -6392,9 +6787,9 @@ rescue
6392
6787
  end
6393
6788
  end
6394
6789
 
6395
- puts '-[√] 내용 입력 부분 탐색 종료.......'.yellow
6396
- end
6397
- sleep(1)
6790
+
6791
+ end
6792
+ sleep(1)
6398
6793
 
6399
6794
  ##<─────────────────────────────────────────────────────────────────────내용 입력 필드 코드 부분
6400
6795
 
@@ -6407,7 +6802,7 @@ rescue
6407
6802
  end
6408
6803
  ##<<─────────────────────────────────────────────────────────────────────내용 임시부분 제거
6409
6804
 
6410
- puts '-[√] 포스팅할 내용 준비.......'.cyan
6805
+
6411
6806
  puts content
6412
6807
  noko = Nokogiri::HTML(content, nil, Encoding::UTF_8.to_s)
6413
6808
  toomung = 0
@@ -6415,7 +6810,7 @@ end
6415
6810
 
6416
6811
  sleep(1)
6417
6812
  data = Hash.new
6418
- puts '-[√] 내용 등록 마무리 진행 중.......'.cyan
6813
+
6419
6814
 
6420
6815
 
6421
6816
 
@@ -7389,42 +7784,106 @@ end
7389
7784
 
7390
7785
 
7391
7786
 
7392
- #@driver.action.key_down(:tab).key_up(:tab).perform #x탭
7787
+ begin
7788
+
7789
+ @driver.find_element(:xpath, '//*[@class="captcha-solver captcha-solver_inner"]')
7790
+ check_captcha = 1
7393
7791
 
7792
+ rescue
7793
+ check_captcha = 0
7794
+ end
7394
7795
 
7395
- sleep(1)
7396
- ##캡챠 이미지,2캡챠,,등등 코드 부분─────────────────────────────────────────────────────────────────────>
7397
- puts '-[√] 캡챠 유형 탐색.......'.green
7796
+ if check_captcha == 1
7797
+ begin
7798
+ # 타임아웃을 3초로 설정
7799
+ wait = Selenium::WebDriver::Wait.new(:timeout => 3)
7800
+ # 요소가 나타날 때까지 30초 동안 기다립니다.
7801
+ wait.until { @driver.find_element(:xpath, '//*[@data-state="ready"]') }
7802
+ sleep(1)
7398
7803
 
7804
+ el_ready = @driver.find_element(:xpath, '//*[@data-state="ready"]')
7805
+ @driver.action.move_to(el_ready).perform
7806
+ sleep(1)
7399
7807
 
7400
- begin
7401
- @driver.switch_to.default_content()
7402
- #@driver.find_element(:xpath, '//*[@id="mb_kcaptcha"]')
7403
- el = @driver.find_element(:xpath, '//*[@id="mb_kcaptcha"]')
7404
- puts '-[√] 캡챠 발견!! 캡차 해제를 위한 환경설정 약 10초 소요.......'.red
7405
- puts '-[√] 챕챠 해제 중~ 해제 완료까지 마우스 움직이지 마세요.......'.red
7406
- puts '-[√] 챕챠 코드 code 1.......'.red
7407
- sleep(1)
7408
- @driver.execute_script("arguments[0].scrollIntoView({behavior: 'smooth', block: 'center', inline: 'center'});", el) # 화면 가운데
7409
- sleep(1)
7410
- mouse_move_percentage(0.3,0.02)
7411
- sleep(0.5)
7412
- left_click
7413
- sleep(1)
7414
- @driver.switch_to.window(@driver.window_handle) #핸들 주입
7415
- @driver.action.context_click(el).perform #우 클릭
7416
- sleep(1)
7417
- @driver.action.key_down(:shift).key_stroke('m').key_up(:shift).perform #단축키
7418
- sleep(1)
7419
- puts '-[√] 캡챠 코드 타겟 완료1.......'.blue
7420
- rescue
7808
+ puts '-[√] 캡챠 해제 진행 중 (약 30~60 초 소요됩니다).......'.green
7809
+ begin
7810
+ @driver.find_element(:xpath, '//*[@data-state="ready"]').click #캡챠우회버튼
7811
+ rescue
7812
+ begin
7813
+ @driver.find_element(:xpath, '//*[@class="captcha-solver-image"]').click #캡챠우회버튼
7814
+ rescue
7815
+ begin
7816
+ @driver.find_element(:xpath, '//*[@class="captcha-solver-info"]').click #캡챠우회버튼
7817
+ rescue
7818
+ begin
7819
+ @driver.find_element(:xpath, '//*[@class="captcha-solver captcha-solver_inner"]').click #캡챠우회버튼
7820
+ rescue
7821
+ end
7822
+ end
7823
+ end
7824
+ end
7825
+
7826
+
7827
+ sleep(10)
7828
+ begin
7829
+ @driver.find_element(:xpath, '//*[@data-state="error"]').click
7830
+ puts '-[√] 캡챠 해제 실패 !! API번호 및 포인트를 체크해주세요.......'.red
7831
+ puts '-[√] 캡챠 해제 실패 !! API번호 및 포인트를 체크해주세요.......'.red
7832
+ @driver.window_handles.each do |handle|
7833
+ @driver.switch_to.window(handle)
7834
+ begin
7835
+ # 로딩 중이거나, 페이지가 완전히 로딩되지 않더라도 탭을 닫기
7836
+ @driver.close
7837
+ rescue Selenium::WebDriver::Error::WebDriverError => e
7838
+ puts '-[√] 다음 작업 준비로 약 1초~60초 내외 시간이 소요됩니다.......'.red
7839
+ end
7840
+ end
7841
+ return 0
7842
+ @driver.quit
7843
+ rescue
7844
+ # 타임아웃을 77초로 설정
7845
+ wait = Selenium::WebDriver::Wait.new(:timeout => 150)
7846
+ # 요소가 나타날 때까지 100초 동안 기다립니다.
7847
+ wait.until { @driver.find_element(:xpath, '//*[@data-state="solved"]') }
7848
+ sleep(1)
7849
+ @driver.find_element(:xpath, '//*[@data-state="solved"]').click
7850
+ puts '-[√] 캡챠 해제 완료 → 이어서 진행 합니다.......'.green
7851
+ sleep(3)
7852
+ begin
7853
+ @driver.find_element(:xpath, '//*[@name="user_captcha"]').click
7854
+ sleep(1)
7855
+ @driver.action.key_down(:right).key_up(:right).perform
7856
+ rescue
7857
+ begin
7858
+ @driver.find_element(:xpath, '//*[@id="user_captcha"]').click
7859
+ sleep(1)
7860
+ @driver.action.key_down(:right).key_up(:right).perform
7861
+ rescue
7862
+ begin
7863
+ @driver.find_element(:xpath, '//*[@title="자동글쓰기방지"]').click
7864
+ sleep(1)
7865
+ @driver.action.key_down(:right).key_up(:right).perform
7866
+ rescue
7867
+ end
7868
+ end
7869
+ end
7870
+ sleep(1)
7871
+ end
7872
+ rescue
7873
+
7874
+ end
7875
+ else
7876
+ end
7877
+
7878
+ if check_captcha == 0
7879
+ puts'캡챠 유무 확인.......'.yellow
7421
7880
  begin
7422
7881
  @driver.switch_to.default_content()
7423
- #@driver.find_element(:xpath, '//*[@alt="자동등록방지"]')
7424
- el = @driver.find_element(:xpath, '//*[@alt="자동등록방지"]')
7882
+ #@driver.find_element(:xpath, '//*[@id="mb_kcaptcha"]')
7883
+ el = @driver.find_element(:xpath, '//*[@id="mb_kcaptcha"]')
7425
7884
  puts '-[√] 캡챠 발견!! 캡차 해제를 위한 환경설정 약 10초 소요.......'.red
7426
7885
  puts '-[√] 챕챠 해제 중~ 해제 완료까지 마우스 움직이지 마세요.......'.red
7427
- puts '-[√] 챕챠 코드 code 2.......'.red
7886
+ puts '-[√] 챕챠 코드 code 1.......'.red
7428
7887
  sleep(1)
7429
7888
  @driver.execute_script("arguments[0].scrollIntoView({behavior: 'smooth', block: 'center', inline: 'center'});", el) # 화면 가운데
7430
7889
  sleep(1)
@@ -7441,18 +7900,11 @@ rescue
7441
7900
  rescue
7442
7901
  begin
7443
7902
  @driver.switch_to.default_content()
7444
- sleep(1)
7445
- #@driver.find_element(:xpath, '//*[@id="captcha_img"]').send_keys(:tab)
7446
- el = @driver.find_element(:xpath, '//*[@id="captcha_img"]')
7903
+ #@driver.find_element(:xpath, '//*[@alt="자동등록방지"]')
7904
+ el = @driver.find_element(:xpath, '//*[@alt="자동등록방지"]')
7447
7905
  puts '-[√] 캡챠 발견!! 캡차 해제를 위한 환경설정 약 10초 소요.......'.red
7448
7906
  puts '-[√] 챕챠 해제 중~ 해제 완료까지 마우스 움직이지 마세요.......'.red
7449
- puts '-[√] 챕챠 코드 code 3.......'.red
7450
- sleep(1)
7451
- #요소 자체 제거 하기 기능
7452
- chat_box = @driver.find_element(:xpath, '//*[@for="captcha_key"]')
7453
- @driver.execute_script("arguments[0].remove();", chat_box)
7454
- sleep(1)
7455
-
7907
+ puts '-[√] 챕챠 코드 code 2.......'.red
7456
7908
  sleep(1)
7457
7909
  @driver.execute_script("arguments[0].scrollIntoView({behavior: 'smooth', block: 'center', inline: 'center'});", el) # 화면 가운데
7458
7910
  sleep(1)
@@ -7469,11 +7921,17 @@ rescue
7469
7921
  rescue
7470
7922
  begin
7471
7923
  @driver.switch_to.default_content()
7472
- #@driver.find_element(:xpath, '//*[@id="kcaptcha"]')
7473
- el = @driver.find_element(:xpath, '//*[@id="kcaptcha"]')
7924
+ #@driver.find_element(:xpath, '//*[@id="captcha_img"]').send_keys(:tab)
7925
+ el = @driver.find_element(:xpath, '//*[@id="captcha_img"]')
7474
7926
  puts '-[√] 캡챠 발견!! 캡차 해제를 위한 환경설정 약 10초 소요.......'.red
7475
7927
  puts '-[√] 챕챠 해제 중~ 해제 완료까지 마우스 움직이지 마세요.......'.red
7476
- puts '-[√] 챕챠 코드 code 4.......'.red
7928
+ puts '-[√] 챕챠 코드 code 3.......'.red
7929
+ sleep(1)
7930
+ #요소 자체 제거 하기 기능
7931
+ chat_box = @driver.find_element(:xpath, '//*[@for="captcha_key"]')
7932
+ @driver.execute_script("arguments[0].remove();", chat_box)
7933
+ sleep(1)
7934
+
7477
7935
  sleep(1)
7478
7936
  @driver.execute_script("arguments[0].scrollIntoView({behavior: 'smooth', block: 'center', inline: 'center'});", el) # 화면 가운데
7479
7937
  sleep(1)
@@ -7490,15 +7948,11 @@ rescue
7490
7948
  rescue
7491
7949
  begin
7492
7950
  @driver.switch_to.default_content()
7493
- @driver.find_elements(:tag_name, 'img').each do |img|
7494
- if img.attribute('src').include?('kboard_captcha')
7495
- el = img # 캡챠 이미지를 el에 저장
7496
- break # 첫 번째 이미지를 찾으면 루프 종료
7497
- end
7498
- end
7951
+ #@driver.find_element(:xpath, '//*[@id="kcaptcha"]')
7952
+ el = @driver.find_element(:xpath, '//*[@id="kcaptcha"]')
7499
7953
  puts '-[√] 캡챠 발견!! 캡차 해제를 위한 환경설정 약 10초 소요.......'.red
7500
7954
  puts '-[√] 챕챠 해제 중~ 해제 완료까지 마우스 움직이지 마세요.......'.red
7501
- puts '-[√] 챕챠 코드 code 5-1.......'.red
7955
+ puts '-[√] 챕챠 코드 code 4.......'.red
7502
7956
  sleep(1)
7503
7957
  @driver.execute_script("arguments[0].scrollIntoView({behavior: 'smooth', block: 'center', inline: 'center'});", el) # 화면 가운데
7504
7958
  sleep(1)
@@ -7515,11 +7969,10 @@ rescue
7515
7969
  rescue
7516
7970
  begin
7517
7971
  @driver.switch_to.default_content()
7518
- #@driver.find_element(:xpath, '//*[@for="kboard-input-captcha"]')
7519
- el = @driver.find_element(:css, 'label[for="kboard-input-captcha"] img')
7972
+ el = @driver.find_element(:xpath, '//img[contains(@src, "kboard_captcha")]')
7520
7973
  puts '-[√] 캡챠 발견!! 캡차 해제를 위한 환경설정 약 10초 소요.......'.red
7521
7974
  puts '-[√] 챕챠 해제 중~ 해제 완료까지 마우스 움직이지 마세요.......'.red
7522
- puts '-[√] 챕챠 코드 code 5-2.......'.red
7975
+ puts '-[√] 챕챠 코드 code 5-1.......'.red
7523
7976
  sleep(1)
7524
7977
  @driver.execute_script("arguments[0].scrollIntoView({behavior: 'smooth', block: 'center', inline: 'center'});", el) # 화면 가운데
7525
7978
  sleep(1)
@@ -7536,12 +7989,11 @@ rescue
7536
7989
  rescue
7537
7990
  begin
7538
7991
  @driver.switch_to.default_content()
7539
- sleep(1)
7540
- #@driver.find_element(:xpath, '//*[@id="captcha_Write"]')
7541
- el = @driver.find_element(:xpath, '//*[@id="captcha_Write"]')
7992
+ #@driver.find_element(:xpath, '//*[@for="kboard-input-captcha"]')
7993
+ el = @driver.find_element(:xpath, '//*[@for="kboard-input-captcha"] img')
7542
7994
  puts '-[√] 캡챠 발견!! 캡차 해제를 위한 환경설정 약 10초 소요.......'.red
7543
7995
  puts '-[√] 챕챠 해제 중~ 해제 완료까지 마우스 움직이지 마세요.......'.red
7544
- puts '-[√] 챕챠 코드 code 6.......'.red
7996
+ puts '-[√] 챕챠 코드 code 5-2.......'.red
7545
7997
  sleep(1)
7546
7998
  @driver.execute_script("arguments[0].scrollIntoView({behavior: 'smooth', block: 'center', inline: 'center'});", el) # 화면 가운데
7547
7999
  sleep(1)
@@ -7558,11 +8010,12 @@ rescue
7558
8010
  rescue
7559
8011
  begin
7560
8012
  @driver.switch_to.default_content()
7561
- #@driver.find_element(:xpath, '//*[@image-reader="in-progress"]')
7562
- el = @driver.find_element(:xpath, '//*[@image-reader="in-progress"]')
8013
+ sleep(1)
8014
+ #@driver.find_element(:xpath, '//*[@id="captcha_Write"]')
8015
+ el = @driver.find_element(:xpath, '//*[@id="captcha_Write"]')
7563
8016
  puts '-[√] 캡챠 발견!! 캡차 해제를 위한 환경설정 약 10초 소요.......'.red
7564
8017
  puts '-[√] 챕챠 해제 중~ 해제 완료까지 마우스 움직이지 마세요.......'.red
7565
- puts '-[√] 챕챠 코드 code 7.......'.red
8018
+ puts '-[√] 챕챠 코드 code 6.......'.red
7566
8019
  sleep(1)
7567
8020
  @driver.execute_script("arguments[0].scrollIntoView({behavior: 'smooth', block: 'center', inline: 'center'});", el) # 화면 가운데
7568
8021
  sleep(1)
@@ -7579,11 +8032,11 @@ rescue
7579
8032
  rescue
7580
8033
  begin
7581
8034
  @driver.switch_to.default_content()
7582
- #@driver.find_element(:xpath, '//*[@id="spamauth"]')
7583
- el = @driver.find_element(:xpath, '//*[@id="spamauth"]')
8035
+ #@driver.find_element(:xpath, '//*[@image-reader="in-progress"]')
8036
+ el = @driver.find_element(:xpath, '//*[@image-reader="in-progress"]')
7584
8037
  puts '-[√] 캡챠 발견!! 캡차 해제를 위한 환경설정 약 10초 소요.......'.red
7585
8038
  puts '-[√] 챕챠 해제 중~ 해제 완료까지 마우스 움직이지 마세요.......'.red
7586
- puts '-[√] 챕챠 코드 code 8.......'.red
8039
+ puts '-[√] 챕챠 코드 code 7.......'.red
7587
8040
  sleep(1)
7588
8041
  @driver.execute_script("arguments[0].scrollIntoView({behavior: 'smooth', block: 'center', inline: 'center'});", el) # 화면 가운데
7589
8042
  sleep(1)
@@ -7600,11 +8053,11 @@ rescue
7600
8053
  rescue
7601
8054
  begin
7602
8055
  @driver.switch_to.default_content()
7603
- #@driver.find_element(:xpath, '//*[@id="norobot_img"]')
7604
- el = @driver.find_element(:xpath, '//*[@id="norobot_img"]')
8056
+ #@driver.find_element(:xpath, '//*[@id="spamauth"]')
8057
+ el = @driver.find_element(:xpath, '//*[@id="spamauth"]')
7605
8058
  puts '-[√] 캡챠 발견!! 캡차 해제를 위한 환경설정 약 10초 소요.......'.red
7606
8059
  puts '-[√] 챕챠 해제 중~ 해제 완료까지 마우스 움직이지 마세요.......'.red
7607
- puts '-[√] 챕챠 코드 code 9.......'.red
8060
+ puts '-[√] 챕챠 코드 code 8.......'.red
7608
8061
  sleep(1)
7609
8062
  @driver.execute_script("arguments[0].scrollIntoView({behavior: 'smooth', block: 'center', inline: 'center'});", el) # 화면 가운데
7610
8063
  sleep(1)
@@ -7621,10 +8074,11 @@ rescue
7621
8074
  rescue
7622
8075
  begin
7623
8076
  @driver.switch_to.default_content()
7624
- el = @driver.find_element(:xpath, '//*[@class="CodeImage"]')
8077
+ #@driver.find_element(:xpath, '//*[@id="norobot_img"]')
8078
+ el = @driver.find_element(:xpath, '//*[@id="norobot_img"]')
7625
8079
  puts '-[√] 캡챠 발견!! 캡차 해제를 위한 환경설정 약 10초 소요.......'.red
7626
8080
  puts '-[√] 챕챠 해제 중~ 해제 완료까지 마우스 움직이지 마세요.......'.red
7627
- puts '-[√] 챕챠 코드 code 10.......'.red
8081
+ puts '-[√] 챕챠 코드 code 9.......'.red
7628
8082
  sleep(1)
7629
8083
  @driver.execute_script("arguments[0].scrollIntoView({behavior: 'smooth', block: 'center', inline: 'center'});", el) # 화면 가운데
7630
8084
  sleep(1)
@@ -7641,10 +8095,10 @@ rescue
7641
8095
  rescue
7642
8096
  begin
7643
8097
  @driver.switch_to.default_content()
7644
- el = @driver.find_element(:xpath, '//*[@id="kcaptcha_image"]')
8098
+ el = @driver.find_element(:xpath, '//*[@class="CodeImage"]')
7645
8099
  puts '-[√] 캡챠 발견!! 캡차 해제를 위한 환경설정 약 10초 소요.......'.red
7646
8100
  puts '-[√] 챕챠 해제 중~ 해제 완료까지 마우스 움직이지 마세요.......'.red
7647
- puts '-[√] 챕챠 코드 code 11.......'.red
8101
+ puts '-[√] 챕챠 코드 code 10.......'.red
7648
8102
  sleep(1)
7649
8103
  @driver.execute_script("arguments[0].scrollIntoView({behavior: 'smooth', block: 'center', inline: 'center'});", el) # 화면 가운데
7650
8104
  sleep(1)
@@ -7661,10 +8115,10 @@ rescue
7661
8115
  rescue
7662
8116
  begin
7663
8117
  @driver.switch_to.default_content()
7664
- el = @driver.find_element(:xpath, '//*[@class="lazy-loaded"]')
8118
+ el = @driver.find_element(:xpath, '//*[@id="kcaptcha_image"]')
7665
8119
  puts '-[√] 캡챠 발견!! 캡차 해제를 위한 환경설정 약 10초 소요.......'.red
7666
8120
  puts '-[√] 챕챠 해제 중~ 해제 완료까지 마우스 움직이지 마세요.......'.red
7667
- puts '-[√] 챕챠 코드 code 12.......'.red
8121
+ puts '-[√] 챕챠 코드 code 11.......'.red
7668
8122
  sleep(1)
7669
8123
  @driver.execute_script("arguments[0].scrollIntoView({behavior: 'smooth', block: 'center', inline: 'center'});", el) # 화면 가운데
7670
8124
  sleep(1)
@@ -7679,72 +8133,51 @@ rescue
7679
8133
  sleep(1)
7680
8134
  puts '-[√] 캡챠 코드 타겟 완료1.......'.blue
7681
8135
  rescue
7682
-
7683
- end
7684
- end
7685
-
7686
- end
7687
- end
7688
- end
7689
- end
7690
- end
7691
- end
7692
- end
7693
-
7694
- end
7695
- end
7696
- end
7697
- end
7698
- ##캡챠 이미지,2캡챠,,등등 코드 부분─────────────────────────────────────────────────────────────────────>
7699
-
7700
- sleep(1)
7701
-
7702
- ##캡챠 해제 입력 코드 부분─────────────────────────────────────────────────────────────────────>
7703
- puts '-[√] 캡챠 입력 항목 탐색.......'.green
7704
- begin
7705
- @driver.find_element(:xpath, '//*[@name="captcha_key"]').click
7706
-
7707
- sleep(1)
7708
-
7709
- el2 = @driver.find_element(:xpath, '//*[@name="captcha_key"]')
7710
- @driver.action.context_click(el2).perform
7711
- sleep(1)
7712
- @driver.action.key_stroke('up')
7713
- sleep(1)
7714
- @driver.action.key_stroke('up')
7715
- sleep(1)
7716
- @driver.action.key_stroke('enter')
7717
- sleep(1)
8136
+ begin
8137
+ @driver.switch_to.default_content()
8138
+ el = @driver.find_element(:xpath, '//*[@class="lazy-loaded"]')
8139
+ puts '-[√] 캡챠 발견!! 캡차 해제를 위한 환경설정 약 10초 소요.......'.red
8140
+ puts '-[√] 챕챠 해제 중~ 해제 완료까지 마우스 움직이지 마세요.......'.red
8141
+ puts '-[√] 챕챠 코드 code 12.......'.red
8142
+ sleep(1)
8143
+ @driver.execute_script("arguments[0].scrollIntoView({behavior: 'smooth', block: 'center', inline: 'center'});", el) # 화면 가운데
8144
+ sleep(1)
8145
+ mouse_move_percentage(0.3,0.02)
8146
+ sleep(0.5)
8147
+ left_click
8148
+ sleep(1)
8149
+ @driver.switch_to.window(@driver.window_handle) #핸들 주입
8150
+ @driver.action.context_click(el).perform #우 클릭
8151
+ sleep(1)
8152
+ @driver.action.key_down(:shift).key_stroke('m').key_up(:shift).perform #단축키
8153
+ sleep(1)
8154
+ puts '-[√] 캡챠 코드 타겟 완료1.......'.blue
8155
+ rescue
8156
+
8157
+ end
8158
+ end
8159
+ end
8160
+ end
8161
+ end
8162
+ end
8163
+ end
8164
+ end
8165
+ end
8166
+ end
8167
+ end
8168
+ end
8169
+ end
7718
8170
 
7719
- begin
7720
- # 요소 찾기 타임아웃을 7초로 설정
7721
- wait = Selenium::WebDriver::Wait.new(:timeout => 7)
7722
- #요소가 나타날 때까지 7초 동안 기다립니다.
7723
- wait.until { @driver.find_element(:xpath, '//*[@class="captcha-solver captcha-solver_inner"]') }
7724
- rescue
7725
- sleep(1)
7726
- @driver.action.key_stroke('left')
7727
- sleep(1)
7728
- @driver.action.key_stroke('up')
7729
- sleep(1)
7730
- @driver.action.key_stroke('enter')
7731
- sleep(1)
7732
- # 요소 찾기 타임아웃을 7초로 설정
7733
- wait = Selenium::WebDriver::Wait.new(:timeout => 7)
7734
- #요소가 나타날 때까지 7초 동안 기다립니다.
7735
- wait.until { @driver.find_element(:xpath, '//*[@class="captcha-solver captcha-solver_inner"]') }
7736
- end
7737
- puts '-[√] 캡챠 코드 타겟 완료2.......'.blue
7738
8171
  sleep(1)
7739
- rescue
8172
+
8173
+ puts '-[√] 캡챠 입력 항목 탐색.......'.green
7740
8174
  begin
7741
- @driver.find_element(:xpath, '//*[@id="captcha_key"]').click
7742
-
7743
- sleep(1)
8175
+ @driver.find_element(:xpath, '//*[@name="captcha_key"]').click
7744
8176
 
7745
- el2 = @driver.find_element(:xpath, '//*[@id="captcha_key"]')
8177
+ sleep(1)
8178
+
8179
+ el2 = @driver.find_element(:xpath, '//*[@name="captcha_key"]')
7746
8180
  @driver.action.context_click(el2).perform
7747
-
7748
8181
  sleep(1)
7749
8182
  @driver.action.key_stroke('up')
7750
8183
  sleep(1)
@@ -7752,33 +8185,34 @@ rescue
7752
8185
  sleep(1)
7753
8186
  @driver.action.key_stroke('enter')
7754
8187
  sleep(1)
8188
+
7755
8189
  begin
7756
- # 요소 찾기 타임아웃을 7초로 설정
7757
- wait = Selenium::WebDriver::Wait.new(:timeout => 7)
7758
- #요소가 나타날 때까지 7초 동안 기다립니다.
7759
- wait.until { @driver.find_element(:xpath, '//*[@class="captcha-solver captcha-solver_inner"]') }
7760
- rescue
7761
- sleep(1)
7762
- @driver.action.key_stroke('left')
7763
- sleep(1)
7764
- @driver.action.key_stroke('up')
7765
- sleep(1)
7766
- @driver.action.key_stroke('enter')
7767
- sleep(1)
7768
- # 요소 찾기 타임아웃을 7초로 설정
7769
- wait = Selenium::WebDriver::Wait.new(:timeout => 7)
7770
- #요소가 나타날 때까지 7초 동안 기다립니다.
7771
- wait.until { @driver.find_element(:xpath, '//*[@class="captcha-solver captcha-solver_inner"]') }
7772
- end
8190
+ # 요소 찾기 타임아웃을 7초로 설정
8191
+ wait = Selenium::WebDriver::Wait.new(:timeout => 7)
8192
+ #요소가 나타날 때까지 7초 동안 기다립니다.
8193
+ wait.until { @driver.find_element(:xpath, '//*[@class="captcha-solver captcha-solver_inner"]') }
8194
+ rescue
8195
+ sleep(1)
8196
+ @driver.action.key_stroke('left')
8197
+ sleep(1)
8198
+ @driver.action.key_stroke('up')
8199
+ sleep(1)
8200
+ @driver.action.key_stroke('enter')
8201
+ sleep(1)
8202
+ # 요소 찾기 타임아웃을 7초로 설정
8203
+ wait = Selenium::WebDriver::Wait.new(:timeout => 7)
8204
+ #요소가 나타날 때까지 7초 동안 기다립니다.
8205
+ wait.until { @driver.find_element(:xpath, '//*[@class="captcha-solver captcha-solver_inner"]') }
8206
+ end
7773
8207
  puts '-[√] 캡챠 코드 타겟 완료2.......'.blue
7774
8208
  sleep(1)
7775
8209
  rescue
7776
8210
  begin
7777
- @driver.find_element(:xpath, '=//*[@id="code"]').click
7778
-
8211
+ @driver.find_element(:xpath, '//*[@id="captcha_key"]').click
8212
+
7779
8213
  sleep(1)
7780
-
7781
- el2 = @driver.find_element(:xpath, '//*[@id="code"]')
8214
+
8215
+ el2 = @driver.find_element(:xpath, '//*[@id="captcha_key"]')
7782
8216
  @driver.action.context_click(el2).perform
7783
8217
 
7784
8218
  sleep(1)
@@ -7810,11 +8244,11 @@ rescue
7810
8244
  sleep(1)
7811
8245
  rescue
7812
8246
  begin
7813
- @driver.find_element(:xpath, '//*[@id="kboard-input-captcha"]').click
7814
-
8247
+ @driver.find_element(:xpath, '=//*[@id="code"]').click
8248
+
7815
8249
  sleep(1)
7816
8250
 
7817
- el2 = @driver.find_element(:xpath, '//*[@id="kboard-input-captcha"]')
8251
+ el2 = @driver.find_element(:xpath, '//*[@id="code"]')
7818
8252
  @driver.action.context_click(el2).perform
7819
8253
 
7820
8254
  sleep(1)
@@ -7846,13 +8280,13 @@ rescue
7846
8280
  sleep(1)
7847
8281
  rescue
7848
8282
  begin
7849
- @driver.find_element(:xpath, '//*[@fw-label="보안문자"]').click
7850
-
8283
+ @driver.find_element(:xpath, '//*[@id="kboard-input-captcha"]').click
8284
+
7851
8285
  sleep(1)
7852
-
7853
- el2 = @driver.find_element(:xpath, '//*[@fw-label="보안문자"]')
8286
+
8287
+ el2 = @driver.find_element(:xpath, '//*[@id="kboard-input-captcha"]')
7854
8288
  @driver.action.context_click(el2).perform
7855
-
8289
+
7856
8290
  sleep(1)
7857
8291
  @driver.action.key_stroke('up')
7858
8292
  sleep(1)
@@ -7882,23 +8316,24 @@ rescue
7882
8316
  sleep(1)
7883
8317
  rescue
7884
8318
  begin
7885
- @driver.find_element(:xpath, '//*[@name="captcha"]').click
8319
+ @driver.find_element(:xpath, '//*[@fw-label="보안문자"]').click
8320
+
7886
8321
  sleep(1)
7887
-
7888
- # CAPTCHA 요소 찾기
7889
- el2 = @driver.find_element(:xpath, '//*[@name="captcha"]')
7890
-
7891
- # 우클릭 (context_click) 실행
8322
+
8323
+ el2 = @driver.find_element(:xpath, '//*[@fw-label="보안문자"]')
7892
8324
  @driver.action.context_click(el2).perform
8325
+
7893
8326
  sleep(1)
7894
8327
  @driver.action.key_stroke('up')
7895
8328
  sleep(1)
7896
8329
  @driver.action.key_stroke('up')
7897
8330
  sleep(1)
7898
8331
  @driver.action.key_stroke('enter')
8332
+ sleep(1)
7899
8333
  begin
8334
+ # 요소 찾기 타임아웃을 7초로 설정
7900
8335
  wait = Selenium::WebDriver::Wait.new(:timeout => 7)
7901
- # 요소가 나타날 때까지 7초 동안 기다립니다.
8336
+ #요소가 나타날 때까지 7초 동안 기다립니다.
7902
8337
  wait.until { @driver.find_element(:xpath, '//*[@class="captcha-solver captcha-solver_inner"]') }
7903
8338
  rescue
7904
8339
  sleep(1)
@@ -7917,24 +8352,23 @@ rescue
7917
8352
  sleep(1)
7918
8353
  rescue
7919
8354
  begin
7920
- @driver.find_element(:xpath, '//*[@id="spamCode"]').click
7921
-
8355
+ @driver.find_element(:xpath, '//*[@name="captcha"]').click
7922
8356
  sleep(1)
7923
-
7924
- el2 = @driver.find_element(:xpath, '//*[@id="spamCode"]')
8357
+
8358
+ # CAPTCHA 요소 찾기
8359
+ el2 = @driver.find_element(:xpath, '//*[@name="captcha"]')
8360
+
8361
+ # 우클릭 (context_click) 실행
7925
8362
  @driver.action.context_click(el2).perform
7926
-
7927
8363
  sleep(1)
7928
8364
  @driver.action.key_stroke('up')
7929
8365
  sleep(1)
7930
8366
  @driver.action.key_stroke('up')
7931
8367
  sleep(1)
7932
8368
  @driver.action.key_stroke('enter')
7933
- sleep(1)
7934
8369
  begin
7935
- # 요소 찾기 타임아웃을 7초로 설정
7936
8370
  wait = Selenium::WebDriver::Wait.new(:timeout => 7)
7937
- #요소가 나타날 때까지 7초 동안 기다립니다.
8371
+ # 요소가 나타날 때까지 7초 동안 기다립니다.
7938
8372
  wait.until { @driver.find_element(:xpath, '//*[@class="captcha-solver captcha-solver_inner"]') }
7939
8373
  rescue
7940
8374
  sleep(1)
@@ -7953,13 +8387,14 @@ rescue
7953
8387
  sleep(1)
7954
8388
  rescue
7955
8389
  begin
7956
- @driver.find_element(:xpath, '//*[@id="norobot_code"]').click
7957
-
8390
+ @driver.find_element(:xpath, '//*[@id="spamCode"]').click
8391
+
7958
8392
  sleep(1)
7959
-
7960
- el2 = @driver.find_element(:xpath, '//*[@id="norobot_code"]')
8393
+
8394
+ el2 = @driver.find_element(:xpath, '//*[@id="spamCode"]')
7961
8395
  @driver.action.context_click(el2).perform
7962
-
8396
+
8397
+ sleep(1)
7963
8398
  @driver.action.key_stroke('up')
7964
8399
  sleep(1)
7965
8400
  @driver.action.key_stroke('up')
@@ -7988,53 +8423,50 @@ rescue
7988
8423
  sleep(1)
7989
8424
  rescue
7990
8425
  begin
7991
- @driver.switch_to.default_content()
7992
- sleep(1)
7993
- @driver.find_element(:xpath, '//*[@name="kcaptcha_code"]').click
7994
-
7995
- sleep(1)
8426
+ @driver.find_element(:xpath, '//*[@id="norobot_code"]').click
7996
8427
 
7997
- el2 = @driver.find_element(:xpath, '//*[@name="kcaptcha_code"]')
7998
- @driver.action.context_click(el2).perform
7999
-
8428
+ sleep(1)
8429
+
8430
+ el2 = @driver.find_element(:xpath, '//*[@id="norobot_code"]')
8431
+ @driver.action.context_click(el2).perform
8432
+
8433
+ @driver.action.key_stroke('up')
8434
+ sleep(1)
8435
+ @driver.action.key_stroke('up')
8436
+ sleep(1)
8437
+ @driver.action.key_stroke('enter')
8438
+ sleep(1)
8439
+ begin
8440
+ # 요소 찾기 타임아웃을 7초로 설정
8441
+ wait = Selenium::WebDriver::Wait.new(:timeout => 7)
8442
+ #요소가 나타날 때까지 7초 동안 기다립니다.
8443
+ wait.until { @driver.find_element(:xpath, '//*[@class="captcha-solver captcha-solver_inner"]') }
8444
+ rescue
8000
8445
  sleep(1)
8001
- @driver.action.key_stroke('up')
8446
+ @driver.action.key_stroke('left')
8002
8447
  sleep(1)
8003
8448
  @driver.action.key_stroke('up')
8004
8449
  sleep(1)
8005
8450
  @driver.action.key_stroke('enter')
8006
- sleep(1)
8007
- begin
8008
- # 요소 찾기 타임아웃을 7초로 설정
8009
- wait = Selenium::WebDriver::Wait.new(:timeout => 7)
8010
- #요소가 나타날 때까지 7초 동안 기다립니다.
8011
- wait.until { @driver.find_element(:xpath, '//*[@class="captcha-solver captcha-solver_inner"]') }
8012
- rescue
8013
- sleep(1)
8014
- @driver.action.key_stroke('left')
8015
- sleep(1)
8016
- @driver.action.key_stroke('up')
8017
- sleep(1)
8018
- @driver.action.key_stroke('enter')
8019
- sleep(1)
8020
- # 요소 찾기 타임아웃을 7초로 설정
8021
- wait = Selenium::WebDriver::Wait.new(:timeout => 7)
8022
- #요소가 나타날 때까지 7초 동안 기다립니다.
8023
- wait.until { @driver.find_element(:xpath, '//*[@class="captcha-solver captcha-solver_inner"]') }
8024
- end
8025
- puts '-[√] 캡챠 코드 타겟 완료2.......'.blue
8026
- sleep(1)
8451
+ sleep(1)
8452
+ # 요소 찾기 타임아웃을 7초로 설정
8453
+ wait = Selenium::WebDriver::Wait.new(:timeout => 7)
8454
+ #요소가 나타날 때까지 7초 동안 기다립니다.
8455
+ wait.until { @driver.find_element(:xpath, '//*[@class="captcha-solver captcha-solver_inner"]') }
8456
+ end
8457
+ puts '-[√] 캡챠 코드 타겟 완료2.......'.blue
8458
+ sleep(1)
8027
8459
  rescue
8028
8460
  begin
8029
8461
  @driver.switch_to.default_content()
8030
8462
  sleep(1)
8031
- @driver.find_element(:xpath, '//*[@title="자동글쓰기방지"]').click
8032
-
8463
+ @driver.find_element(:xpath, '//*[@name="kcaptcha_code"]').click
8464
+
8033
8465
  sleep(1)
8034
8466
 
8035
- el2 = @driver.find_element(:xpath, '//*[@title="자동글쓰기방지"]')
8467
+ el2 = @driver.find_element(:xpath, '//*[@name="kcaptcha_code"]')
8036
8468
  @driver.action.context_click(el2).perform
8037
-
8469
+
8038
8470
  sleep(1)
8039
8471
  @driver.action.key_stroke('up')
8040
8472
  sleep(1)
@@ -8066,13 +8498,13 @@ rescue
8066
8498
  begin
8067
8499
  @driver.switch_to.default_content()
8068
8500
  sleep(1)
8069
- @driver.find_element(:xpath, '//*[@id="user_captcha"]').click
8070
-
8501
+ @driver.find_element(:xpath, '//*[@title="자동글쓰기방지"]').click
8502
+
8071
8503
  sleep(1)
8072
8504
 
8073
- el2 = @driver.find_element(:xpath, '//*[@id="user_captcha"]')
8505
+ el2 = @driver.find_element(:xpath, '//*[@title="자동글쓰기방지"]')
8074
8506
  @driver.action.context_click(el2).perform
8075
-
8507
+
8076
8508
  sleep(1)
8077
8509
  @driver.action.key_stroke('up')
8078
8510
  sleep(1)
@@ -8104,13 +8536,13 @@ rescue
8104
8536
  begin
8105
8537
  @driver.switch_to.default_content()
8106
8538
  sleep(1)
8107
- @driver.find_element(:xpath, '//*[@itemname="자동등록방지"]').click
8108
-
8539
+ @driver.find_element(:xpath, '//*[@id="user_captcha"]').click
8540
+
8109
8541
  sleep(1)
8110
8542
 
8111
- el2 = @driver.find_element(:xpath, '//*[@itemname="자동등록방지"]')
8543
+ el2 = @driver.find_element(:xpath, '//*[@id="user_captcha"]')
8112
8544
  @driver.action.context_click(el2).perform
8113
-
8545
+
8114
8546
  sleep(1)
8115
8547
  @driver.action.key_stroke('up')
8116
8548
  sleep(1)
@@ -8142,13 +8574,13 @@ rescue
8142
8574
  begin
8143
8575
  @driver.switch_to.default_content()
8144
8576
  sleep(1)
8145
- @driver.find_element(:xpath, '//*[@name="wr_key"]').click
8146
-
8577
+ @driver.find_element(:xpath, '//*[@itemname="자동등록방지"]').click
8578
+
8147
8579
  sleep(1)
8148
8580
 
8149
- el2 = @driver.find_element(:xpath, '//*[@name="wr_key"]')
8581
+ el2 = @driver.find_element(:xpath, '//*[@itemname="자동등록방지"]')
8150
8582
  @driver.action.context_click(el2).perform
8151
-
8583
+
8152
8584
  sleep(1)
8153
8585
  @driver.action.key_stroke('up')
8154
8586
  sleep(1)
@@ -8177,7 +8609,124 @@ rescue
8177
8609
  puts '-[√] 캡챠 코드 타겟 완료2.......'.blue
8178
8610
  sleep(1)
8179
8611
  rescue
8612
+ begin
8613
+ @driver.switch_to.default_content()
8614
+ sleep(1)
8615
+ @driver.find_element(:xpath, '//*[@name="wr_key"]').click
8616
+
8617
+ sleep(1)
8618
+
8619
+ el2 = @driver.find_element(:xpath, '//*[@name="wr_key"]')
8620
+ @driver.action.context_click(el2).perform
8621
+
8622
+ sleep(1)
8623
+ @driver.action.key_stroke('up')
8624
+ sleep(1)
8625
+ @driver.action.key_stroke('up')
8626
+ sleep(1)
8627
+ @driver.action.key_stroke('enter')
8628
+ sleep(1)
8629
+ begin
8630
+ # 요소 찾기 타임아웃을 7초로 설정
8631
+ wait = Selenium::WebDriver::Wait.new(:timeout => 7)
8632
+ #요소가 나타날 때까지 7초 동안 기다립니다.
8633
+ wait.until { @driver.find_element(:xpath, '//*[@class="captcha-solver captcha-solver_inner"]') }
8634
+ rescue
8635
+ sleep(1)
8636
+ @driver.action.key_stroke('left')
8637
+ sleep(1)
8638
+ @driver.action.key_stroke('up')
8639
+ sleep(1)
8640
+ @driver.action.key_stroke('enter')
8641
+ sleep(1)
8642
+ # 요소 찾기 타임아웃을 7초로 설정
8643
+ wait = Selenium::WebDriver::Wait.new(:timeout => 7)
8644
+ #요소가 나타날 때까지 7초 동안 기다립니다.
8645
+ wait.until { @driver.find_element(:xpath, '//*[@class="captcha-solver captcha-solver_inner"]') }
8646
+ end
8647
+ puts '-[√] 캡챠 코드 타겟 완료2.......'.blue
8648
+ sleep(1)
8649
+ rescue
8650
+ begin
8651
+ @driver.switch_to.default_content()
8652
+ sleep(1)
8653
+ @driver.find_element(:xpath, '//*[@title="자동등록방지"]').click
8180
8654
 
8655
+ sleep(1)
8656
+
8657
+ el2 = @driver.find_element(:xpath, '//*[@title="자동등록방지"]')
8658
+ @driver.action.context_click(el2).perform
8659
+
8660
+ sleep(1)
8661
+ @driver.action.key_stroke('up')
8662
+ sleep(1)
8663
+ @driver.action.key_stroke('up')
8664
+ sleep(1)
8665
+ @driver.action.key_stroke('enter')
8666
+ sleep(1)
8667
+ begin
8668
+ # 요소 찾기 타임아웃을 7초로 설정
8669
+ wait = Selenium::WebDriver::Wait.new(:timeout => 7)
8670
+ #요소가 나타날 때까지 7초 동안 기다립니다.
8671
+ wait.until { @driver.find_element(:xpath, '//*[@class="captcha-solver captcha-solver_inner"]') }
8672
+ rescue
8673
+ sleep(1)
8674
+ @driver.action.key_stroke('left')
8675
+ sleep(1)
8676
+ @driver.action.key_stroke('up')
8677
+ sleep(1)
8678
+ @driver.action.key_stroke('enter')
8679
+ sleep(1)
8680
+ # 요소 찾기 타임아웃을 7초로 설정
8681
+ wait = Selenium::WebDriver::Wait.new(:timeout => 7)
8682
+ #요소가 나타날 때까지 7초 동안 기다립니다.
8683
+ wait.until { @driver.find_element(:xpath, '//*[@class="captcha-solver captcha-solver_inner"]') }
8684
+ end
8685
+ puts '-[√] 캡챠 코드 타겟 완료2.......'.blue
8686
+ sleep(1)
8687
+ rescue
8688
+ begin
8689
+ @driver.switch_to.default_content()
8690
+ sleep(1)
8691
+ @driver.find_element(:xpath, '//input[@name="kcaptcha_img"]').click
8692
+
8693
+ sleep(1)
8694
+
8695
+ el2 = @driver.find_element(:xpath, '//input[@name="kcaptcha_img"]')
8696
+ @driver.action.context_click(el2).perform
8697
+
8698
+ sleep(1)
8699
+ @driver.action.key_stroke('up')
8700
+ sleep(1)
8701
+ @driver.action.key_stroke('up')
8702
+ sleep(1)
8703
+ @driver.action.key_stroke('enter')
8704
+ sleep(1)
8705
+ begin
8706
+ # 요소 찾기 타임아웃을 7초로 설정
8707
+ wait = Selenium::WebDriver::Wait.new(:timeout => 7)
8708
+ #요소가 나타날 때까지 7초 동안 기다립니다.
8709
+ wait.until { @driver.find_element(:xpath, '//*[@class="captcha-solver captcha-solver_inner"]') }
8710
+ rescue
8711
+ sleep(1)
8712
+ @driver.action.key_stroke('left')
8713
+ sleep(1)
8714
+ @driver.action.key_stroke('up')
8715
+ sleep(1)
8716
+ @driver.action.key_stroke('enter')
8717
+ sleep(1)
8718
+ # 요소 찾기 타임아웃을 7초로 설정
8719
+ wait = Selenium::WebDriver::Wait.new(:timeout => 7)
8720
+ #요소가 나타날 때까지 7초 동안 기다립니다.
8721
+ wait.until { @driver.find_element(:xpath, '//*[@class="captcha-solver captcha-solver_inner"]') }
8722
+ end
8723
+ puts '-[√] 캡챠 코드 타겟 완료2.......'.blue
8724
+ sleep(1)
8725
+ rescue
8726
+
8727
+ end
8728
+ end
8729
+ end
8181
8730
  end
8182
8731
  end
8183
8732
  end
@@ -8189,9 +8738,8 @@ rescue
8189
8738
  end
8190
8739
  end
8191
8740
  end
8192
- end
8193
- end
8194
- ##<─────────────────────────────────────────────────────────────────────캡챠 해제 입력 코드 부분
8741
+ end
8742
+
8195
8743
 
8196
8744
 
8197
8745
 
@@ -8285,7 +8833,8 @@ end
8285
8833
 
8286
8834
 
8287
8835
 
8288
-
8836
+ else
8837
+ end
8289
8838
 
8290
8839
 
8291
8840
 
@@ -8313,7 +8862,7 @@ sleep(1)
8313
8862
 
8314
8863
 
8315
8864
  ##등록 버튼 코드 부분─────────────────────────────────────────────────────────────────────>
8316
- puts '-[√] HTML 버튼 복구 여부 체크.......'.yellow
8865
+
8317
8866
  begin
8318
8867
  @driver.find_element(:xpath, '//*[@aria-label="코드 보기"]')
8319
8868
  sleep(1)
@@ -8338,7 +8887,7 @@ rescue
8338
8887
  @driver.find_element(:xpath, '//*[@title="에디터 타입"]').click
8339
8888
  sleep(1)
8340
8889
  rescue
8341
- puts '-[√] HTML 버튼 복구 여부 체크 종료.......'.yellow
8890
+
8342
8891
  end
8343
8892
  end
8344
8893
  end
@@ -8519,6 +9068,8 @@ rescue
8519
9068
  sleep(1)
8520
9069
 
8521
9070
  @driver.find_element(:xpath, '//*[@form="write"]').click
9071
+ sleep(1)
9072
+ @driver.action.key_down(:enter).key_up(:enter).perform #엔터
8522
9073
  puts '-[√] 등록을 19번 코드로 시도하였습니다.......'.magenta
8523
9074
  sleep(5)
8524
9075
 
@@ -8940,7 +9491,6 @@ end
8940
9491
 
8941
9492
 
8942
9493
 
8943
-
8944
9494
  class Wordpress
8945
9495
  include Glimmer
8946
9496
  def get_mac_address
@@ -8967,39 +9517,6 @@ class Wordpress
8967
9517
  end
8968
9518
  end
8969
9519
 
8970
- # def get_naver_text(q)
8971
- # begin
8972
- # Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
8973
- # @driver = Selenium::WebDriver.for :chrome
8974
- # rescue
8975
- # @driver = Selenium::WebDriver.for :chrome
8976
- # end
8977
- # @driver.get('https://search.naver.com/search.naver?display=15&f=&filetype=0&page=3&query='+q.to_s+'&research_url=&sm=tab_pge&start=16&where=web')
8978
- # noko = Nokogiri::HTML(@driver.page_source)
8979
- # tt = noko.xpath('//*[@id="main_pack"]/section/div/ul').text
8980
- # aa33 = '하였습니다,하였어요,하게됬어요,했답니다,했었는데요,하게되었어요,했어요,그랬답니다,그랬어요,합니다,그랬어요,그랬답니다,그랬답니다,그러합니다,좋아요,좋습니다,됬어요,되었어요,되었답니다,되었구요,되었어요,되네요,하네요,해요,할거예요,할수었이요,입니다,인데요,이예요,이랍니다,이였어요,그랬어요,그랬거든요,그랬습니다,었어요,었습니다,있었어요'.split(',')
8981
- # for page in 3..8
8982
- # @driver.get('https://www.google.com/search?q='+q.to_s+'&start='+(page*10).to_s)
8983
- # noko = Nokogiri::HTML(@driver.page_source)
8984
- # for n in 1..15
8985
- # tt2 = noko.xpath('//*[@id="rso"]/div['+n.to_s+']/div/div/div[2]/div').text
8986
- # if tt2.length < 5
8987
-
8988
- # else
8989
- # tt2 = tt2.split('...').join('')+aa3.sample
8990
- # tt += tt2
8991
- # end
8992
- # end
8993
- # end
8994
- # @driver.close
8995
- # tt = tt.split(' ').shuffle.join(' ')[0..1000]
8996
- # m = Array.new
8997
- # for n in 0..19
8998
- # m << tt[(n*100)..(n*100+100)]
8999
- # end
9000
- # return m.join("\n")
9001
- # end
9002
-
9003
9520
  def get_naver_text(q)
9004
9521
  puts '자동 글 생성을 시작합니다.......'.green
9005
9522
  text_array = Array.new
@@ -9376,64 +9893,36 @@ class Wordpress
9376
9893
  puts table[10]
9377
9894
  if table[8].to_i > table[10].to_i
9378
9895
  if @data['포스트설정']['테더링'].checked?
9379
- puts 'Tethering IP change...'
9380
-
9896
+ puts 'tedering ip change...'
9381
9897
  stdout, stderr, status = Open3.capture3('./adb devices')
9382
-
9383
9898
  if status.success?
9384
- device_id = stdout.split("\n")[1].split("\t")[0]
9385
- puts device_id
9386
-
9387
- # ADB 서버 초기화
9388
- puts 'adb kill-server'
9389
- Open3.capture3('./adb kill-server')
9390
- sleep(5) # ADB 서버가 안정될 시간을 충분히 주기
9391
-
9392
- # 다시 ADB 서버 실행
9393
- puts 'adb start-server'
9394
- Open3.capture3('./adb start-server')
9395
- sleep(5) # ADB 서버가 안정될 시간을 충분히 주기
9396
-
9397
- # 데이터를 끄고 켜기
9398
- puts 'adb -s ' + device_id + ' shell svc data disable'
9399
- stdout2, stderr2, status2 = Open3.capture3('./adb -s ' + device_id + ' shell svc data disable')
9400
- puts "stderr: #{stderr2}" unless status2.success? # 오류 출력
9401
- sleep(5) # 네트워크가 안정될 시간을 더 줍니다.
9402
- puts 'adb -s ' + device_id + ' shell svc data enable'
9403
- stdout3, stderr3, status3 = Open3.capture3('./adb -s ' + device_id + ' shell svc data enable')
9404
- puts "stderr: #{stderr3}" unless status3.success? # 오류 출력
9405
- sleep(5) # 네트워크가 안정될 시간을 더 줍니다.
9406
- puts 'adb ok'
9407
- sleep(8)
9408
-
9409
- # IP 변경 확인을 위한 람다 함수
9410
- robot_ip = lambda do
9411
- begin
9412
- # IP 변경 확인
9413
- http = HTTP.get('https://www.findip.kr/')
9414
- noko = Nokogiri::HTML(http.to_s)
9415
-
9416
- current_ip = noko.xpath('/html/body/header/h2').text.strip
9417
- if current_ip != @my_ip
9418
- @my_ip = current_ip
9419
- puts "IP 변경됨[ #{@my_ip} ]"
9420
- else
9421
- puts "현재 IP: #{@my_ip}"
9422
- puts 'IP 변경이 감지되지 않았습니다. 다시 시도합니다...'
9423
- sleep(5) # 여유롭게 대기 시간 증가
9424
- robot_ip[] # 재시도
9425
- end
9426
- rescue HTTP::ConnectionError => e
9427
- puts "네트워크 오류 발생: #{e.message}. 재시도 중..."
9428
- sleep(5) # 재시도 간 여유 시간 추가
9429
- retry # 재시도
9899
+ device_id = stdout.split("\n")[1].split("\t")[0]
9900
+ puts device_id
9901
+ puts 'adb -s '+device_id+' shell svc data disable'
9902
+ stdout2, stderr2, status2 = Open3.capture3('./adb -s '+device_id+' shell svc data disable')
9903
+ sleep(3)
9904
+ puts 'adb -s '+device_id+' shell svc data enable'
9905
+ Open3.capture3('./adb -s '+device_id+' shell svc data enable')
9906
+ sleep(3)
9907
+ puts 'adb ok'
9908
+ sleep(8)
9909
+ robot_ip = lambda do
9910
+ http = HTTP.get('https://www.findip.kr/')
9911
+ noko = Nokogiri::HTML(http.to_s)
9912
+ if noko.xpath('/html/body/header/h2').text != @my_ip
9913
+ @my_ip = noko.xpath('/html/body/header/h2').text
9914
+ else
9915
+ puts @my_ip
9916
+ puts '재시도...'
9917
+ sleep(3)
9918
+ robot_ip[]
9919
+ end
9430
9920
  end
9431
- end
9432
- robot_ip[] # IP 확인 시작
9921
+ robot_ip[]
9433
9922
  else
9434
- puts "adb devices 명령어 실행 실패. stderr: #{stderr}"
9923
+ puts 'adb error pass'
9435
9924
  end
9436
- end
9925
+ end
9437
9926
 
9438
9927
  check_success = 1
9439
9928
  @data['table'][index][-1] = 0
@@ -9511,7 +10000,7 @@ class Wordpress
9511
10000
  @data['table'].pop
9512
10001
 
9513
10002
  #네이버로그인
9514
- login_check = naver.login(option['proxy'])
10003
+ login_check = naver.login(option['proxy'],captcha_key)
9515
10004
  if login_check == 0
9516
10005
  black_users << table[1].to_s
9517
10006
  next