Free tools Windows power users keep installed
One-click scans. No signup required.
Selenium’s C# browser commands let you open pages, inspect the current browsing context, find and operate on elements, manage windows and cookies, and wait for application state. The examples below use the IWebDriver interface with ChromeDriver; other drivers can be used where supported. The official API is a living reference, so check signatures and capabilities against the Selenium package and browser driver installed in your project.
Start a browser session and navigate
IWebDriver is Selenium’s main interface for controlling a browser session. Create a concrete driver such as ChromeDriver, then use Navigate().GoToUrl(...) to load a page:
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
IWebDriver driver = new ChromeDriver();
driver.Navigate().GoToUrl("https://www.selenium.dev/selenium/web/web-form.html");
The Navigate() method returns an INavigation interface. Use it for direct URL navigation and browser-history actions. Setting driver.Url also loads a URL using HTTP GET; redirects can affect when control returns. See Selenium’s IWebDriver API and C# first-script example.
Navigation command choices
| Need | Command | What it does |
|---|---|---|
| Load a known URL | driver.Navigate().GoToUrl(url) or set driver.Url |
Requests the URL and waits according to the configured page-load strategy. |
| Return to the prior history entry | driver.Navigate().Back() |
Uses the browser’s back navigation. |
| Move forward in history | driver.Navigate().Forward() |
Uses the browser’s forward navigation. |
| Reload the current page | driver.Navigate().Refresh() |
Refreshes the current browsing context. |
Inspect the current browsing context
These IWebDriver properties describe the selected browser window and its current page:
Do these 3 things before closing this tab:
1Fix the driver behind crashes, sound loss and screen glitches2Repair Windows errors before they cause bigger problems3Scan for outdated or missing drivers - takes under a minute#1 Best Overall
driver.Urlgets the current URL.driver.Titlegets the current window’s title.driver.PageSourcereturns a representation of the page’s underlying DOM.driver.CurrentWindowHandleidentifies the selected window, whiledriver.WindowHandleslists the open window handles.
Do not treat PageSource as a guaranteed snapshot of the live DOM after JavaScript changes the page. Selenium’s API documentation notes that it may not reflect post-load modifications and is not necessarily formatted like the original server response.
Find elements and interact with them
Use By to specify how to locate an element, and use the returned IWebElement to interact with it. FindElement is for a match you expect to exist; FindElements returns a collection and is useful when there may be zero or multiple matches.
var textBox = driver.FindElement(By.Name("my-text"));
var submitButton = driver.FindElement(By.TagName("button"));
textBox.SendKeys("Selenium");
submitButton.Click();
var message = driver.FindElement(By.Id("message")).Text;
Common locator strategies include By.Id(...), By.Name(...), By.TagName(...) and other By methods. Choose a locator that identifies the intended element reliably on the page. The IWebElement API provides actions such as Click() and SendKeys(...), and properties such as Text. The official C# example demonstrates the form interaction above.
Element references can become stale when the page replaces or redraws the corresponding DOM node. If that happens, wait for the new state and locate the element again rather than assuming an earlier reference remains valid. Use Selenium’s element finders guidance for locator details.
Rank #2
Wait for the state your next command needs
A navigation command waits for a document readyState determined by the page-load strategy; the default target is complete. That does not guarantee that a JavaScript application has finished rendering the control your test needs. Waiting for the specific condition before acting helps avoid timing races.
Condition-specific explicit wait
A WebDriverWait can repeatedly evaluate a condition until it succeeds or its timeout expires. This example waits up to three seconds for an element to be found:
using OpenQA.Selenium.Support.UI;
var wait = new WebDriverWait(driver, TimeSpan.FromSeconds(3));
var element = wait.Until(d => d.FindElement(By.Name("q")));
Use a condition that corresponds to the action you need next, such as an element becoming available. The .NET WebDriverWait API documents the wait interface.
Implicit wait versus explicit wait
An implicit wait is a session-wide setting that affects element searches; an explicit wait is applied at a particular point and tests a stated condition. Prefer explicit waits when the application’s required state is specific. Selenium warns: “Do not mix implicit and explicit waits. Doing so can cause unpredictable wait times.” See the official Waiting Strategies guide.
PC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minuteManage timeouts, cookies, windows, and frames
driver.Manage() provides access to browser-session options, including timeouts, cookies and window controls. The precise methods available depend on the installed .NET API; consult its namespace reference for the version in your project.
driver.SwitchTo() selects a target context, such as a frame or another window. Subsequent driver commands operate in that selected context. Switch back when the next action belongs to the parent page or another window. For windows, use WindowHandles to inspect open handles and select the intended one through the target locator.
Close a window or end the session
driver.Close() closes the current window; if it is the last window, the browser quits. driver.Quit() ends the WebDriver session and closes all windows associated with it. Use Quit() in cleanup so the session is ended even if an assertion or command fails:
IWebDriver driver = new ChromeDriver();
try
{
driver.Navigate().GoToUrl("https://www.selenium.dev/selenium/web/web-form.html");
// Run test steps and assertions here.
}
finally
{
driver.Quit();
}
In a test framework, put session cleanup in the framework’s teardown or equivalent guaranteed cleanup path.
Rank #4
Other Selenium command families
The .NET WebDriver class also exposes JavaScript execution and screenshot-related functionality. Selenium’s namespace reference lists additional interfaces for alerts, logs, actions, printing, downloads and network handling. These are useful when a test requires those capabilities, but actual support and behavior can vary by browser driver; check the relevant API and driver documentation before relying on a command.
Troubleshoot common command problems
Element search fails
If FindElement cannot locate a match, check that the locator targets the correct element and that the page has reached the needed state. For dynamic content, wait for the condition and then search again. Use FindElements when an empty result is an expected possibility.
An element reference is stale
A page update may have replaced the DOM node represented by the reference. Wait for the updated page state and locate the element again before interacting with it.
The page loaded, but a control is not ready
Page-load completion does not establish that client-side rendering or application work is finished. Wait explicitly for the element or state needed by the next test step.
Best Value
Wait duration behaves unpredictably
Check whether the session combines implicit and explicit waits. Selenium advises against mixing them; use a consistent wait strategy, usually a condition-specific explicit wait for dynamic page behavior.
Commands target the wrong window or frame
Check the selected context. Inspect WindowHandles and use SwitchTo() to select the intended window or frame before issuing commands.
Or skip the browser setup
If your goal is to capture a page image or PDF rather than automate browser interactions, ScreenshotNeo offers a one-request screenshot API. It removes cookie and consent banners, newsletter popups and chat widgets before capture; bot checks, blank pages and failed loads are never billed. Its MCP server lets AI agents take screenshots, and 1,000 screenshots a month are free with no card; paid plans start at $5 for 3,000.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
See the ScreenshotNeo API documentation for options and response details. Sign up for 1,000 free screenshots a month, with no card required.
Recommended Free Tools
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




