title: i want to select dependent values from drop down using IF condition in selenium java
body: <p>I want to select values from drop down that are interdependent to each other when I select dropdown1 - its gives some specific value and when i select drop down2  it gives some different values so using if condition to check the if(dropdown1 == x)
  { select y }
  else 
  { select A }</p>
  
  <pre><code>public class SelectingRadioButtons {
      public static void main(String[] args) {
          System.setProperty("webdriver.gecko.driver",
              "C:\\geckodriver-v0.17.0-win64\\geckodriver.exe");
          WebDriver driver = new FirefoxDriver();
  
          driver.get("http://careerendeavour.com/admission-form/registration-form.php");
          Select dropdown = new Select(driver.findElement(By.xpath(".//*[@id='center']")));
          dropdown.selectByIndex(2);
  
          Select subcourse = new Select(driver.findElement(By.xpath(".//*[@id='course']")));
          subcourse.selectByValue("Regular Course");
  
          if (subcourse.equals("Regular Course")) {
              Select dropdown1 =  new Select(driver.findElement(
                  By.xpath(".//*[@id='coursetp']")));
              dropdown1.selectByValue("GATE");
          }
      }
  }
  </code></pre>