Thanks for your response. in the screenAisShown() function, am returning the boolean value.
here is the code that added in another class.
public Boolean privacyNoticeScreenIsShown() {
return privacyNoticeTitle.isDisplayed();
}
Am calling the above method in my test class with try catch. Please find here. I used the same try catch in screenB as well.
try {
if (privacy.privacyNoticeScreenIsShown())
{
privacy.clickToAgreePrivacy();
onBoard.clickSkip();
}
}
catch (NoSuchElementException e)
{
e.printStackTrace();
}