cafe_buy 0.0.27 → 0.0.29

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/cafe_buy.rb +99 -28
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6d648b0b0a044468c457cbca1c7b01d131f04530e799c9389b2f983409ac75d9
4
- data.tar.gz: fc48d3775eddd64d5fef5d535883a7cdcc7e95c11151571ae964cfc5e092d583
3
+ metadata.gz: f40a2270d9ead90dda0119a5d6eaea524e08211da8ca4824c3fbb39d381a82f2
4
+ data.tar.gz: df26a2cbc98f8c1799c9ac508f27815d288581b17568172c118e80779e6f8ae8
5
5
  SHA512:
6
- metadata.gz: 5042467993ba9b1ef30e7edcd5c5643f1a17d2e6eddfd0fd17e348031b26174db816d02e21d63980c346b4d9c7602e2aad586bd5f7ac09dce37ce5a970fa990f
7
- data.tar.gz: 5ef0b66989d52ed9e91ebe2043c26f2735dfab648f9cb8ac933dfc8a4a9db5e560b998b537f73b340546765e649de733c4e0f73ae3a7c85b3f6c3c5d0e7df6f0
6
+ metadata.gz: da3b0fdc581d34f811c036c4209796e224179dd1ffcfadfea10a9637b68263170ada2615eb476b43be39ef4ec4e0750b4d821ab44684decfd85fc8e65becadbc
7
+ data.tar.gz: 1606f67d1cb9536335e683cdbf4201efd0914c9e5409a0352ad8f0e9efe434b83cbe46613647b59feebb8de35a661c6c98d1ce748ad5b44a52ba1c8468ffc96d
data/lib/cafe_buy.rb CHANGED
@@ -1049,10 +1049,18 @@ end
1049
1049
  if i2.to_s.include?('<img')
1050
1050
  path = i2.to_s.split('src="')[1].split('"')[0]
1051
1051
  path = URI.decode_www_form(path)[0][0]
1052
+
1053
+ @driver.execute_script(<<~JS)
1054
+ window.URL.createObjectURL = function() {};
1055
+ HTMLInputElement.prototype.click = function() {
1056
+ console.log("File dialog suppressed");
1057
+ };
1058
+ JS
1059
+ sleep(1)
1052
1060
  # 이미지 등록 버튼 클릭
1053
1061
  @driver.find_element(:xpath, '//*[@id="'+page_id+'"]/div[1]/div/header/div[1]/ul/li[1]/button').click
1054
1062
  sleep(3)
1055
- key_stroke('escape')
1063
+ #key_stroke('escape')
1056
1064
 
1057
1065
  # 파일 경로 변환 (슬래시 -> 백슬래시)
1058
1066
  file_path = path.split('/').join("\\") # 윈도우 스타일 경로로 변환
@@ -1063,9 +1071,43 @@ end
1063
1071
  # send_keys로 파일 경로를 직접 입력하여 파일 업로드
1064
1072
  file_input.send_keys(file_path)
1065
1073
  sleep(3)
1066
-
1067
1074
 
1068
-
1075
+ @driver.action.key_down(:up).key_up(:up).perform
1076
+ sleep(1)
1077
+
1078
+ begin
1079
+ wait = Selenium::WebDriver::Wait.new(:timeout => 3)
1080
+ #요소가 나타날 때까지 60초 동안 기다립니다.
1081
+ wait.until { @driver.find_element(:xpath, '//li[@class="se-toolbar-item se-toolbar-item-resizing"]//button[@data-name="image-resizing"]') }
1082
+ sleep(1)
1083
+ @driver.find_element(:xpath, '//li[@class="se-toolbar-item se-toolbar-item-resizing"]//button[@data-name="image-resizing"]').click
1084
+
1085
+ sleep(1)
1086
+ begin
1087
+ wait = Selenium::WebDriver::Wait.new(:timeout => 3)
1088
+ #요소가 나타날 때까지 60초 동안 기다립니다.
1089
+ wait.until { @driver.find_element(:xpath, '//div[@class="se-custom-layer-option se-custom-layer-option-resizing"]//button[@class="se-custom-layer-resizing-reset-button"]') }
1090
+ sleep(1)
1091
+ @driver.find_element(:xpath, '//div[@class="se-custom-layer-option se-custom-layer-option-resizing"]//button[@class="se-custom-layer-resizing-reset-button"]').click
1092
+ sleep(1)
1093
+ @driver.action.key_down(:enter).key_up(:enter).perform #엔터
1094
+ sleep(1)
1095
+ rescue
1096
+ wait = Selenium::WebDriver::Wait.new(:timeout => 3)
1097
+ #요소가 나타날 때까지 60초 동안 기다립니다.
1098
+ wait.until { @driver.find_element(:xpath, '//span[@class="se-custom-layer-resizing-reset-label" and text()="초기화"]') }
1099
+ sleep(1)
1100
+ @driver.find_element(:xpath, '//span[@class="se-custom-layer-resizing-reset-label" and text()="초기화"]').click
1101
+ sleep(1)
1102
+ @driver.action.key_down(:enter).key_up(:enter).perform #엔터
1103
+ sleep(1)
1104
+ end
1105
+ rescue
1106
+ @driver.action.key_down(:down).key_up(:down).perform
1107
+
1108
+ end
1109
+
1110
+
1069
1111
  if option['사진타이틀'] == 'true'
1070
1112
  begin
1071
1113
  @driver.action.key_down(:up).key_up(:up).perform
@@ -1082,7 +1124,7 @@ end
1082
1124
  rescue
