package com.autonomy.abc.selenium.menu;

import com.hp.autonomy.frontend.selenium.util.AppElement;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;

import java.util.List;

public class SideNavBar extends AppElement {

    public SideNavBar(WebDriver driver){
        super(driver.findElement(By.cssSelector(".navbar-static-side")), driver);
    }

    public Tab getTab(NavBarTabId id){
        return null;
    }

    public Tab getSelectedTab(){
        final List<WebElement> activeTabs = $el().findElements(By.cssSelector("li.active"));

        if (activeTabs.size() != 1) {
            throw new IllegalStateException("Number of active tabs != 1");
        }

        return new SideNavBarTab(activeTabs.get(0), getDriver());
    }

    public String getPageName() {
        return getSelectedTab().getName();
    }

    public String getPageId() {
        return getSelectedTab().getId();
    }

    public void switchPage(final NavBarTabId tab) {
        new WebDriverWait(getDriver(),30).until(
                ExpectedConditions.visibilityOfElementLocated(By.xpath("//ul//li//*[text()=' " + tab.toString() + "']/.."))).click();
    }
}

@@ -1127,16 +1127,43 @@
         
+tryClickThenTryParentClick(
 new WebD
@@ -1316,22 +1316,12 @@
  %22'%5D
-/..
 %22)))
-.click(
 );%0A 

Fix side nav bar - click was failing due to span inside link on some pages