title: Selenium - How do click on this span class
body: <p>I am not able to use xpath for this span class. I need to click on the link.</p>
  
  <pre><code>&lt;span class="nav-selection"&gt;Ad Style&lt;/span&gt;
  </code></pre>
  
  <p>I have been trying using this method:</p>
  
  <pre><code>WebElement heightClass = driver.findElement(By.xpath("/html/body/div[3]/div/div[1]/div[2]/ul/li[3]/a/span"));
  </code></pre>
  
  <p>The html code for the portion that I need to test.</p>
  
  <pre><code>&lt;ul class="nav nav-side-menu" style="top: 0px;"&gt;
          &lt;li class="shadow-layer"&gt;&lt;/li&gt;
          &lt;li&gt;
              &lt;a href="portal.do?portalCategory=analyst"&gt;
                  &lt;i class="icon-photon dashboard"&gt;&lt;/i&gt;
                  &lt;span class="nav-selection"&gt;Dashboard&lt;/span&gt;
                                  &lt;/a&gt;
          &lt;/li&gt;
  
          &lt;li&gt;
              &lt;a href="javascript:;" class="sub-nav-container"&gt;
                  &lt;i class="icon-photon adcorner"&gt;&lt;/i&gt;
                  &lt;span class="nav-selection"&gt;Ad Corner&lt;/span&gt;
                  &lt;i class="icon-menu arrow"&gt;&lt;/i&gt;                &lt;/a&gt;
              &lt;div class="sub-nav adCorner"&gt;
                  &lt;ul class="nav"&gt;
  
                      &lt;li class="menu-add"&gt;
                          &lt;a href="showstatusreports.do"&gt;Status Reports&lt;/a&gt;
                      &lt;/li&gt;
  
  
                      &lt;li class="menu-add"&gt;
                          &lt;a href="listinsertion.do"&gt;Insertion Order&lt;/a&gt;                              
                      &lt;/li&gt;
                      &lt;li class="menu-add"&gt;
                          &lt;a href="campaignWrapper.do?processpath=defaultPage&amp;amp;camStatus=L"&gt;Campaigns&lt;/a&gt;
  
                          &lt;i class="icon-add" title="create new campaign" rel="createCampaign"&gt;&lt;/i&gt;   
  
                      &lt;/li&gt;
  
  
  
  
  
  
                      &lt;li class="menu-add"&gt;
                          &lt;a href="campaigncreatepage.do"&gt;Tags&lt;/a&gt;                            
                      &lt;/li&gt;
  
  
  
  
  
  
  
                          &lt;li class="menu-add"&gt;
                          &lt;a href="viewcreative.do"&gt;View Creative&lt;/a&gt;
                          &lt;/li&gt;
  
  
                  &lt;/ul&gt;
              &lt;/div&gt;
          &lt;/li&gt;
  </code></pre>
  
  <p>Thanks for the help! Please let me know.</p>
  
  <p>This is what i am writing in eclipse. please go through it and let me know. Thanks.</p>
  
  <pre><code>//class to run the test
  public class AddNewCampaign extends TestLogin{
  
      WebDriver driver;
  
  public static void main(String[] args) {
  
      AddNewCampaign addCamp = new AddNewCampaign();
      addCamp.LaunchParisUI();
      addCamp.loginCredentials();
      addCamp.addCampaign();
  
  
  }
  
  //method to add campagin
  
      public void addCampaign() { 
  
              WebElement heightclass = driver.findElement(By.xpath("//*[.='Ad Corner']/.."));
  
              WebElement linkCampaigns = driver.findElement(By.xpath("/html/body/div[3]/div/div[1]/div[2]/ul/li[3]/div/ul/li[3]/a"));
  
              WebDriverWait wait = new WebDriverWait(driver, 10);
  
              Actions builder = new Actions(driver);
              builder.moveToElement(heightclass).perform();
              wait.until(ExpectedConditions.visibilityOf(linkCampaigns));
              builder.moveToElement(linkCampaigns).click().perform();
  
          }
  
  //class the launch the url
  
      public class LaunchParis{
  
          WebDriver driver;
  
          //Launch PairsUI    
          public void LaunchParisUI() {
              driver = new FirefoxDriver();
              //driver = new ChromeDriver();
              driver.get("https://xfpqa1uiadm1");
              driver.manage().window().maximize();
              }
  </code></pre>