Class BrowserConfiguration
public class BrowserConfiguration : BaseConfiguration
- Inheritance
-
BrowserConfiguration
- Inherited Members
Properties
BrowserType
Gets or sets a value which specifies the browser type to use for the web tests. It can be one of the values from the BrowserType enum in the Playwright library, such as “chromium”, “firefox”, or “webkit”. The default value is “chromium”.
public string BrowserType { get; set; }
Property Value
Remarks
The BrowserType property is used by to create a new browser instance of the specified type. For example, you can set this property as follows
var settings = new TestSettings
{
BrowserType = BrowserType.Firefox;
}
Headless
public bool? Headless { get; set; }
Property Value
- bool?
Locale
Specify user locale, for example en-GB
, de-DE
, etc. Locale will affect navigator.language
value, Accept-Language
request header value as well as number and date formatting rules. Defaults to the
system default locale. Learn more about emulation in our
emulation guide.
public string? Locale { get; set; }
Property Value
WaitUntil
When to consider operation succeeded, defaults to load
. Events can be either:
-
'domcontentloaded'
- consider operation to be finished when theDOMContentLoaded
event is fired. -
'load'
- consider operation to be finished when theload
event is fired. -
'networkidle'
- **DISCOURAGED** consider operation to be finished when there are no network connections for at least500
ms. Don't use this method for testing, rely on web assertions to assess readiness instead. -
'commit'
- consider operation to be finished when network response is received and the document started loading.
public WaitUntilState? WaitUntil { get; set; }
Property Value
- WaitUntilState?
Methods
ClearGeolocation()
Removes the geolocation information from the test settings instance.
public void ClearGeolocation()
Remarks
This method clears any stored geolocation data associated with the Geolocation key in the PropertyBag. It is useful for resetting the test environment or ensuring that no location data persists between tests.
GetGeolocation()
Retrieves the geolocation coordinates from the test settings instance.
public Geolocation? GetGeolocation()
Returns
- Geolocation
A Geolocation object containing latitude and longitude coordinates if found; otherwise, null.
Remarks
This method attempts to retrieve the Geolocation object associated with the current test settings. If the PropertyBag contains the Geolocation key, the method will return the corresponding Geolocation object; otherwise, it will return null, indicating that no geolocation has been set.
SetGeolocation(Geolocation)
Stores the geolocation coordinates in the test settings instance for use with a headless browser.
public void SetGeolocation(Geolocation geolocation)
Parameters
geolocation
GeolocationThe Geolocation object containing latitude and longitude coordinates.
Remarks
note
Note that this method is not applicable for setting geolocation in an HttpClient instance, as HttpClient does not inherently support geolocation.