0

I have searched and have not found a clear (enough for me) answer to after using Scenario Outlines to specify multiple URLs I'd like to navigate to using Selenium Webdriver and C#. How do I setup the C# to handle each URL? This is currently my steps:

Scenario Outline: Search
Given I Navigate to <URL>

Examples:
    | URL |
    | https://aaa.com/foo/bar/uniqueID1/en-us |
    | https://aaa.com/foo/bar/uniqueID2/en-us |
    | https://aaa.com/foo/bar/uniqueID3/en-us |

And this is my Step Def:

[Binding]
public class Search
{
    [Given(@"I Navigate to 
https://aaa\.com/foo/bar/(.*)/en-us")]
    public void GivenINavigateToHttpsAaa_FooBarEn_Us(int p0)
    {
        driver.url("https://aaa.com/foo/bar/(.*)/en-us");
    }

However, running this doesn't pull in each scenario from the outline as I expected. Where am I going wrong with my Step Definition?

1 Answer 1

1

Seems you didn't put the parameter p0 for the unique id to drive.url() method.

This code should work.

[Given(@"I Navigate to https://aaa\.com/foo/bar/(.*)/en-us")]
  public void GivenINavigateToHttpsAaa_FooBarEn_Us(int p0)
  {
    driver.url("https://aaa.com/foo/bar/" + p0 + "/en-us");
  }

Be careful on coding stuff when do the automation. Print it out in console or debugging helps me a lot to solve this kind of case.

Hope it helps,

1
  • Thanks! This worked for me - I'm new to C# so I overlook a lot of common things - especially when the regex is generated by Visual Studio and I didn't have to work my way through it myself. Thanks again!
    – Haney
    Commented Oct 10, 2017 at 12:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.