verifying an element

Answered

Given that there is no isElementPresent type of function is there a standard way to check if a web element is displayed to set a Boolean variable?

Add Comment
  • 2 Answer(s)
    Best answer

    One of the approach would  be to have a Static utility function. Something like this

    boolean isElementInteractoable(WebDriver driver, By locator)
    {
    WebElement element;
    try{
    element = driver.FindElement(locator);
    }
    catch(Exception exp)
    {
    return false;
    }

    if(element.isVisible() && element.isEnabled())
    {
    return true;
    }
    return false;
    }

    I hope you get the point here.

    Virender

    Professor Answered on October 13, 2015.
    Add Comment

     

    public static boolean isElementPresent(WebDriver driver, By by) {

    try {

    driver.findElement(by);

    return true;

    }

    catch(NoSuchElementException e){

    return false; }

    }
     

    But I get a msg :

    Method public static boolean AutomationFramework.SalesForce.isElementPresent(org.openqa.selenium.WebDriver,org.openqa.selenium.By) has a @Test annotation but also a return value: ignoring it. Use <suite allow-return-values=”true”> to fix this
    When I call this method. I’m not sure what  I do for this fix “Use <suite allow-return-values=”true”> to fix this” . Where is that set?

    Train Answered on October 13, 2015.
    Add Comment
  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.