質問編集履歴

1

教えていただいた方法を試した際に現状が変化したので、その部分を追加しました。

2018/03/04 02:06

投稿

sunafu
sunafu

スコア7

test CHANGED
File without changes
test CHANGED
@@ -4,69 +4,281 @@
4
4
 
5
5
 
6
6
 
7
+ よろしくお願いします。
8
+
9
+
10
+
7
11
  ### 発生している問題・エラーメッセージ
8
12
 
9
13
 
10
14
 
11
- D:\python test.py
15
+ 3.6.4 |Anaconda, Inc.| (default, Jan 16 2018, 10:22:32) [MSC v.1900 64 bit (AMD64)]
12
16
 
13
17
  Traceback (most recent call last):
14
18
 
15
- File "test.py", line 8, in <module>
19
+ File "test.py", line 23, in <module>
20
+
16
-
21
+ main()
22
+
23
+ File "test.py", line 16, in main
24
+
17
- driver = webdriver.Chrome(chrome_options=options, executable_path="C:\Python36\selenium\webdriver\chromedriver.exe")
25
+ driver = webdriver.Chrome(chrome_options=options, executable_path=executable_path, service_args=["--verbose", f"--log-path={log_path}"])
18
-
26
+
19
- File "C:\Python36\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 75, in __init__
27
+ File "C:\ProgramData\Anaconda3\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 75, in __init__
20
28
 
21
29
  desired_capabilities=desired_capabilities)
22
30
 
23
- File "C:\Python36\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 154, in __init__
31
+ File "C:\ProgramData\Anaconda3\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 154, in __init__
24
32
 
25
33
  self.start_session(desired_capabilities, browser_profile)
26
34
 
27
- File "C:\Python36\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 243, in start_session
35
+ File "C:\ProgramData\Anaconda3\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 243, in start_session
28
36
 
29
37
  response = self.execute(Command.NEW_SESSION, parameters)
30
38
 
31
- File "C:\Python36\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 312, in execute
39
+ File "C:\ProgramData\Anaconda3\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 312, in execute
32
40
 
33
41
  self.error_handler.check_response(response)
34
42
 
35
- File "C:\Python36\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
43
+ File "C:\ProgramData\Anaconda3\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
36
44
 
37
45
  raise exception_class(message, screen, stacktrace)
38
46
 
39
47
  selenium.common.exceptions.WebDriverException: Message: unknown error: chrome failed to start
40
48
 
