0

I have this chunk of code:

void setFilterAndClickApply(String type,String... items){
        LOG.i("Clicking on filter menu inside comboboxcommon with type="+type + " and items= " + Arrays.toString(items));
        selectUlMenu(type, items);
        sleep(Duration.FIVE_HUNDRED_MILLISECONDS);
        clickApply();
         if(waitElmBecomeInvisible(Duration.TWO_SECONDS, applyBthBy)){
            TESTS_LOG.info("Menu was closed as expected");
        }else {
            TESTS_LOG.info("Filter clicked successfully");
        }
    }

where I am validating if the element is visible (using 'waitElmBecomeInvisible') if the element is not visible I am returning a message which indicates this. if the element is visible I want to throw exception I am not sure which exception I should throw and this is the point where you guys can suggest me kindly what do you think I should implement as an exception

tupac shakur
  • 658
  • 1
  • 12
  • 29
  • It's largely a matter of opinion. Review the JDK exceptions and if none applies in your view, [write your own exception class](https://stackoverflow.com/questions/1070590/how-can-i-write-custom-exceptions). – T.J. Crowder Nov 04 '19 at 14:32
  • Possible duplicate of [Java best practices when throwing exceptions: throwing core Java exceptions](https://stackoverflow.com/questions/10016550/java-best-practices-when-throwing-exceptions-throwing-core-java-exceptions) – px06 Nov 04 '19 at 14:32

1 Answers1

2

Since this situation can occur only during the runtime (this exception unchecked) - it seems reasonable to create your own ElementStillVisibleException extends RuntimeException and throw it.

maveriq
  • 456
  • 4
  • 14