-1

We are starting to implement BDD and we have a scenario that I don't know how to implement.

We implemented BDD using Specflow with selenium.

In the web page there's a Dropdown that when you switch the content, the web page also changes. I would like to iterate through that dropdown and check that the changes are applied correctly using Gherkin but I would like to do it the most effective way possible.

Also is it possible to do it without reloading the driver every time?

1 Answers1

0

I would recommend to use a DataTable. First some steps to enter page, then in step with table, where one column - value, which needed to select, other values - what to validate on page. Second way, I would use Scenario Outline, but this is not so effective, as you want.

Ukrainis
  • 534
  • 2
  • 16
  • Basically in my `Given` section, I provided a **Data table** where the first column is the dropdown value and all the other columns are the other page element value? – alexandre simard marquis Mar 13 '20 at 19:24
  • Yes. Something like: Given I navigated to home page. When I entered page with drop-down. Then I choose value from drop-down and see next data on page (last step - Then - with data table). – Ukrainis Mar 14 '20 at 11:12
  • Bad side of this approach is if test will fail on first drop-down value, then next values will not be validated. So, I would strongly recommend to use Scenario Outline in this situation. – Ukrainis Mar 14 '20 at 11:14
  • Is there a way to not reload the web driver? The way that I'm set up right now is that I have to provide wich driver I want to test in the `Given` since there's multiple browsers. However, in this case, I would like to, once i'm on the page, not go through the process of loading the driver again. I know you can do a background but from my understanding it's just to prevent the user from rewriting the same step but will still be process every scenario. – alexandre simard marquis Mar 16 '20 at 13:26
  • You can use static constructor in your Driver class. In this case, all tests will be in one browser window. Here is how to do it: https://www.tutlane.com/tutorial/csharp/csharp-static-constructor-with-examples – Ukrainis Mar 16 '20 at 15:07