dimanche 27 septembre 2020

Selenium chrome-driver [JAVA] waiting for element to be clickable for ubuntu

The code which works for eclipse IDE for same application seems to fail for ubuntu*. Please guide, where I'm doing wrong, i have tried to add wait conditions and thread sleep but nothing seems to work.

  WebElement nav= driver.findElement(By.xpath("//*[@id='navbarNav']/ul[1]/li[2]/a"));

System.out.println("RESULTS" +driver.getCurrentUrl());

WebDriverWait w= new WebDriverWait(driver, 200);
Thread.sleep(400);

w.until(ExpectedConditions.elementToBeClickable(nav));

Thread.sleep(400);
       nav.click();

error

 Exception in thread "main" org.openqa.selenium.TimeoutException: Expected condition failed: waiting for element to be clickable: [[ChromeDriver: chrome on LINUX (726e7ea18ab0340298b4be9c717b370b)] -> xpath: //*[@id='navbarNav']/ul[1]/li[2]/a] (tried for 200 second(s) with 500 milliseconds interval)
  

HTML code

<div class="collapse navbar-collapse style-scope app-shell" id="navbarNav">
                <ul class="app-nav navbar-nav mr-auto style-scope app-shell">
                    <li class="nav-item style-scope app-shell">
                        <a class="nav-link p-3 px-4 style-scope app-shell" href="/#/dashboard">Dashboard</a>
                    </li>
                    <li class="nav-item style-scope app-shell">
                        <a class="nav-link py-3 px-4 style-scope app-shell active" href="/#/trend-analysis/tag-search">TrendAnalysis</a>
                        <ul class="sub-nav d-flex flex-row flex-nowrap list-unstyled style-scope app-shell">
                            <li class="sub-nav-item style-scope app-shell">
                                <a class="sub-nav-link style-scope app-shell active" href="#/trend-analysis/tag-search">
                                    Trend Analysis
                                </a>
                            </li>
                            <li class="sub-nav-item style-scope app-shell">
                                <a class="sub-nav-link style-scope app-shell" href="#/trend-analysis/value-based-search">
                                    Value-Based Search
                                </a>
                            </li>
                  .....

Aucun commentaire:

Enregistrer un commentaire