Skip to content

Commit a0e1cd1

Browse files
authored
test: page tests, part 3 (#50)
1 parent afcf39e commit a0e1cd1

File tree

11 files changed

+478
-80
lines changed

11 files changed

+478
-80
lines changed

playwright/element_handle.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,8 @@ async def evalOnSelectorAll(
231231

232232

233233
def convertSelectOptionValues(arg: ValuesToSelect) -> Any:
234+
if arg is None:
235+
return []
234236
if isinstance(arg, ElementHandle):
235237
return arg._channel
236238
if isinstance(arg, list) and len(arg) and isinstance(arg[0], ElementHandle):

playwright/frame.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ def isDetached(self) -> bool:
206206
return self._detached
207207

208208
async def addScriptTag(
209-
self, url: str = None, path: str = None, content: str = None
209+
self, url: str = None, path: str = None, content: str = None, type: str = None,
210210
) -> ElementHandle:
211211
return from_channel(
212212
await self._channel.send("addScriptTag", locals_to_params(locals()))
@@ -282,7 +282,7 @@ async def selectOption(
282282
timeout: int = None,
283283
noWaitAfter: bool = None,
284284
) -> None:
285-
await self._channel.send(
285+
return await self._channel.send(
286286
"selectOption",
287287
dict(
288288
selector=selector,

playwright/page.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,10 @@ async def selectOption(
580580
timeout: int = None,
581581
noWaitAfter: bool = None,
582582
) -> None:
583-
return await self._main_frame.selectOption(**locals_to_params(locals()))
583+
params = locals_to_params(locals())
584+
if "values" not in params:
585+
params["values"] = None
586+
return await self._main_frame.selectOption(**params)
584587

585588
async def setInputFiles(
586589
self,

tests/assets/csp.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<meta http-equiv="Content-Security-Policy" content="default-src 'self'">

tests/assets/es6/.eslintrc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"parserOptions": {
3+
"sourceType": "module"
4+
}
5+
}

tests/assets/es6/es6import.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import num from './es6module.js';
2+
window.__es6injected = num;

tests/assets/es6/es6module.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export default 42;

tests/assets/es6/es6pathimport.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import num from './es6/es6module.js';
2+
window.__es6injected = num;

tests/assets/injectedstyle.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
body {
2+
background-color: red;
3+
}

tests/server.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@ def __init__(self):
3838
self.EMPTY_PAGE = f"http://localhost:{self.PORT}/empty.html"
3939
self.PREFIX = f"http://localhost:{self.PORT}"
4040
self.CROSS_PROCESS_PREFIX = f"http://127.0.0.1:{self.PORT}"
41+
# On Windows, this list can be empty, reporting text/plain for scripts.
42+
mimetypes.add_type("text/html", ".html")
43+
mimetypes.add_type("text/css", ".css")
44+
mimetypes.add_type("application/javascript", ".js")
45+
mimetypes.add_type("image/png", ".png")
46+
mimetypes.add_type("font/woff2", ".woff2")
4147

4248
def __repr__(self) -> str:
4349
return self.PREFIX

0 commit comments

Comments
 (0)