Variable for different countries

I am trying to figure out something like below mentioned and need to automate:-

Lets assume I have 2 countries and 2 browser and 4 devices to test and only have one “testclass” for login page.
User id and password are same for both the locations. Only changes are in desired capabilities (deviceid, udid).I do not want to hardcode the location and browser into the testclass so I created another one which holds the variable.
So i have created Constants.java page and mentioned like below details
public static final String Location = “XX”;
public static final String Location = “YY”;

In the testclass I would call it e.g

CommonExcelUtil.updateTheResponseIntoCSVFile(dtf.format(now), “login”, Constants.Location);

However everytime i have to change the location manually in Constants.java page .

My Question is how can I select before I start the test the other browser or location without always changing the code at the testclass(ex-Constants.java page ).

why not create enum?

public enum Country {
    UK(120, 120),
    US(130, 130);

    private final int x;
    private final int y;

    Country(int x, int y) {
        this.x = x;
        this.y = y;
    }

    public int getX() {
        return x;
    }

    public int getY() {
        return y;
    }
}

// use in test
int x = Country.UK.getX();
int y = Country.UK.getY();
1 Like