com.sun.jdi.InvocationException occurred invoking method

前端 未结 16 1260
迷失自我
迷失自我 2020-12-13 01:38

I just want to create an object of class, but got this error when debugging. Can anybody tell me what the problem is? The location of this code is in some Spring(2.5) Servic

16条回答
  •  星月不相逢
    2020-12-13 02:08

    There could be two reasons an element doesn't exist:

    1. Bad xpath (//*[@id'forgotQuote])
    2. Correct xpath but no element (//*[contains(text(),'This text is not in the page')])

    Would you get com.sun.jdi.InvocationException in either case when you are running Debug and you hover your mouse over a reference to the WeBElement (this with Selenium and Java)???

    We use the following, but can't distinguish if it returns false due to bad xpath or non-existent element (valid xpath syntax):

    public static boolean isElementDisplayed(WebElement element) {
        boolean isDisplayed = false;
    
        try {
            isDisplayed = element.isDisplayed();
        } catch (NoSuchElementException e) {
            ;// No Worries
        }
        return isDisplayed;
    }
    

提交回复
热议问题