title: How to use If else statements in selenium webdriver using java?
body: <ol>
  <li>Question:</li>
  </ol>
  
  <p>I have 8 buttons like (discover,news,people,videos,sport,tech,offbeat,ents). so i want to click on any one or more buttons. actually i don't know what to use here, i was thinking if else will work. need some help. Here there is a problem which i feel is, all buttons have same class name so how to use if else for this type of issue. </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div class="btn-group"&gt;
  &lt;button class="btn btn-default button ng-scope ng-binding" type="button" ng-repeat="category in categories" ng-click="addTag(category.text)"&gt;discover&lt;/button&gt;
  &lt;button class="btn btn-default button ng-scope ng-binding" type="button" ng-repeat="category in categories" ng-click="addTag(category.text)"&gt;news&lt;/button&gt;
  &lt;button class="btn btn-default button ng-scope ng-binding" type="button" ng-repeat="category in categories" ng-click="addTag(category.text)"&gt;people&lt;/button&gt;
  &lt;button class="btn btn-default button ng-scope ng-binding" type="button" ng-repeat="category in categories" ng-click="addTag(category.text)"&gt;videos&lt;/button&gt;
  &lt;button class="btn btn-default button ng-scope ng-binding" type="button" ng-repeat="category in categories" ng-click="addTag(category.text)"&gt;sport&lt;/button&gt;
  &lt;button class="btn btn-default button ng-scope ng-binding" type="button" ng-repeat="category in categories" ng-click="addTag(category.text)"&gt;tech&lt;/button&gt;
  &lt;button class="btn btn-default button ng-scope ng-binding" type="button" ng-repeat="category in categories" ng-click="addTag(category.text)"&gt;offbeat&lt;/button&gt;
  &lt;button class="btn btn-default button ng-scope ng-binding" type="button" ng-repeat="category in categories" ng-click="addTag(category.text)"&gt;ents&lt;/button&gt;
  &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <pre><code>if(!driver.findElement(By.className("default button ")).isSelected())
      {
        driver.findElement(By.className("default button")).sendKeys("discover");
      }
      else 
      {
          driver.findElement(By.className("default button")).sendKeys("news");
      }
  </code></pre>
  
  <ol start="2">
  <li>Question:</li>
  </ol>
  
  <p>I have 8 tags as drop downs like (discover,news,people,videos,sport,tech,offbeat,ents). so i want to select only any one tag. how do i use if else statements for this...</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>   &lt;div class="input-group"&gt;
  &lt;span class="input-group-addon title"&gt;Category&lt;/span&gt;
  &lt;input class="form-control ng-valid ng-dirty ng-valid-editable" typeahead="category.text for category in categories | filter:$viewValue | limitTo:8" ng-model="article.category" placeholder="Enter Category"&gt;
  &lt;ul class="dropdown-menu ng-isolate-scope" ng-style="{display: isOpen()&amp;&amp;'block' || 'none', top: position.top+'px', left: position.left+'px'}" typeahead-popup="" matches="matches" active="activeIdx" select="select(activeIdx)" query="query" position="position" style="display: none; top: 34px; left: 165.05px;"&gt; &lt;/ul&gt;
  &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>thanks in advance !!</p>