SpecFlowOSS / SpecFlow.Actions

BSD 3-Clause "New" or "Revised" License
57 stars 53 forks source link

Browserstack Credentials Not Being passed to DriverInitialiser #88

Closed tomrobinsonv closed 2 years ago

tomrobinsonv commented 2 years ago

I have set up my specflow project up almost identically to match your Browserstack implementation, although the only thing I haven't been able to get working is the credentials.

SpecFlow.NUnit - V3.9.74 SpecFlow.Actions.Browserstack - V0.1.322

Target Framework - netcoreapp3.1 Language Version - 9.0

The error I'm getting now

` Message: OpenQA.Selenium.WebDriverException : Unexpected error. Authorization required TearDown : OpenQA.Selenium.WebDriverException : Unexpected error. Authorization required

Stack Trace: RemoteWebDriver.UnpackAndThrowOnError(Response errorResponse) RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary2 parameters) RemoteWebDriver.StartSession(ICapabilities desiredCapabilities) RemoteWebDriver.ctor(ICommandExecutor commandExecutor, ICapabilities desiredCapabilities) RemoteWebDriver.ctor(Uri remoteAddress, ICapabilities desiredCapabilities, TimeSpan commandTimeout) RemoteWebDriver.ctor(Uri remoteAddress, ICapabilities desiredCapabilities) RemoteWebDriver.ctor(Uri remoteAddress, DriverOptions options) BrowserstackDriverInitialiser.GetWebDriver(DriverOptions options) BrowserstackChromeDriverInitialiser.CreateWebDriver(ChromeOptions options) DriverInitialiser1.Initialise()

<29 more frames...> Lazy`1.get_Value() BrowserDriver.get_Current() BrowserstackRuntimePlugin.RuntimePluginTestExecutionLifecycleEventEmitter_AfterScenario(Object sender, RuntimePluginAfterScenarioEventArgs e) RuntimePluginTestExecutionLifecycleEvents.RaiseAfterScenario(IObjectContainer objectContainer) RuntimePluginTestExecutionLifecycleEventEmitter.RaiseExecutionLifecycleEvent(HookType hookType, IObjectContainer container) TestExecutionEngine.FireEvents(HookType hookType) TestExecutionEngine.FireScenarioEvents(HookType bindingEvent) TestExecutionEngine.OnScenarioEnd() TestRunner.OnScenarioEnd() ManualVehicleSearchFeature.TestTearDown() ` My BrowserstackCredentialProvider class ` class BrowserstackCredentialProvider : ICredentialProvider { private readonly Lazy _browserstackUsername; private readonly Lazy _accessKey; public BrowserstackCredentialProvider() { Console.WriteLine("FEtching authoria"); _browserstackUsername = new Lazy(() => Environment.GetEnvironmentVariable("BROWSERSTACK_USER")); _accessKey = new Lazy(() => Environment.GetEnvironmentVariable("BROWSERSTACK_KEY")); } public string? Username => _browserstackUsername.Value; public string? UsernameArgumentName => "browserstack.user"; public string? AccessKey => _accessKey.Value; public string? AccessKeyArgumentName => "browserstack.key"; } ` I have double checked my environment variables and they are definitely valid. I also added the logging line in the constructor method but this never gets called.
mrampass commented 2 years ago

Hello , Could you please mention the webdriver package version that you are using ?

tomrobinsonv commented 2 years ago

Hii, the Selenium Webdriver version I have is 3.141.0

tomrobinsonv commented 2 years ago

I've just updated to the latest version 4.1.1 but still the same error.

tomrobinsonv commented 2 years ago

Hi, quick update. I have managed to access the browserstack server but only after setting my credentials in the specflow.actions.json file which will be exposed in the repo. Even though this is now working, I have ran into another issue which is that the driver is not being destroyed after a scenario. Every taste hangs for over a minute after the test has finished and manually quitting the driver in the AfterScenario hook method doesn't work. Can we address this on this issue, or do you want a new issue raised?