I am creating a test suite using appium/selenium java and it was suggested that I use a boolean to select the gender on a registration form.

The page objects on the gender page are male, female, and a clear button. The male/female objects have a value that can be checked to see if they are selected.

The default value is neither selected. Is this possible or does having two specific clickMale and clickFemale functions make more sense?

  • 1
    Great question in our current political climate, but not a QA subject. I recommend moving this question to ux.stackexchange.com.
    – user246
    Apr 26, 2016 at 16:44
  • 1
    Why move it? It's asking about whether he should have 2 functions within a POM.
    – Paul Muir
    Apr 26, 2016 at 16:47
  • 1
    I'm voting to close this question as off-topic because will get better value answers on ux.stackexchange.com. Apr 26, 2016 at 16:52
  • 2
    It's really just a programming question for automated tests. We're automating a successful account creation. If the gender part is political or whatever, pretend it's something else, it's not intended for that.
    – squeemish
    Apr 26, 2016 at 16:57
  • Sorry, I misunderstood the question. It's fine where it is.
    – user246
    Apr 26, 2016 at 17:00

4 Answers 4


I'd say that you should use an enum. Gender is enumerable, so it makes sense to model it as that (indeed, anything which is a radio button strikes me as enumerable). Something like the below would encapsulate it neatly. I've used a switch because they work well with enums, but I guess you could use if/else.

private static final By OPTIONS_GENDER_MALE = By.id("...");
private static final By OPTIONS_GENDER_FEMALE = By.id("...");

public void setFormGender(final GenderEnum gender){


    switch (gender) {
        case MALE:
        case FEMALE:
            throw new IllegalArgumentException("Something went wrong!");

private void clearFormGender(){
    // ...

A note on your terminology - page objects are the objects that represent an entire page (or significant large chunks of the page), not the controls on the page.


Why not Both (Or well, all three)?

So, you create a clickMale, clickFemale and clear function. You can have a function that takes in a boolean that will click male or female based on the value of that boolean using the functions that were created.


If I'm in this case, I will create a fucntion to select/unselect a checkbox then we can reuse it for all checkboxes.

C# sample

private void Check(IWebElement element, bool isSelect)
    // get currentStatus of checkbox
    // if currentStatus not equal to isSelect then call click function

For a clear function, you may include it to Check() function above or create a separate function, it depends on how many time you use it.

Hope it helps.


You could have methods like:




or any names that are easy to understand.There is no big difference. When you have any doubts is better to review some documentation/tutorials related to page objects.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.