Skip to content

Commit 10088a6

Browse files
committed
fixes
1 parent f535d4f commit 10088a6

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

playwright/_impl/_browser_type.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -152,11 +152,7 @@ async def launch_persistent_context(
152152
recordHarContent: HarContentPolicy = None,
153153
clientCertificates: List[ClientCertificate] = None,
154154
) -> BrowserContext:
155-
userDataDir = (
156-
str(Path(userDataDir))
157-
if (Path(userDataDir).is_absolute() or not userDataDir)
158-
else str(Path(userDataDir).resolve())
159-
)
155+
userDataDir = self._user_data_dir(userDataDir)
160156
params = locals_to_params(locals())
161157
await prepare_browser_context_params(params)
162158
normalize_launch_params(params)
@@ -167,6 +163,13 @@ async def launch_persistent_context(
167163
self._did_create_context(context, params, params)
168164
return context
169165

166+
def _user_data_dir(self, userDataDir: Optional[Union[str, Path]]) -> str:
167+
if not userDataDir:
168+
return ""
169+
if not Path(userDataDir).is_absolute():
170+
return str(Path(userDataDir).resolve())
171+
return str(Path(userDataDir))
172+
170173
async def connect_over_cdp(
171174
self,
172175
endpointURL: str,

0 commit comments

Comments
 (0)