@@ -42,29 +42,29 @@ async def _run_chromium_devtools() -> Tuple[subprocess.Popen, str]:
42
42
return proc , devtools_url
43
43
44
44
45
- def _run_playwright_browser_server () -> Tuple [subprocess .Popen , str ]:
45
+ def _run_chromium_browser_server () -> Tuple [subprocess .Popen , str ]:
46
46
"""Start a Playwright server in a separate process, return the process
47
47
object and a string with its websocket endpoint.
48
48
Pass fixed port and ws path as arguments instead of allowing Playwright
49
49
to choose, for some reason I was unable to capture stdout/stderr :shrug:
50
50
"""
51
51
port = str (random .randint (60_000 , 63_000 ))
52
52
ws_path = str (uuid .uuid4 ())
53
- launch_server_script_path = str (Path (__file__ ).parent .parent / "launch_browser_server .js" )
53
+ launch_server_script_path = str (Path (__file__ ).parent .parent / "launch_chromium_server .js" )
54
54
command = ["node" , launch_server_script_path , port , ws_path ]
55
55
proc = subprocess .Popen (command ) # pylint: disable=consider-using-with
56
56
return proc , f"ws://localhost:{ port } /{ ws_path } "
57
57
58
58
59
59
@asynccontextmanager
60
- async def remote_browser ( is_chrome_devtools_protocol : bool = True ):
60
+ async def remote_chromium ( with_devtools_protocol : bool = True ):
61
61
"""Launch a remote browser that lasts while in the context."""
62
62
proc = url = None
63
63
try :
64
- if is_chrome_devtools_protocol :
64
+ if with_devtools_protocol :
65
65
proc , url = await _run_chromium_devtools ()
66
66
else :
67
- proc , url = _run_playwright_browser_server ()
67
+ proc , url = _run_chromium_browser_server ()
68
68
await asyncio .sleep (1 ) # allow some time for the browser to start
69
69
except Exception :
70
70
pass
@@ -77,15 +77,15 @@ async def remote_browser(is_chrome_devtools_protocol: bool = True):
77
77
proc .communicate ()
78
78
79
79
80
- class TestRemote (IsolatedAsyncioTestCase ):
80
+ class TestRemoteBrowser (IsolatedAsyncioTestCase ):
81
81
@pytest .fixture (autouse = True )
82
82
def inject_fixtures (self , caplog ):
83
83
caplog .set_level (logging .DEBUG )
84
84
self ._caplog = caplog
85
85
86
86
@allow_windows
87
87
async def test_connect_devtools (self ):
88
- async with remote_browser ( is_chrome_devtools_protocol = True ) as devtools_url :
88
+ async with remote_chromium ( with_devtools_protocol = True ) as devtools_url :
89
89
settings_dict = {
90
90
"PLAYWRIGHT_CDP_URL" : devtools_url ,
91
91
"PLAYWRIGHT_LAUNCH_OPTIONS" : {"headless" : True },
@@ -103,7 +103,7 @@ async def test_connect_devtools(self):
103
103
104
104
@allow_windows
105
105
async def test_connect (self ):
106
- async with remote_browser ( is_chrome_devtools_protocol = False ) as browser_url :
106
+ async with remote_chromium ( with_devtools_protocol = False ) as browser_url :
107
107
settings_dict = {
108
108
"PLAYWRIGHT_CONNECT_URL" : browser_url ,
109
109
"PLAYWRIGHT_LAUNCH_OPTIONS" : {"headless" : True },
0 commit comments