title: Selenium(Java), java.lang.AssertionError
body: <p>I wrote a method to load the page navigation links. The method works, but when I added code to check the correct URL and tab title my test is not performed. Sometimes it happens that for loop fast clicks on the pages the side that does not get loaded, I do not know whether it is a problem but I can not check whether a page loaded with the correct url or tab title, or the problem is the code that I wrote for check the correct url or tab title.</p>
  
  <p>This is my method:</p>
  
  <pre><code>public void showNavigationLinks(){
          Actions action = new Actions(driver);
  
          String[] submenus = {"Accessories", "iMacs", "iPads" , "iPhones" , "iPods" , "MacBook"};
  
          for(int i=0;i&lt;submenus.length;i++)
          {
  
              WebElement we = driver.findElement(By.xpath("//a[contains(.,'Product Category')]"));
              wait(2000);
              action.moveToElement(we).moveToElement(driver.findElement(By.xpath("//a[contains(.,'"+submenus[i]+"')]"))).click().build().perform();
              wait(3000);
  
              waitForElementToBeDisplayed(driver.findElement(By.xpath("//a[contains(.,'"+submenus[i]+"')]")) , 500);
              Assert.assertTrue(driver.getCurrentUrl().toLowerCase().contains(submenus[i]));
  
              Assert.assertTrue(driver.getTitle().contains(submenus[i]));
          }
  
          link_all_product.click();
      }
  </code></pre>
  
  <p>This is my error:</p>
  
  <pre><code>java.lang.AssertionError
      at org.junit.Assert.fail(Assert.java:86)
      at org.junit.Assert.assertTrue(Assert.java:41)
      at org.junit.Assert.assertTrue(Assert.java:52)
      at PageObject.ProductPage.showNavigationLinks(ProductPage.java:627)
  </code></pre>