質問編集履歴

2

②options.addArguments("--no-sandbox")追加時の挙動を追加

2021/10/17 05:15

投稿

RHira
RHira

スコア0

test CHANGED
File without changes
test CHANGED
@@ -220,7 +220,7 @@
220
220
 
221
221
  ###追記
222
222
 
223
- Docker Imageの状態
223
+ Docker Imageの状態
224
224
 
225
225
  ```PowerShell
226
226
 
@@ -237,3 +237,145 @@
237
237
  selenium/standalone-chrome 3.141.59-xenon da74f3fdcfe2 24 months ago 852MB
238
238
 
239
239
  ```
240
+
241
+
242
+
243
+ ②options.add_Arguments("--no-sandbox")追加後
244
+
245
+ ```jupyter
246
+
247
+ os.chdir('I:/suisui')
248
+
249
+
250
+
251
+ from selenium import webdriver
252
+
253
+
254
+
255
+ # Chrome のオプションを設定する
256
+
257
+ options = webdriver.ChromeOptions()
258
+
259
+ options.add_argument('--headless')
260
+
261
+ options.add_argument('--no-sandbox')
262
+
263
+
264
+
265
+ # Selenium Server に接続する
266
+
267
+ driver = webdriver.Remote(command_executor='http://localhost:4444/wd/hub',desired_capabilities=options.to_capabilities(),options=options,)
268
+
269
+
270
+
271
+ # Selenium 経由でブラウザを操作する
272
+
273
+ driver.get('https://qiita.com')
274
+
275
+ print(driver.current_url)
276
+
277
+
278
+
279
+ # ブラウザを終了する
280
+
281
+ driver.quit()
282
+
283
+ ```
284
+
285
+ ②続き。応答内容
286
+
287
+ ```jupyter
288
+
289
+ <ipython-input-10-f81577d73398>:11: DeprecationWarning: desired_capabilities has been deprecated, please pass in an Options object with options kwarg
290
+
291
+ driver = webdriver.Remote(command_executor='http://localhost:4444/wd/hub',desired_capabilities=options.to_capabilities(),options=options,)
292
+
293
+ ---------------------------------------------------------------------------
294
+
295
+ WebDriverException Traceback (most recent call last)
296
+
297
+ <ipython-input-10-f81577d73398> in <module>
298
+
299
+ 9
300
+
301
+ 10 # Selenium Server に接続する
302
+
303
+ ---> 11 driver = webdriver.Remote(command_executor='http://localhost:4444/wd/hub',desired_capabilities=options.to_capabilities(),options=options,)
304
+
305
+ 12
306
+
307
+ 13 # Selenium 経由でブラウザを操作する
308
+
309
+
310
+
311
+ ~\anaconda3\lib\site-packages\selenium\webdriver\remote\webdriver.py in __init__(self, command_executor, desired_capabilities, browser_profile, proxy, keep_alive, file_detector, options)
312
+
313
+ 264 self.file_detector = file_detector or LocalFileDetector()
314
+
315
+ 265 self.start_client()
316
+
317
+ --> 266 self.start_session(capabilities, browser_profile)
318
+
319
+ 267
320
+
321
+ 268 def __repr__(self):
322
+
323
+
324
+
325
+ ~\anaconda3\lib\site-packages\selenium\webdriver\remote\webdriver.py in start_session(self, capabilities, browser_profile)
326
+
327
+ 355 parameters = {"capabilities": w3c_caps,
328
+
329
+ 356 "desiredCapabilities": capabilities}
330
+
331
+ --> 357 response = self.execute(Command.NEW_SESSION, parameters)
332
+
333
+ 358 if 'sessionId' not in response:
334
+
335
+ 359 response = response['value']
336
+
337
+
338
+
339
+ ~\anaconda3\lib\site-packages\selenium\webdriver\remote\webdriver.py in execute(self, driver_command, params)
340
+
341
+ 416 response = self.command_executor.execute(driver_command, params)
342
+
343
+ 417 if response:
344
+
345
+ --> 418 self.error_handler.check_response(response)
346
+
347
+ 419 response['value'] = self._unwrap_value(
348
+
349
+ 420 response.get('value', None))
350
+
351
+
352
+
353
+ ~\anaconda3\lib\site-packages\selenium\webdriver\remote\errorhandler.py in check_response(self, response)
354
+
355
+ 241 alert_text = value['alert'].get('text')
356
+
357
+ 242 raise exception_class(message, screen, stacktrace, alert_text) # type: ignore[call-arg] # mypy is not smart enough here
358
+
359
+ --> 243 raise exception_class(message, screen, stacktrace)
360
+
361
+ 244
362
+
363
+ 245 def _value_or_default(self, obj: Mapping[_KT, _VT], key: _KT, default: _VT) -> _VT:
364
+
365
+
366
+
367
+ WebDriverException: Message: unknown error: Chrome failed to start: crashed
368
+
369
+ (chrome not reachable)
370
+
371
+ (The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
372
+
373
+ Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53'
374
+
375
+ System info: host: 'f97debeefe29', ip: '172.17.0.3', os.name: 'Linux', os.arch: 'amd64', os.version: '5.10.16.3-microsoft-standard-WSL2', java.version: '1.8.0_222'
376
+
377
+ Driver info: driver.version: unknown
378
+
379
+ remote stacktrace: #0 0x5602d26eb7e9 <unknown>
380
+
381
+ ```

1

Dockerのイメージを追記しました

2021/10/17 05:15

投稿

RHira
RHira

スコア0

test CHANGED
File without changes
test CHANGED
@@ -215,3 +215,25 @@
215
215
  jupyter notebook 6.3.0 <- Anaconda navigaterより
216
216
 
217
217
  Win10 Pro 21H1 64bit
218
+
219
+
220
+
221
+ ###追記
222
+
223
+ Docker Imageの状態
224
+
225
+ ```PowerShell
226
+
227
+ PS C:\Users..> docker images
228
+
229
+ REPOSITORY TAG IMAGE ID CREATED SIZE
230
+
231
+ ID/docker101tutorial latest c7031e4fa799 3 hours ago 28.3MB
232
+
233
+ docker101tutorial latest c7031e4fa799 3 hours ago 28.3MB
234
+
235
+ alpine/git latest 612b988140be 6 days ago 27.4MB
236
+
237
+ selenium/standalone-chrome 3.141.59-xenon da74f3fdcfe2 24 months ago 852MB
238
+
239
+ ```