1083
1125
  @driver.action.key_down(:down).key_up(:down).perform
1084
1126
  end
1085
- end
1127
+ end
1086
1128
 
1087
1129
 
1088
1130
  if i2.to_s.split('href="')[1] != nil
@@ -1103,38 +1145,67 @@ end
1103
1145
  elsif i2.to_s.include?('<video')
1104
1146
  path = i2.to_s.split('src="')[1].split('"')[0]
1105
1147
  path = URI.decode_www_form(path)[0][0]
1106
-
1148
+
1107
1149
  @driver.find_element(:xpath, '//*[@id="'+page_id+'"]/div[1]/div/header/div[1]/ul/li[3]/button').click
1108
1150
  sleep(3)
1151
+
1152
+
1153
+ @driver.execute_script(<<~JS)
1154
+ window.URL.createObjectURL = function() {};
1155
+ HTMLInputElement.prototype.click = function() {
1156
+ console.log("File dialog suppressed");
1157
+ };
1158
+ JS
1159
+ sleep(1)
1160
+ # 파일 업로드 버튼 클릭 (이제 파일 선택 창이 뜨지 않음)
1109
1161
  @driver.find_element(:xpath, '//*[@id="video-uploader-wrap"]/div/div/div[2]/fieldset/div[1]/button[1]').click
1110
1162
  sleep(3)
1111
-
1112
- Clipboard.copy(path.split('/').join("\\"))
1113
- key_down('ctrl')
1114
- key_stroke('v')
1115
- key_up('ctrl')
1163
+
1164
+ file_path = path.split('/').join("\\") # 윈도우 스타일 경로로 변환
1165
+ # 파일 입력 필드 찾기 (input[type="file"])
1166
+ file_input = @driver.find_element(:id, "hidden-input")
1167
+
1168
+ # send_keys로 파일 경로를 직접 입력하여 파일 업로드
1169
+ file_input.send_keys(file_path)
1170
+
1116
1171
  sleep(3)
1117
- key_stroke('enter')
1118
- sleep(2)
1119
-
1120
- @driver.find_element(:xpath, '//*[@id="nvu_inp_box_title"]').send_keys(title)
1121
- sleep(1)
1122
- @driver.find_element(:xpath, '//*[@id="nvu_inp_box_description"]').send_keys(title)
1123
- sleep(1)
1172
+ begin
1173
+ @driver.find_element(:xpath, '//*[@id="nvu_inp_box_title"]').send_keys(title)
1174
+ sleep(1)
1175
+ rescue
1176
+ end
1177
+
1178
+ begin
1179
+ @driver.find_element(:xpath, '//*[@id="nvu_inp_box_description"]').send_keys(title)
1180
+ sleep(1)
1181
+ rescue
1182
+ end
1183
+
1184
+ begin
1124
1185
  @driver.find_element(:xpath, '//*[@id="nvu_inp_box_tag"]').send_keys(title)
1125
- sleep(1)
1186
+ sleep(1)
1187
+ rescue
1188
+ end
1126
1189
 
1127
1190
  for n in 1..10
1128
- puts @driver.find_element(:xpath, '//*[@id="video-uploader-wrap"]/div/div/div[2]/div[1]/ul/li/div/button[1]/div[2]/em').text
1129
- if @driver.find_element(:xpath, '//*[@id="video-uploader-wrap"]/div/div/div[2]/div[1]/ul/li/div/button[1]/div[2]/em').text == '업로드 완료'
1130
- break
1131
- end
1132
- sleep(10)
1191
+ begin
1192
+ puts @driver.find_element(:xpath, '//*[@id="video-uploader-wrap"]/div/div/div[2]/div[1]/ul/li/div/button[1]/div[2]/em').text
1193
+ if @driver.find_element(:xpath, '//*[@id="video-uploader-wrap"]/div/div/div[2]/div[1]/ul/li/div/button[1]/div[2]/em').text == '업로드 완료'
1194
+ break
1195
+ end
1196
+ sleep(10)
1197
+ rescue
1198
+ end
1133
1199
  end
1134
- @driver.find_element(:xpath, '//*[@id="video-uploader-wrap"]/div/div/div[3]/button/span').click
1135
- sleep(3)
1136
- @driver.action.key_down(:up).key_up(:up).perform #x탭
1137
- sleep(1)
1200
+
1201
+ begin
1202
+ @driver.find_element(:xpath, '//*[@id="video-uploader-wrap"]/div/div/div[3]/button/span').click
1203
+ sleep(3)
1204
+ @driver.action.key_down(:up).key_up(:up).perform #x탭
1205
+ sleep(1)
1206
+ rescue
1207
+ end
1208
+
1138
1209
  begin
1139
1210
  wait = Selenium::WebDriver::Wait.new(:timeout => 3)
1140
1211
  #요소가 나타날 때까지 60초 동안 기다립니다.
@@ -1149,7 +1220,7 @@ end
1149
1220
  rescue
1150
1221
  @driver.action.key_down(:down).key_up(:down).perform
1151
1222
  end
1152
-
1223
+
1153
1224
  elsif i2.to_s.include?('<inyonggoo')
1154
1225
  if i2.text == ''
1155
1226
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cafe_buy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.27
4
+ version: 0.0.29
5
5
  platform: ruby
6
6
  authors:
7
7
  - zon
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-01-24 00:00:00.000000000 Z
11
+ date: 2025-02-04 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: File to Clipboard gem
14
14
  email: mymin26@naver.com