1

I am looking for a way to predefine some parameters (URL's) and then run a selenium test for each of them in C#.

  • Where should I specify those URL's?
  • How to implement reading of those parameters in my code?
    [Test]
    public void Test(string URLParameter)
    {
        driver.Navigate().GoToUrl(URLParameter);
    }  
  • And how should I run those tests?
1
  • You should ask more specific and focused questions. Here you actually asked 3 questions while it also can be defined as opinion-minded question... Commented Dec 27, 2021 at 11:03

3 Answers 3

1

If you are looking for a way to run the same test with a different set of test data i.e: a different URL in your case and If you are using

Either Nunit or xUnit

Please note all built-in attributes allow for data to be provided programmatically, but NUnit does not have any attributes that fetch the data from a file or other external source.

You can make use of

[TestCaseSource]

attribute

Please read more about it from Nunit Documentation

References:

Sign up to request clarification or add additional context in comments.

Comments

1

There are several ways to predefine and keep such test data.

  1. You can keep it in some external file. It can be JSON, XML or plain text formatted file.
  2. It may be kept in some resource C# class file inside the project.
  3. It can be kept in some kind of DB etc.
    Actual implementation of how to read this data will vary according to the way you decided to keep the test data, according to your project structure etc. There are several best practices how to do that, not only one way to do that.
    There are also several ways to run such tests. You can learn about these best practices on many online tutorials and other resources.

Comments

1

For that purpose you should use multiple different ways to keep test data.

1- Kept in the resources folder of the project for example in
   properties file. 
2- Kept data in DB and read from there while
   needed.  
3- Kept in some external sources and read/retrieve if from
   there.

Note: Should use that method which will be convenient for you later on.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.