質問編集履歴
2
別質問へのリンクを追記。
test
CHANGED
File without changes
|
test
CHANGED
@@ -272,7 +272,13 @@
|
|
272
272
|
|
273
273
|
|
274
274
|
|
275
|
-
後ほど、新たに質問を立てるつもりです。
|
275
|
+
~~後ほど、新たに質問を立てるつもりです。~~
|
276
|
+
|
277
|
+
下記に質問を立てました。
|
278
|
+
|
279
|
+
[https://teratail.com/questions/353567](https://teratail.com/questions/353567)
|
280
|
+
|
281
|
+
|
276
282
|
|
277
283
|
|
278
284
|
|
1
内容的な変更はありません。本番PCでのエラーメッセージに差し替えました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -30,211 +30,205 @@
|
|
30
30
|
|
31
31
|
C:\work>python 01_ie_test.py
|
32
32
|
|
33
|
+
[WDM] - There is no [x64] IEDriverServer for browser in cache
|
34
|
+
|
35
|
+
Traceback (most recent call last):
|
36
|
+
|
37
|
+
File "01_ie_test.py", line 4, in <module>
|
38
|
+
|
39
|
+
driver_path = IEDriverManager().install()
|
40
|
+
|
41
|
+
File "C:\Python\lib\site-packages\webdriver_manager\microsoft.py", line 26, in install
|
42
|
+
|
43
|
+
return self._get_driver_path(self.driver)
|
44
|
+
|
45
|
+
File "C:\Python\lib\site-packages\webdriver_manager\manager.py", line 29, in _get_driver_path
|
46
|
+
|
47
|
+
file = download_file(driver.get_url())
|
48
|
+
|
49
|
+
File "C:\Python\lib\site-packages\webdriver_manager\driver.py", line 168, in get_url
|
50
|
+
|
51
|
+
major, minor, patch = self.__get_divided_version(self.get_version())
|
52
|
+
|
53
|
+
File "C:\Python\lib\site-packages\webdriver_manager\driver.py", line 183, in __get_divided_version
|
54
|
+
|
55
|
+
"but given was: {version}".format(version=self.get_version()))
|
56
|
+
|
57
|
+
ValueError: Version must consist of major, minor and/or patch, but given was: .3.150.2
|
58
|
+
|
59
|
+
```
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
### 試したコード
|
68
|
+
|
69
|
+
```python
|
70
|
+
|
71
|
+
from selenium import webdriver
|
72
|
+
|
73
|
+
from webdriver_manager.microsoft import IEDriverManager
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
driver_path = IEDriverManager().install()
|
78
|
+
|
79
|
+
driver = webdriver.Ie(driver_path)
|
80
|
+
|
81
|
+
driver.get('https://google.com')
|
82
|
+
|
83
|
+
```
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
### 自分で試したこと
|
88
|
+
|
89
|
+
Python\Lib\site-packages\webdriver_manager\にある
|
90
|
+
|
91
|
+
microsoft.pyのIEDriverManager()の__init__の引数urlに記載の
|
92
|
+
|
93
|
+
http://selenium-release.storage.googleapis.com
|
94
|
+
|
95
|
+
にアクセスしたところ、以下の記述があることを発見しました。
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
```html
|
100
|
+
|
101
|
+
<Contents>
|
102
|
+
|
103
|
+
<Key>3.150/IEDriverServer_Win32_.3.150.2.zip</Key>
|
104
|
+
|
105
|
+
<Generation>1628200845472844</Generation>
|
106
|
+
|
107
|
+
<MetaGeneration>1</MetaGeneration>
|
108
|
+
|
109
|
+
<LastModified>2021-08-05T22:00:45.502Z</LastModified>
|
110
|
+
|
111
|
+
<ETag>"6f17f688d643c40ea21c2610b55d259f"</ETag>
|
112
|
+
|
113
|
+
<Size>1062956</Size>
|
114
|
+
|
115
|
+
</Contents>
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
|
120
|
+
|
121
|
+
<Contents>
|
122
|
+
|
123
|
+
<Key>3.150/IEDriverServer_x64_.3.150.2.zip</Key>
|
124
|
+
|
125
|
+
<Generation>1628200846705412</Generation>
|
126
|
+
|
127
|
+
<MetaGeneration>1</MetaGeneration>
|
128
|
+
|
129
|
+
<LastModified>2021-08-05T22:00:46.734Z</LastModified>
|
130
|
+
|
131
|
+
<ETag>"93ddb5c8a84a304b9ed915431c79d816"</ETag>
|
132
|
+
|
133
|
+
<Size>1154724</Size>
|
134
|
+
|
135
|
+
</Contents>
|
136
|
+
|
137
|
+
```
|
138
|
+
|
139
|
+
|
140
|
+
|
141
|
+
__get_divided_versionのversionをsplitしたとき、
|
142
|
+
|
143
|
+
versionの中身は「.3.150.2」となっており、
|
144
|
+
|
145
|
+
splitしたら[],[3],[150],[2]となってlen(divided_version)が4になってValueErrorになっている
|
146
|
+
|
147
|
+
ということで、
|
148
|
+
|
149
|
+
Python\Lib\site-packages\webdriver_manager\にある
|
150
|
+
|
151
|
+
driver.pyの
|
152
|
+
|
153
|
+
class IEDriver(Driver):の
|
154
|
+
|
155
|
+
__get_divided_versionの2行目に
|
156
|
+
|
157
|
+
version = version[1:]
|
158
|
+
|
159
|
+
を追加してみました。(下記コードの2行目です。)
|
160
|
+
|
161
|
+
|
162
|
+
|
163
|
+
```python
|
164
|
+
|
165
|
+
def __get_divided_version(self, version):
|
166
|
+
|
167
|
+
version = version[1:]
|
168
|
+
|
169
|
+
divided_version = version.split('.')
|
170
|
+
|
171
|
+
if len(divided_version) == 2:
|
172
|
+
|
173
|
+
return divided_version[0], divided_version[1], '0'
|
174
|
+
|
175
|
+
elif len(divided_version) == 3:
|
176
|
+
|
177
|
+
return divided_version
|
178
|
+
|
179
|
+
else:
|
180
|
+
|
181
|
+
raise ValueError(
|
182
|
+
|
183
|
+
"Version must consist of major, minor and/or patch, "
|
184
|
+
|
185
|
+
"but given was: {version}".format(version=self.get_version()))
|
186
|
+
|
187
|
+
```
|
188
|
+
|
189
|
+
すると以下のように、len(divided_version) == 3になりますので、
|
190
|
+
|
191
|
+
ダウンロードを試みるところまで進んだのですが、
|
192
|
+
|
193
|
+
ピリオドを削除した影響でurlのピリオドも消え、リンクが正しくなくなり、
|
194
|
+
|
195
|
+
ダウンロードに失敗しました。
|
196
|
+
|
197
|
+
|
198
|
+
|
199
|
+
```python
|
200
|
+
|
201
|
+
C:\work>python 01_ie_test.py
|
202
|
+
|
33
203
|
|
34
204
|
|
35
205
|
|
36
206
|
|
37
207
|
====== WebDriver manager ======
|
38
208
|
|
39
|
-
There is no [
|
209
|
+
There is no [Win32] IEDriverServer for browser in cache
|
210
|
+
|
211
|
+
Trying to download new driver from http://selenium-release.storage.googleapis.com/3.150/IEDriverServer_Win32_3.150.2.zip
|
40
212
|
|
41
213
|
Traceback (most recent call last):
|
42
214
|
|
43
215
|
File "C:\work\01_ie_test.py", line 4, in <module>
|
44
216
|
|
45
|
-
driver_path = IEDriverManager(os_type = "win
|
217
|
+
driver_path = IEDriverManager(os_type = "win32").install()
|
46
|
-
|
218
|
+
|
47
|
-
File "C:\Python\
|
219
|
+
File "C:\Python\lib\site-packages\webdriver_manager\microsoft.py", line 25, in install
|
48
220
|
|
49
221
|
return self._get_driver_path(self.driver)
|
50
222
|
|
51
|
-
File "C:\Python\
|
223
|
+
File "C:\Python\lib\site-packages\webdriver_manager\manager.py", line 30, in _get_driver_path
|
52
224
|
|
53
225
|
file = download_file(driver.get_url())
|
54
226
|
|
55
|
-
File "C:\Python\Python39\lib\site-packages\webdriver_manager\driver.py", line 172, in get_url
|
56
|
-
|
57
|
-
major, minor, patch = self.__get_divided_version(self.get_version())
|
58
|
-
|
59
|
-
File "C:\Python\Python39\lib\site-packages\webdriver_manager\driver.py", line 185, in __get_divided_version
|
60
|
-
|
61
|
-
raise ValueError(
|
62
|
-
|
63
|
-
ValueError: Version must consist of major, minor and/or patch, but given was: .3.150.2
|
64
|
-
|
65
|
-
```
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
### 試したコード
|
74
|
-
|
75
|
-
```python
|
76
|
-
|
77
|
-
from selenium import webdriver
|
78
|
-
|
79
|
-
from webdriver_manager.microsoft import IEDriverManager
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
driver_path = IEDriverManager().install()
|
84
|
-
|
85
|
-
driver = webdriver.Ie(driver_path)
|
86
|
-
|
87
|
-
driver.get('https://google.com')
|
88
|
-
|
89
|
-
```
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
### 自分で試したこと
|
94
|
-
|
95
|
-
Python\Lib\site-packages\webdriver_manager\にある
|
96
|
-
|
97
|
-
microsoft.pyのIEDriverManager()の__init__の引数urlに記載の
|
98
|
-
|
99
|
-
http://selenium-release.storage.googleapis.com
|
100
|
-
|
101
|
-
にアクセスしたところ、以下の記述があることを発見しました。
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
```html
|
106
|
-
|
107
|
-
<Contents>
|
108
|
-
|
109
|
-
<Key>3.150/IEDriverServer_Win32_.3.150.2.zip</Key>
|
110
|
-
|
111
|
-
<Generation>1628200845472844</Generation>
|
112
|
-
|
113
|
-
<MetaGeneration>1</MetaGeneration>
|
114
|
-
|
115
|
-
<LastModified>2021-08-05T22:00:45.502Z</LastModified>
|
116
|
-
|
117
|
-
<ETag>"6f17f688d643c40ea21c2610b55d259f"</ETag>
|
118
|
-
|
119
|
-
<Size>1062956</Size>
|
120
|
-
|
121
|
-
</Contents>
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
<Contents>
|
128
|
-
|
129
|
-
<Key>3.150/IEDriverServer_x64_.3.150.2.zip</Key>
|
130
|
-
|
131
|
-
<Generation>1628200846705412</Generation>
|
132
|
-
|
133
|
-
<MetaGeneration>1</MetaGeneration>
|
134
|
-
|
135
|
-
<LastModified>2021-08-05T22:00:46.734Z</LastModified>
|
136
|
-
|
137
|
-
<ETag>"93ddb5c8a84a304b9ed915431c79d816"</ETag>
|
138
|
-
|
139
|
-
<Size>1154724</Size>
|
140
|
-
|
141
|
-
</Contents>
|
142
|
-
|
143
|
-
```
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
__get_divided_versionのversionをsplitしたとき、
|
148
|
-
|
149
|
-
versionの中身は「.3.150.2」となっており、
|
150
|
-
|
151
|
-
splitしたら[],[3],[150],[2]となってlen(divided_version)が4になってValueErrorになっている
|
152
|
-
|
153
|
-
ということで、
|
154
|
-
|
155
|
-
Python\Lib\site-packages\webdriver_manager\にある
|
156
|
-
|
157
|
-
driver.pyの
|
158
|
-
|
159
|
-
class IEDriver(Driver):の
|
160
|
-
|
161
|
-
__get_divided_versionの2行目に
|
162
|
-
|
163
|
-
version = version[1:]
|
164
|
-
|
165
|
-
を追加してみました。(下記コードの2行目です。)
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
```python
|
170
|
-
|
171
|
-
def __get_divided_version(self, version):
|
172
|
-
|
173
|
-
version = version[1:]
|
174
|
-
|
175
|
-
divided_version = version.split('.')
|
176
|
-
|
177
|
-
if len(divided_version) == 2:
|
178
|
-
|
179
|
-
return divided_version[0], divided_version[1], '0'
|
180
|
-
|
181
|
-
elif len(divided_version) == 3:
|
182
|
-
|
183
|
-
return divided_version
|
184
|
-
|
185
|
-
else:
|
186
|
-
|
187
|
-
raise ValueError(
|
188
|
-
|
189
|
-
"Version must consist of major, minor and/or patch, "
|
190
|
-
|
191
|
-
"but given was: {version}".format(version=self.get_version()))
|
192
|
-
|
193
|
-
```
|
194
|
-
|
195
|
-
すると以下のように、len(divided_version) == 3になりますので、
|
196
|
-
|
197
|
-
ダウンロードを試みるところまで進んだのですが、
|
198
|
-
|
199
|
-
ピリオドを削除した影響でurlのピリオドも消え、リンクが正しくなくなり、
|
200
|
-
|
201
|
-
ダウンロードに失敗しました。
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
```python
|
206
|
-
|
207
|
-
C:\work>python 01_ie_test.py
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
====== WebDriver manager ======
|
214
|
-
|
215
|
-
There is no [Win32] IEDriverServer for browser in cache
|
216
|
-
|
217
|
-
Trying to download new driver from http://selenium-release.storage.googleapis.com/3.150/IEDriverServer_Win32_3.150.2.zip
|
218
|
-
|
219
|
-
Traceback (most recent call last):
|
220
|
-
|
221
|
-
File "C:\work\01_ie_test.py", line 4, in <module>
|
222
|
-
|
223
|
-
driver_path = IEDriverManager(os_type = "win32").install()
|
224
|
-
|
225
|
-
File "C:\Python\Python39\lib\site-packages\webdriver_manager\microsoft.py", line 25, in install
|
226
|
-
|
227
|
-
return self._get_driver_path(self.driver)
|
228
|
-
|
229
|
-
File "C:\Python\Python39\lib\site-packages\webdriver_manager\manager.py", line 30, in _get_driver_path
|
230
|
-
|
231
|
-
file = download_file(driver.get_url())
|
232
|
-
|
233
|
-
File "C:\Python\
|
227
|
+
File "C:\Python\lib\site-packages\webdriver_manager\utils.py", line 93, in download_file
|
234
228
|
|
235
229
|
validate_response(response)
|
236
230
|
|
237
|
-
File "C:\Python\
|
231
|
+
File "C:\Python\lib\site-packages\webdriver_manager\utils.py", line 79, in validate_response
|
238
232
|
|
239
233
|
raise ValueError("There is no such driver by url {}".format(resp.url))
|
240
234
|
|