MCPcopy Create free account
hub / github.com/SeleniumHQ/selenium / WebDriver

Class WebDriver

dotnet/src/webdriver/WebDriver.cs:33–1164  ·  view source on GitHub ↗

A base class representing a driver for a web browser.

Source from the content-addressed store, hash-verified

31/// A base class representing a driver for a web browser.
32/// </summary>
33public class WebDriver : IWebDriver, ISearchContext, IJavaScriptExecutor, IFindsElement, ITakesScreenshot, ISupportsPrint, IActionExecutor, IAllowsFileDetection, IHasCapabilities, IHasCommandExecutor, IHasSessionId, ICustomDriverCommandExecutor, IHasVirtualAuthenticator
34{
35 /// <summary>
36 /// The default command timeout for HTTP requests in a RemoteWebDriver instance.
37 /// </summary>
38 protected static readonly TimeSpan DefaultCommandTimeout = TimeSpan.FromSeconds(60);
39 private IFileDetector fileDetector = new DefaultFileDetector();
40 private NetworkManager? network;
41 private WebElementFactory elementFactory;
42
43 private readonly List<string> registeredCommands = new List<string>();
44
45 /// <summary>
46 /// Initializes a new instance of the <see cref="WebDriver"/> class.
47 /// </summary>
48 /// <param name="executor">The <see cref="ICommandExecutor"/> object used to execute commands.</param>
49 /// <param name="capabilities">The <see cref="ICapabilities"/> object used to configure the driver session.</param>
50 protected WebDriver(ICommandExecutor executor, ICapabilities capabilities)
51 {
52 this.CommandExecutor = executor;
53 this.elementFactory = new WebElementFactory(this);
54 this.registeredCommands.AddRange(DriverCommand.KnownCommands);
55
56 if (this is ISupportsLogs)
57 {
58 // Only add the legacy log commands if the driver supports
59 // retrieving the logs via the extension end points.
60 this.RegisterDriverCommand(DriverCommand.GetAvailableLogTypes, new HttpCommandInfo(HttpCommandInfo.GetCommand, "/session/{sessionId}/se/log/types"), true);
61 this.RegisterDriverCommand(DriverCommand.GetLog, new HttpCommandInfo(HttpCommandInfo.PostCommand, "/session/{sessionId}/se/log"), true);
62 }
63
64 try
65 {
66 this.StartSession(capabilities);
67 }
68 catch (Exception)
69 {
70 try
71 {
72 // Failed to start driver session, disposing of driver
73 this.Dispose();
74 }
75 catch
76 {
77 // Ignore the clean-up exception. We'll propagate the original failure.
78 }
79 throw;
80 }
81 }
82
83 /// <summary>
84 /// Gets the <see cref="ICommandExecutor"/> which executes commands for this driver.
85 /// </summary>
86 public ICommandExecutor CommandExecutor { get; }
87
88 /// <summary>
89 /// Gets the <see cref="ICapabilities"/> that the driver session was created with, which may be different from those requested.
90 /// </summary>

Callers

nothing calls this directly

Calls 6

ExecuteMethod · 0.95
EnsureValueIsNotNullMethod · 0.80
ToStringMethod · 0.45
GoToUrlMethod · 0.45
AddMethod · 0.45
AsReadOnlyMethod · 0.45

Tested by

no test coverage detected