Im looking for a clean way to test all features on the webpage with 2 different users. One user is the admin, the second one a normal user.
Here is the overview of my selenium tests:
As you can see, we have 3 different features on the webpage:
Each of these features has its own Test class with its own webDriver so im able to run the tests in parallel.
Each of these test files, is calling the Login Class inside the SetUp.
What the Login Class is doing is:
Everything works perfectly when i test it for one user. All the test run in parallel.
Now i want to test all the same features with the admin user.
The only way which comes into my mind is, to just create another Login class, which gets the other users credentials and copy also the 3 test classes, so all the 6 tests run in parallel.
But in my opinion its not clean, because i would copy 4 files which would have nearly 1:1 the same code.
I'd make the user id and password arguments to the fixtures.
[TestFixture("normalUser", "normalUserPassword")]
[TestFixture("adminUser", "adminUserPassword")]
public class SomeFixture
{
private string User { get; }
private string Password { get; }
public SomeFixture(string user, string password)
{
User = user;
Password = password;
}
[OneTimeSetUp]
public void SetUpTheFixture()
{
// Create the driver
}
...
}
If you prefer to lookup the password, then just make the user id the only argument and look up the password when you need it.
[TestFixture("normalUser")]
[TestFixture("adminUser")]
public class SomeFixture
{
private string User { get; }
public SomeFixture(string user)
{
User = user;
}
[OneTimeSetUp]
public void SetUpTheFixture()
{
// Look up password
// Create driver
}
...
}