power_settings_new
Here goes my class:

public void clickAroLoadKorunLink() throws InterruptedException
    {
        
        do{
        WebDriverWait waitLoadMore = new WebDriverWait(driver, 25);
        waitLoadMore.until(ExpectedConditions.elementToBeClickable(AroLoadKorunLink));
        JavascriptExecutor exe = (JavascriptExecutor)driver;
        WebElement eleAroLoadKorunLink = driver.findElement(AroLoadKorunLink);
        exe.executeScript("arguments[0].scrollIntoView(true);", eleAroLoadKorunLink );
        exe.executeScript("arguments[0].click();", eleAroLoadKorunLink );
       
        Thread.sleep(5000);
        if(!(driver.findElement(AroLoadKorunLink).isDisplayed()))
        {
            break;
        }
            
            
        }while(driver.findElement(AroLoadKorunLink).isDisplayed());

    }
by (391 points)
My code is working fine but the exit condition is not working.
by (171 points)
What is the error that you're getting?
by (391 points)
I am not getting any error, only the test case fails as the script is still searching for the load more button

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please log in or register.

1 Answer

by (171 points)
0 votes

There are possibilitis that AroLoadKorunLink is displayed. But not clickable.

 

Do you want to try using driver.findElement(AroLoadKorunLink).isEnabled() or isClickable?

 

To see if element is clickable you may have to use below custom function for isClickable.

 
public static boolean isClickable(WebElement webe)
 
{
try
{
   WebDriverWait wait = new WebDriverWait(yourWebDriver, 5);
   wait.until(ExpectedConditions.elementToBeClickable(webe));
   return true;
}
catch (Exception e)
{
  return false;
}
}

 

Hope tha thelps.

by (391 points)
Is it mandatory to declare the isClickable() method as static?
by (171 points)
No. You can use it as non static.
add
...