Futile.SpecFlow.Actions.Selenium
0.1.350.7
dotnet add package Futile.SpecFlow.Actions.Selenium --version 0.1.350.7
NuGet\Install-Package Futile.SpecFlow.Actions.Selenium -Version 0.1.350.7
<PackageReference Include="Futile.SpecFlow.Actions.Selenium" Version="0.1.350.7" />
paket add Futile.SpecFlow.Actions.Selenium --version 0.1.350.7
#r "nuget: Futile.SpecFlow.Actions.Selenium, 0.1.350.7"
// Install Futile.SpecFlow.Actions.Selenium as a Cake Addin #addin nuget:?package=Futile.SpecFlow.Actions.Selenium&version=0.1.350.7 // Install Futile.SpecFlow.Actions.Selenium as a Cake Tool #tool nuget:?package=Futile.SpecFlow.Actions.Selenium&version=0.1.350.7
Futile.SpecFlow.Actions.Selenium
This SpecFlow.Action will help you use Selenium together with SpecFlow. It handles the lifetime of your browser and provides easy configuration and helper methods to interact with Selenium.
Futile?
Work on Specflow has been discontinued and the successor is reqnroll (status May 2024). This nuget package comes from a fork that:
- Includes some bug fixes
- Uses
net48
andnet6.0
Updated examples can be found here: Futile.SpecFlow-Examples.
Note: Requires environment variable
FIREFOX_WEBDRIVER_FILE_PATH
which points to a installed geckodriver.
Included Features
- Lifetime handling of Browser
- Supported Browsers
- Chrome
- Firefox
- Edge
- Internet Explorer
- Safari
- Supported Browsers
- Configuration via
specflow.actions.json
- Helper Methods for WebDriver
- Helper Extension Methods for WebElement
Configuration
You can configure this plugin via the specflow.actions.json
.
Example:
{
"selenium": {
"browser": "chrome",
"arguments": [
"--start-maximized",
"--incognito"
],
"capabilities" : {
"some_capability": "the value",
"some_other_capability": "also a value"
},
"defaultTimeout": 60,
"pollingInterval": 5
}
}
browser
Supported values:
chrome
firefox
internetexplorer
edge
safari
Multiple target configurations
This plugin supports tagreting of multiple configurations at runtime. For each configuration you provide, a class will be generated in your feature's code behind file when you build the project. This means that for any given test, the test will be executed against each target.
Example:
specflow.actions.chrome.json
{
"selenium": {
"browser": "chrome"
}
}
specflow.actions.firefox.json
{
"selenium": {
"browser": "firefox"
}
}
For the example shown above, all tests will execute against both Chrome and Firefox. The configuration format of these targets follows the same structure as if you provide a single config in specflow.actions.json
How to use it
The browser is started automatically when you try to use the WebDriver the first time. It is closed after the scenario ends.
BrowserInteractions
This class gives you helper methods to work with the Webdriver. If necessary, it is waiting for completness of the action.
Available Helper Methods:
IWebElement WaitAndReturnElement(By elementLocator)
Waits for the element to exist and returns it using the specified element localisationIEnumerable<IWebElement> WaitAndReturnElements(By elementLocator)
Waits for the element(s) to exist and returns them using the specified element localisationvoid GoToUrl(string url)
Goes to the specified urlstring GetUrl()
Gets the current URLT? WaitUntil<T>(Func<T> getResult, Func<T, bool> isResultAccepted)
Helper method to wait until the expected result is available on the UI
Usage:
[Binding]
public class StepImplementation
{
private IBrowserInteractions _browserInteractions;
public StepImplementation(IBrowserInteractions browserInteractions)
{
_browserInteractions = browserInteractions;
}
[Given("")]
public void SomeStep()
{
var currentUrl = _browserInteractions.GetUrl();
}
}
BrowserDriver
This class gives you direct access to the WebDriver. Request an instance via context injection and access it via the Current
property.
[Binding]
public class StepImplementation
{
private BrowserDriver _browserDriver;
public StepImplementation(BrowserDriver browserDriver)
{
_browserDriver = browserDriver;
}
[Given("")]
public void SomeStep()
{
var currentUrl = _browserDriver.Current.Url;
}
}
WebElementExtensions
This class gives to helper extension methods on the WebElements
Available Helper Methods:
public static void SendKeysWithClear(this IWebElement webElement, string keys)
Clears and sends keystrokes to the specified web elementpublic static void ClickWithRetry(this IWebElement webElement, int retryCount = 3)
Attempts to click the specified web element, ignoring intercepted clicks for a number of attemptspublic static SelectElement GetSelectElement(this IWebElement webElement)
Returns a new select elementpublic static void SelectDropdownOptionByIndex(this IWebElement webElement, int index)
Selects an option from a select element by index valuepublic static void SelectDropdownOptionByText(this IWebElement webElement, string text)
Selects an option from a select element by textpublic static void SelectDropdownOptionByValue(this IWebElement webElement, string value)
Selects an option from a select element by its valuepublic static void SelectRandomDropdownOption(this IWebElement webElement)
Selects a random dropdown optionpublic static IEnumerable<IWebElement> WhereElementsHaveClass(this IEnumerable<IWebElement> webElements, string className)
Finds and returns web elements that contain the specified class namepublic static IEnumerable<IWebElement> WhereElementsHaveValue(this IEnumerable<IWebElement> webElements, string value)
Finds and returns web elements that have the specified valuepublic static bool HasClass(this IWebElement webElement, string className)
Checks if the web element contains a specified class namepublic static bool HasValue(this IWebElement webElement, string value)
Checks if the web element contains a specified value from its value attributepublic static IEnumerable<IWebElement> WhereElementsAreDisplayed(this IEnumerable<IWebElement> webElements)
Returns only web elements that are displayedpublic static IEnumerable<IWebElement> WhereElementsHavePropertyValue(this IEnumerable<IWebElement> webElements, string propertyName, string value)
Returns web elements that have the expected value from a specified propertypublic static IWebElement MoveToElement(this IWebElement webElement, IWebDriver driver)
Move the mouse to the specific element. Scroll element into viewport and return the web element.
How to get it
Add the latest version of the Futile.SpecFlow.Actions.Selenium
NuGet Package to your project.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. 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 Framework | net48 is compatible. net481 was computed. |
-
.NETFramework 4.8
- Futile.SpecFlow.Actions.Configuration (>= 0.1.350.7)
- Selenium.Support (>= 4.24.0)
- SpecFlow (>= 3.9.74)
- System.Text.Json (>= 8.0.4)
-
net6.0
- Futile.SpecFlow.Actions.Configuration (>= 0.1.350.7)
- Selenium.Support (>= 4.24.0)
- SpecFlow (>= 3.9.74)
- System.Text.Json (>= 8.0.4)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.