title: Skipping a check for a radio button when not displayed in Selenium
body: <p>I am trying to get Selenium Webdriver to check to see if a radio button is displayed, and if not to skip the step and move on. I have multiple versions of a web app and a newer version has implemented a new radio button that is not available in older versions but I want to test multiple versions of the app using the same selenium code. I am using java code to write my scripts and this is what I have so far...</p>
  
  <p>I have a Utilities class that includes several other functions for use throughout my other classes called AdminUtils.java and I have coded the following to find the radio button element and click it when found:</p>
  
  <pre><code>public static void clickPrivate() {
  
      WebElement rdBtn_Private = AdminUtils.driver.findElement(By.id("type-radio-private"));
      rdBtn_Private.click();
  }
  </code></pre>
  
  <p>Then I have my Base Test class where I call the function (along with other steps before and after this step):</p>
  
  <pre><code>ArchiveUtils.clickPrivate();
  </code></pre>
  
  <p>This works as is with the newer version of the web app but throws errors on older versions since the button doesn't exist in those versions. I have been reading around this and other sites that have suggestions for similar functions but I am relatively new to Java and Selenium so translating that to what I am trying to do has been ineffective up to this point. I have tried try catch and .IsDisplayed calls but I wasn't sure which class required them and it was causing nullPointerExceptions farther down in my Base Test class when trying to perform the test. Any assistance would be greatly appreciated. Thanks in advance!</p>