Quantcast
Channel: Active questions tagged selenium - Stack Overflow
Viewing all articles
Browse latest Browse all 97793

How to use enum with spaces in java

$
0
0

I have an issue that I want to resolve. I am using selenium and on of the tests I need to select values from dropdown. the values are:

Unassigned - 1
Self Service -  2

I want to create enum with name opsOwner that will contains these values. the problem with the values are the spaces. How can I create enum with this values, and in other class assigned them?

this is my code:

public enum OpsOwner
{
    selfService ("Self Service - 2");
    unassigned("Unassigned - 1");

    private String opsOwnerValue;

    OpsOwner(String value)
    {
        this.opsOwnerValue = value;
    }

    OpsOwner(){}

    public String opsOwnerValueValue(){ return opsOwnerValue; }

    @Override
    public String toString() {
        return "opsOwnerValue{" +
                "opsOwnerValue='" + opsOwnerValue + '\'' +
                '}';
    }
}
}

and this is how I want to use the code:

PubOpsApproveExPublisherObject.OpsOwner.selfService;

the code is only worked if I removed the

unassigned("Unassigned - 1");

when I add the second value unassigned("Unassigned - 1"); it says missing method body. I just want enum with values of spaces, and than evaluate it. can someone please advise how can I use it? for now I am not using enum but String since I need the flexibility.


Viewing all articles
Browse latest Browse all 97793

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>