41
- (Driver info: chromedriver=2.35.528161 (5b82f2d2aae0ca24b877009200ced9065a772e73),platform=Windows NT 10.0.16299 x86_64)
49
+ (Driver info: chromedriver=2.9.248315,platform=Windows NT 6.3 x86_64)
50
+
51
+
52
+
53
+
54
+
55
+ 【Chrome Driverのデバックログの内容】
56
+
57
+ [2.995][INFO]: COMMAND InitSession {
58
+
59
+ "capabilities": {
60
+
61
+ "alwaysMatch": {
62
+
63
+ "browserName": "chrome",
64
+
65
+ "goog:chromeOptions": {
66
+
67
+ "args": [ "--no-sandbox", "--disable-gpu", "--headless" ],
68
+
69
+ "extensions": [ ]
70
+
71
+ },
72
+
73
+ "platformName": "any"
74
+
75
+ },
76
+
77
+ "firstMatch": [ {
78
+
79
+
80
+
81
+ } ]
82
+
83
+ },
84
+
85
+ "desiredCapabilities": {
86
+
87
+ "browserName": "chrome",
88
+
89
+ "goog:chromeOptions": {
90
+
91
+ "args": [ "--no-sandbox", "--disable-gpu", "--headless" ],
92
+
93
+ "extensions": [ ]
94
+
95
+ },
96
+
97
+ "platform": "ANY",
98
+
99
+ "version": ""
100
+
101
+ }
102
+
103
+ }
104
+
105
+ [2.998][INFO]: Populating Preferences file: {
106
+
107
+ "alternate_error_pages": {
108
+
109
+ "enabled": false
110
+
111
+ },
112
+
113
+ "autofill": {
114
+
115
+ "enabled": false
116
+
117
+ },
118
+
119
+ "browser": {
120
+
121
+ "check_default_browser": false
122
+
123
+ },
124
+
125
+ "distribution": {
126
+
127
+ "import_bookmarks": false,
128
+
129
+ "import_history": false,
130
+
131
+ "import_search_engine": false,
132
+
133
+ "make_chrome_default_for_user": false,
134
+
135
+ "show_welcome_page": false,
136
+
137
+ "skip_first_run_ui": true
138
+
139
+ },
140
+
141
+ "dns_prefetching": {
142
+
143
+ "enabled": false
144
+
145
+ },
146
+
147
+ "profile": {
148
+
149
+ "content_settings": {
150
+
151
+ "pattern_pairs": {
152
+
153
+ "https://*,*": {
154
+
155
+ "media-stream": {
156
+
157
+ "audio": "Default",
158
+
159
+ "video": "Default"
160
+
161
+ }
162
+
163
+ }
164
+
165
+ }
166
+
167
+ },
168
+
169
+ "default_content_settings": {
170
+
171
+ "geolocation": 1,
172
+
173
+ "mouselock": 1,
174
+
175
+ "notifications": 1,
176
+
177
+ "popups": 1,
178
+
179
+ "ppapi-broker": 1
180
+
181
+ },
182
+
183
+ "password_manager_enabled": false
184
+
185
+ },
186
+
187
+ "safebrowsing": {
188
+
189
+ "enabled": false
190
+
191
+ },
192
+
193
+ "search": {
194
+
195
+ "suggest_enabled": false
196
+
197
+ },
198
+
199
+ "translate": {
200
+
201
+ "enabled": false
202
+
203
+ }
204
+
205
+ }
206
+
207
+ [3.000][INFO]: Populating Local State file: {
208
+
209
+ "background_mode": {
210
+
211
+ "enabled": false
212
+
213
+ },
214
+
215
+ "ssl": {
216
+
217
+ "rev_checking": {
218
+
219
+ "enabled": false
220
+
221
+ }
222
+
223
+ }
224
+
225
+ [3.512][INFO]: RESPONSE InitSession unknown error: chrome failed to start
226
+
227
+ [3.512][DEBUG]: Log type 'driver' lost 0 entries on destruction
228
+
229
+ [3.512][DEBUG]: Log type 'browser' lost 0 entries on destruction
42
230
 
43
231
 
44
232
 
45
233
  ### 該当のソースコード
46
234
 
47
- Python
48
-
49
-
50
-
51
235
  # -*- coding: utf-8 -*-
52
236
 
53
237
  from selenium import webdriver
54
238
 
55
239
  from selenium.webdriver.chrome.options import Options
56
240
 
57
-
241
+ import sys
242
+
243
+
244
+
58
-
245
+ def main():
246
+
247
+ print(sys.version)
248
+
59
- options = Options()
249
+ options = Options()
60
-
250
+
61
- options.binary_location = "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"
251
+ options.add_argument('--no-sandbox')
252
+
62
-
253
+ options.add_argument('--disable-gpu')
254
+
63
- options.add_argument('--headless')
255
+ #options.add_argument('--headless')
256
+
64
-
257
+ options.add_argument('--incognito')
258
+
259
+ options.add_argument('--disable-extensions')
260
+
261
+ log_path = r"C:\selenium\chromedriver.log"
262
+
263
+ executable_path = 'C:\selenium\chromedriver.exe'
264
+
65
- driver = webdriver.Chrome(chrome_options=options, executable_path="C:\Python36\selenium\webdriver\chromedriver.exe")
265
+ driver = webdriver.Chrome(chrome_options=options, executable_path=executable_path, service_args=["--verbose", f"--log-path={log_path}"])
66
-
67
-
68
-
266
+
267
+
268
+
69
- driver.get('https://www.google.co.jp')
269
+ driver.get('https://www.google.co.jp')
270
+
271
+ driver.save_screenshot('screen.png')
272
+
273
+
274
+
275
+
276
+
277
+ if __name__ == "__main__":
278
+
279
+ main()
280
+
281
+
70
282
 
71
283
 
72
284
 
@@ -74,7 +286,7 @@
74
286
 
75
287
  【pathの登録】
76
288
 
77
- C:\Python36\selenium\webdriver
289
+ C:\selenium\
78
290
 
79
291
 
80
292
 
@@ -84,6 +296,8 @@
84
296
 
85
297
  python3.xを再インストール → 変化なし
86
298
 
299
+ python3.x 32bit を Anaconda python3.x 64bitに変更 → 変化なし
300
+
87
301
 
88
302
 
89
303
  【//を/に】
@@ -102,6 +316,22 @@
102
316
 
103
317
 
104
318
 
319
+ 【起動オプションの変更 ※以下に変更】変化なし
320
+
321
+ options.add_argument('--no-sandbox')
322
+
323
+ options.add_argument('--disable-gpu')
324
+
325
+ #options.add_argument('--headless')
326
+
327
+ options.add_argument('--incognito')
328
+
329
+ options.add_argument('--disable-extensions')
330
+
331
+
332
+
333
+
334
+
105
335
  ### 補足情報(FW/ツールのバージョンなど)
106
336
 
107
337
  【バージョン】
@@ -110,6 +340,6 @@
110
340
 
111
341
  chrome : 64.0.3282.186(Official Build) (64 ビット)
112
342
 
113
- python : 3.6
343
+ python : 3.6.4 Anaconda [MSC v.1900 64 bit (AMD64)]
114
344
 
115
345
  chromeWebdriver : ChromeDriver 2.35(Supports Chrome v62-64) → chromedriver_win32