Closed rightmax1234 closed 2 years ago
Hello,
You can use SpecFlow.Actions.Configuration in all classes which use the specflow [Binding] and inject the config that is currently run.
using Specflow.Actions.Browserstack.IntegrationTests.PageObjects;
using SpecFlow.Actions.Configuration;
using SpecFlow.Actions.Selenium;
using TechTalk.SpecFlow;
namespace Specflow.Actions.Browserstack.IntegrationTests.Hooks
{
[Binding]
public class CalculatorHooks
{
private readonly IBrowserInteractions _browserInteractions;
private readonly ISpecFlowActionsConfiguration _specFlowActionsConfiguration;
public CalculatorHooks(ISpecFlowActionsConfiguration specFlowActionsConfiguration, IBrowserInteractions browserInteractions)
{
_browserInteractions = browserInteractions;
_specFlowActionsConfiguration = specFlowActionsConfiguration;
var deviceName = _specFlowActionsConfiguration.Get("selenium:capabilities:device");
}
}
}
@mrampass is completly correct.
Hi, I've had a look at the docs and I'm not sure if I've just missed it. But is there any method that I can call to get the current device the tests are running on, so I can tailor my tests to each target.
So if I have this specflow json file
{ "selenium": { "browser": "Chrome", "capabilities": { "browser": "samsung", "device": "Samsung Galaxy S20", "os_version": "10", "build": "Samsung_Galaxy_S20.Samsung" } } }
Is there any way to get the current device in the code?