Testing multiple browser urls with the same test


#1

Hello:
So we have multiple staging servers that I am going to need to hit with testing. I would run the same test file in multiple places, basically. So obviously, we have to instantiate the first object with the url etc… What would be the best practice for the same test file to be run with different URLs? Would I have to create different folders within the same solution or a different solution all together?

Thank you!


#2

Hello @micheleaz!
I am not sure about is there a best practice defined for this, but here is how you could accomplish this using a single test file:
You can use the @DataProvider to pass in different URLs to your test’s .get() method.
For example, create the url’s data provider

@DataProvider(name = "url's")
    public Object[][] searchURL() {
        Object[][] data = new Object[3][1];
        data[0][0] = "https://URL1.com";
        data[1][0] = "https://URL2.com";
        data[2][0] = "https://URL3.com";
        return data;
    }

And in your Test file, you pass in the previously created data provider, and the test will run for each entry in the dataProvider object, so 3 times for each URL defined.

 @Test(dataProvider="url's")
    public void SampleTestCase(String url) {
             
        driver.get("url");
        ...

Of course, you can modify this example as you wish, and you can find out more about DataProviders here


#3

It would be also interesting to know how and where you start these tests from.
So are you launching the tests from each staging server individually directly on them? Or are you running everything from one local machine? Or is it part of a CI job where after a build or the like the tests get executed?

Also would you want all of the cycles be part of one test or should the result be three different tests. The reason could be for properly separated reports per staging env vs an all-in-one approach.


#4

Hi! We haven’t gotten that far yet. We will probably use CI as we already have Ranorex running through Jenkins.

We would probably want individual reports for each environment as the back end processes will be different per environment.


#5

So you think that if we wanted reports per environment, a separate solution would be the way to go?
Thanks for your help!


#6

Hey there @micheleaz and sorry for the late response.

No, I think you’re fine with having one project, thats all good. I was specifically asking for what the results should look like because of an upcoming feature we plan.

As you may have noticed, when you create a project, you end up with a default.endpoints.json file. Modifying or adding new endpoints essentially persists those to said file. Now given the case that e.g you want to run your tests on Mac and Win, you can create another json file which targets mac and e.g includes Safari, but the Win one contains Edge (legacy) and IE. So this way you can split up execution environments by individual json files.
Now our upcoming plans are to enable users to store arbitrary data in said file. These data will then be converted to environment variables and can be accessed by your testcode.
Now long story short, this might be exactly what would help solve your case. Because you’d now have for each Server an individual json file, containing the url as additional data, which then can be used within the test to forward the environment-specific url.

I hope that above doesn’t sound too complicated, the actual usage is going to be pretty straight forward and of course also introduced with a HowTo article.


#7

Meanwhile we’ve released the environment per endpoint feature as explained here.