Selenium.Essentials
2.0.1
dotnet add package Selenium.Essentials --version 2.0.1
NuGet\Install-Package Selenium.Essentials -Version 2.0.1
<PackageReference Include="Selenium.Essentials" Version="2.0.1" />
paket add Selenium.Essentials --version 2.0.1
#r "nuget: Selenium.Essentials, 2.0.1"
// Install Selenium.Essentials as a Cake Addin #addin nuget:?package=Selenium.Essentials&version=2.0.1 // Install Selenium.Essentials as a Cake Tool #tool nuget:?package=Selenium.Essentials&version=2.0.1
Selenium.Essentials
</br>
</br> </br> <a href="https://saucelabs.com"><img src="https://github.com/peterrexj/Selenium.Essentials/blob/develop/docs/resources/images/SauceLabLogo.svg" height="100"/></a> </br>
Package (Test Automation) | Description |
---|---|
<a href="https://www.nuget.org/packages/Selenium.Essentials">Selenium Essentials</a> | Build Selenium web automation test using advanced web controls with wrappers and plenty of extensions to fasten your automation development time |
<a href="https://www.nuget.org/packages/TestAny.Essentials.Api">Api Tests</a> | Simple and powerful framework to write API tests focused for Shift Left. For those who think quality as engineering and work along with the developers using .NET c# |
<a href="https://www.nuget.org/packages/Jira.Rest.Sdk">Jira Rest SDK</a> | SDK using Jira REST to query Jira application using Rest endpoints. Manage your Jira process from query, create and update issues. Integrate with you existing automation solution or process that will manage both Jira Server and Cloud based application |
<a href="https://www.nuget.org/packages/ZephyrScale.Rest.Sdk">Zephyr Scale Rest SDK</a> | SDK to connect to the Zephyr Scale app using Zephyr Scale's Rest endpoints. Manage your communication and easily retrieve and publish test cases, test cycle and execution results to Zephyr Scale. You can integrate with you existing automation solution or process that will manage these process. Support both Server and Cloud hosted Zephyr Scale application |
Notice: Release version 2.0.1
Selenium is upgraded to 4.23.0
Notice: Release version 1.3.0
All extensions and helpers are now moved to Pj library and should use
using Pj.Library
to your class if refering to any extensions or helpers. The document to the extensions and helpers will be updated soon.
Build Selenium web automation test using advanced web controls with wrappers and plenty of extensions to fasten your automation development time. Focus more on script logic with better consistent script execution, less maintenance, no hardwaits, with improved script execution performance and integrated Api testing framework.
Overview
Selenium provides only option to create only a single generic control which is called the IWebElement. Imagine if you have option to declare controls which resemble the html elements and provide its functionality, for example, Checkbox, Textbox, Button.
Selenium Essentials provide new custom controls giving meaning to your page objects and making it more readable. Every control is defined from a BaseControl which has a set of definitions applicable to all controls as well as its custom actions. For example, Checkbox control will have all properties of the BaseControl and also defines Check() which ticks the checkbox in the UI, UnCheck() which unticks the checkbox, IsChecked returns a bool value based on the control is Checked or Unchecked reading from the UI.
The Custom control also expose the underlying IWebElement as a property used by Selenium, in case you need to do any operations on top of this.
There are plenty of Wait operation defined on the base control which flows through all the custom controls. There are different overrides to the wait operation where you can control the time to wait, whether to throw exception if fails, message for assertions when the waits are used for assert operations. Some custom control overrides the default wait to give a better meaning.
WebDriver and WebElement comes with some useful extensions which helps during the automation. For example, executing javascript, scroll operations, taking screenshot, getting driver capabilities.
There is a simple Api framework, which can help in writing Integration tests using a fluent approach.
Package contains lots of extensions and helpers over different types which will help increase productivity. Example,
- Loading excel and converting to C#
- Converting Json to Dictionary
- Serialization and Deserialization
- Regular Expression, DateTime, String, Enumerable, Async
Benefits
- Readable page objects which clearly defines what each control resemble in the browser
- Custom controls with wrapped operations
- Checkbox - Check, UnCheck, IsChecked, more
- Textbox - Custom clear and set operations (extented clear which will make sure the content is cleared by doing Ctrl+a and BackSpace) and Set operation to overcome some responsive issues
- UnorderedList - Total, Items
- Select - operations on SelectElement
- Table - TotalColumns, TotalRows, ColumnNames, GeCellContent, GetRowPosition, GetColumnPosition, more
- Collection - working with Driver.FindElements(...)
- FileUpload - UploadFile
- Button
- WebControl - for all generic html control
- WebElement and WebDriver extension methods for most of the
- Api framework to write integration tests
- Supports fluent
- Support most of the operations
- Simple and easy to manage the tests
- Extensions which provide many methods for automation engineering works
- String, RegEx, Enumerable, DatTime, Async, more
- Helpers to load excel, serialization, Json to Dictonary, more
- Attributes for test to load json and xml data
Prerequisites
Visual Studio 2017 or higher
You need to know
- Minimum
- Good to know
- CI CD pipelines
- Multibrowser automated test configurations (any)
- Selenium Grid
- Sauce Labs
- Browser Stack
- Inhouse setup with physical servers and Vm
- Cloud configured machines to run tests
- Any custom setup to run multibrowser tests
- Mobile test with Appium
- Advanced Logging
- Test Reporting
- Programming knowledge
- c# Generics
- OOPS concepts
- Linq and Lamda (basic)
- Multithread programming
Install
nuget install Selenium.Essentials
Setup
Once you have setup your project or added the nuget package to your existing project, follow the links below to speed up your development.
Usage
Conventional way to declare elements (IWebElement)
private IWebElement _headerContent = driver.FindElement(By.Id("chkAreYouRobot"));
The below section show how to use new Checkbox
control. This definition is clear on what element in the UI corresponds to and also contains its custom properties and methods.
Add the using
statement for this package
using Selenium.Essentials
Define the new control in your page object. If you have existing page objects with IWebElement
, then you can easily change with same selector and passing it to the new custom control.
Remember, the driver is explicitly passed to the control, in order to have better control over the page object if you intend to run the scripts in parallel, on the same machine.
private CheckboxControl _userTypeCheck => new CheckboxControl(driver, By.Id("chkAreYouRobot"));
Notice the declaration is by an expression (=>) which does not store the value but fetch everytime when accessed. Following this pattern reduces StaleElementException.
To tick the checkbox
public void CheckUserType() {
_userTypeCheck.WaitForElementVisible(errorMessage: "The User Type checkbox was not visible in the UI"); //This can be used as an assertions, and when not found, it will throw with an exception with "errorMessage"
_userTypeCheck.Check();
}
Conditionally check if the element exist by waiting for maximum of 2 seconds and make a check operation if available. The below sample will not throw an exception if the control was not found in the browser, instead the WaitForElementVisible
will return false after 2 seconds and will not go inside the if
condition
public void CheckUserType() {
if (_userTypeCheck.WaitForElementVisible(waitTimeSec: 2, throwExceptionWhenNotFound: false)) {
_userTypeCheck.Check();
}
}
This is how it looks like when you have new controls in your page object
private ButtonControl _loginBtn => new ButtonControl(driver, By.Name("loginUser"));
private TextboxControl _usernameTxt => new TextboxControl(driver, By.Id("txtUserName"));
private TextboxControl _passwordTxt => new TextboxControl(driver, By.Id("txtPassword"));
private WebControl _headerContent => new WebControl(driver, By.CssSelector("div.user h2"));
private UnorderedListControl _tabNavigation => new UnorderedListControl(driver, By.XPath("//div[@id='p-namespaces']/ul"));
private TableControl _tableMainContent => new TableControl(driver, By.Id("mp-upper"));
Custom control default properties and methods (few listed)
Properties | Properties | Methods | Methods |
---|---|---|---|
IsReadonly |
Value |
GetAttribute(string) |
ScrollTo() |
IsDisabled |
Text |
Click() |
Clear() |
IsEnabled |
ElementId |
WaitAndClick(int) |
Highlight() |
IsVisible |
Class |
ScrollAndClick() |
|
CssDisplayed |
Classes |
ClickByJsScript() |
|
IsDisplayed |
Driver |
WaitClickAndIgnoreError() |
|
IsHidden |
RawElement |
SendKeys() |
|
Exists |
ParentControl |
SendEnter() |
|
XpathSelector |
ParentRawElement |
SendTab() |
|
By |
SetFocusByJavascript() |
Wait operations (few listed)
Wait On | Description |
---|---|
WaitUntilElementVisible |
Wait until the element is visible |
WaitUntilElementInvisible |
Wait until the element goes invisible |
WaitUntilElementEnabled |
Wait until the element is enabled |
WaitUntilElementExists |
Wait until the element exists |
WaitUntilElementCssDisplayed |
Wait until the element is Css Displayed (display: none not applied) |
WaitUntilElementClickable |
Wait until the element is clickable, which is element Exists, Displayed, CssDisplayed and Enabled |
WaitUntilElementTextTrimEquals |
Wait until the text on the element after trim is equal to the text passed for match |
WaitUntilElementTextStartsWith |
Wait until the text on the element after trim is starts with the text passed for match |
WaitUntilElementTextContains |
Wait until the text on the element contains the text passed for match |
WaitUntilElementHasSomeText |
Wait until the element has any text on it |
Most of the above operations are also added to IWebElement as extension methods
Documentation
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. 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. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Microsoft.CSharp (>= 4.7.0)
- Microsoft.Win32.Registry (>= 5.0.0)
- Newtonsoft.Json (>= 13.0.3)
- Pj.Library (>= 1.0.4.31)
- Pj.Library.ThirdParty (>= 1.0.4.31)
- Selenium.Support (>= 4.23.0)
- Selenium.WebDriver (>= 4.23.0)
- System.ValueTuple (>= 4.5.0)
- TestAny.Essentials.Api (>= 2.0.1)
- TestAny.Essentials.Core (>= 2.0.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
2.0.1 | 429 | 8/12/2024 |
1.0.7 | 281 | 7/25/2024 |
1.0.6 | 1,078 | 5/1/2024 |
1.0.5.28 | 454 | 3/10/2024 |
1.0.5.27 | 306 | 3/10/2024 |
1.0.5.26 | 1,337 | 11/22/2023 |
1.0.5.25 | 1,115 | 10/18/2023 |
1.0.5.24 | 972 | 10/17/2023 |
1.0.5.23 | 955 | 10/17/2023 |
1.0.5.22 | 1,057 | 10/16/2023 |
1.0.5.21 | 955 | 10/16/2023 |
1.0.5.20 | 974 | 10/13/2023 |
1.0.5.19 | 984 | 10/11/2023 |
1.0.5.18 | 1,033 | 10/10/2023 |
1.0.5.17 | 1,063 | 9/29/2023 |
1.0.5.16 | 1,198 | 9/6/2023 |
1.0.5.15 | 2,374 | 2/14/2023 |
1.0.5.14 | 1,790 | 11/21/2022 |
1.0.5.13 | 1,460 | 11/20/2022 |
1.0.5.12 | 1,517 | 11/15/2022 |
1.0.5.11 | 1,783 | 10/16/2022 |
1.0.5.10 | 2,245 | 9/1/2022 |
1.0.5.8 | 3,322 | 5/25/2022 |
1.0.5.6 | 7,838 | 4/12/2022 |
1.0.5.5 | 1,757 | 4/6/2022 |
1.0.5.4 | 1,642 | 4/5/2022 |
1.0.5.3 | 1,729 | 4/4/2022 |
1.0.5.2 | 1,837 | 3/20/2022 |
1.0.5.1 | 1,964 | 1/9/2022 |
1.0.5 | 1,629 | 12/31/2021 |
1.0.4.1 | 2,688 | 7/3/2021 |
1.0.4 | 1,601 | 7/3/2021 |
1.0.3.1 | 1,815 | 6/14/2021 |
1.0.3 | 1,600 | 6/14/2021 |
1.0.2.1 | 14,888 | 10/15/2020 |
1.0.2 | 3,610 | 11/3/2019 |
1.0.1 | 1,754 | 10/6/2019 |
1.0.0 | 1,764 | 10/6/2019 |
Release 1.0.5.15
- Newtonsoft package update due to vulnerability
Release 1.0.5.11
- BaseControl - RawElements - gives a list of RawElements if the request is to get more than one element (for collection control)
- BaseControl - NotExists - bool to return if the element does not exists and available for all controls
- BaseControl - DoubleClick - performs double click and available for all controls
- CollectionControl - Fix issue when search or operations were not considering the parent control
- CollectionControl - VisibleItem<control> at position - returns the item/element/control visible at the position
- CollectionControl - FirstVisibleControl<control> - returns the first visible item/element/control from the collection
- CollectionControl - FirstVisibleElement - returns element/control of type WebControl which is first visible in the collection
- CollectionControl - DoubleClick(position) - performs double click on the control at position
- CollectionControl - WaitForMinimumOne(position) - waits for the control/element at specified position is available
Release 1.0.5.7
- Pj library update to have environment variables load from local setting files. This feature will enable to control the critical informations required for the test to hold in a local file which can be git ignored.
Release 1.0.5.2
- Api Retry option now has ability to control on which httpstatuscode the retry should occur
Release 1.0.5.2
- Introduce Api framework with PUT PATCH commands
-- WithRetry option with time on interval
-- Response contains cookies extracted from domains
-- Cookie extension to merge and contact cookies
-- Introducing Proxy for API request based on the user data
-- Introducing Certificates to be passed on the request
-- Response has more request details from headers to cookies
- Tests are now upgraded to .NET 6
Release 1.0.5.1
- Bug fix when loading ApiResponse as HtmlContent
Release 1.0.5
- Introduce TestAny.Essentials.Core
- Introduce TestAny.Essentials.Api. All Api related functionality are moved into this new package
- There are some breaking changes
-- SeAppConfig is renamed to TestAnyAppConfig
-- TestAnyAppConfig is now moved into TestAny.Essentials.Core
-- TestContextHelper is renamed to TestAnyTestContextHelper
-- TestAnyTestContextHelper is now moved into TestAny.Essentials.Core
-- Dtos models are now moved into the Core project
Release 1.0.4
- Introduction of Selenium.Essentials.Api for Api testing
- Usage of utilities from Pj.Library
- Remove Utility class from Selenium Essentials
- Move properties from Utility class to SeAppConfig class
- Move InitializeFramework(..) from Utility to SeAppConfig class
Release 1.0.3.1
- Upgrade few dependent packages
Release 1.0.3
- All extensions and helpers are now referenced from Pj packages
- Usage of extensions are helpers should be followed by adding using Pj.Library to the class files
Release 1.0.2.1
Fix: Element wait throws exception when the element is not available
Feat: Use cache while loading excel data to improve the performace and to support multi worksheet loads from same workbook
Feat: Web driver extension - Switch window handle