SeleniumExtensionMethods 1.0.1
dotnet add package SeleniumExtensionMethods --version 1.0.1
NuGet\Install-Package SeleniumExtensionMethods -Version 1.0.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="SeleniumExtensionMethods" Version="1.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SeleniumExtensionMethods" Version="1.0.1" />
<PackageReference Include="SeleniumExtensionMethods" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add SeleniumExtensionMethods --version 1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: SeleniumExtensionMethods, 1.0.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package SeleniumExtensionMethods@1.0.1
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=SeleniumExtensionMethods&version=1.0.1
#tool nuget:?package=SeleniumExtensionMethods&version=1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
SeleniumExtensionMethods
Some extension methods for writing less code without throwing an exception for Selenium Library.
Usage
using OpenQA.Selenium;
using OpenQA.Selenium.Firefox;
using SeleniumExtensionMethods.SeleniumExtensions.WebDriverExtensions;
using SeleniumExtensionMethods.SeleniumExtensions.WebElementExtensions;
IWebDriver driver = new FirefoxDriver();
string webUrl = "https://www.wikipedia.org/";
driver.WaitingForEachPageToLoad(TimeSpan.FromSeconds(3));
driver.GotoUrl(webUrl);
driver?.FindElementIfExistsByTagName("html")
?.SendKeys(Keys.End);//scroll down
driver?.FindElementIfExistsById("searchLanguage")
.ClickOnElement();
driver?.FindElementIfExistsByCssSelector("#searchLanguage > option:nth-child(21)")
.ClickOnElement();
driver?.FindElementIfExists(By.Id("searchInput"))//This extension method and FindElementsIfExists are only for use in other extension methods, and you must use FindElementIfExistsById or FindElementsIfExistsById
?.WriteInElement("کوروش");
driver?.FindElementIfExistsById("searchInput")
?.WriteAppendInElement($" بزرگ");
driver?.FindElementIfExistsById("searchInput")
?.WritePrependInElement("پادشاه " + Keys.Enter);
driver?.FindElementIfExistsByLinkText("کوروش بزرگ")
?.ClickOnElement();
driver?.FindElementIfExistsById("p-lang-btn")
.ClickOnElement();
driver?.FindElementIfExistsByXPath("/html/body/div[1]/div[2]/div[1]/div/ul[2]/li[3]/a")
?.ClickOnElement();
driver?.FindElementIfExistsByCssSelector("#mw-normal-catlinks > ul:nth-child(2) > li:nth-child(1) > a:nth-child(1)")
?.ClickOnElement();
driver?.FindElementIfExistsById("searchInput")
?.WriteInElement("ljklkjfdfdjkfasdfl")
?.ClearTextInputElement();
driver?.FindElementIfExistsByTagName("html")
?.SendKeys(Keys.Home);//scroll up
driver?.FindElementIfExistsById("searchInput")
?.SendKeys("Order of Assassins" + Keys.Enter);
driver?.FindElementIfExistsByXPath("/html/body/div[3]/div[3]/div[5]/div[1]/div[4]/ul/li[5]/a")
?.ClickOnElement();
driver?.FindElementIfExistsById("p-logo")
?.ClickOnElement();
driver?.FindElementIfExistsById("ca-viewsource")
?.ClickOnElement();
driver?.FindElementIfExistsById("wpTextbox1")
?.SendKeys(Keys.End);
Note:
If extension methods can not find a web element, extension methods return null instead of throwing exceptions.
Install
Install-Package SeleniumExtensionMethods -Version 1.0.0
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.
License
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net7.0
- Selenium.Support (>= 4.8.1)
- Selenium.WebDriver (>= 4.8.1)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on SeleniumExtensionMethods:
Package | Downloads |
---|---|
SeleniumChain
SeleniumChain Library for fluent commands. |
GitHub repositories
This package is not used by any popular GitHub repositories.