@@ -11,13 +11,18 @@ def base_url() -> str:
1111
1212
1313@pytest .fixture (scope = "session" )
14- def basic_auth () -> dict [str , str ]:
14+ def basic_auth_credentials () -> dict [str , str ]:
1515 return {
1616 "username" : os .environ ["BASIC_AUTH_USERNAME" ],
1717 "password" : os .environ ["BASIC_AUTH_PASSWORD" ],
1818 }
1919
2020
21+ @pytest .fixture (scope = "session" )
22+ def basic_auth_token () -> str :
23+ return os .environ ["BASIC_AUTH_TOKEN" ]
24+
25+
2126@pytest .fixture (scope = "session" )
2227def browser_type (playwright : Playwright , device : Optional [str ]) -> BrowserType :
2328 device = device or "Desktop Chrome"
@@ -26,5 +31,13 @@ def browser_type(playwright: Playwright, device: Optional[str]) -> BrowserType:
2631
2732
2833@pytest .fixture (scope = "session" )
29- def browser_context_args (browser_context_args , basic_auth ):
30- return {** browser_context_args , "http_credentials" : basic_auth }
34+ def browser_context_args (
35+ browser_context_args , basic_auth_credentials , basic_auth_token
36+ ) -> dict :
37+ if basic_auth_token :
38+ return {
39+ ** browser_context_args ,
40+ "extra_http_headers" : {"Authorization" : f"Basic { basic_auth_token } " },
41+ }
42+
43+ return {** browser_context_args , "http_credentials" : basic_auth_credentials }
0 commit comments