1

Hi all!

I use WebDriver to automate the test packets. Please help to solve one problem: does not work use the jQuery .. always get the error

org.openqa.selenium.WebDriverException: TypeError: $(...) is null

Testing code:

@Test
public void stage003() throws Exception {
    Reporter.log("<p class=\"stageDescr\">Check for uniqueness of identifiers</p>");
    JQSS("" +
        "var D_id=\"\";" +
        "$('[id]').each(function(){" +
            "var ids = $('[id=\"'+this.id+'\"]');" +
            "if(ids.length>1 && ids[0]==this) {" +
                "D_id = D_id + \" \" + this.id;" +
            "}" +
        "});" +
        "if (D_id==\"\") {" +
            "return D_id = \"All ID's is unique\";" +
        "} else {" +
            "return D_id;" +
        "}" +               
    "");
    Reporter.log("<p class=\"stageOutline\">                                   </p>");
}

And

public void JQSS(String SC) {
    String test = (String)((JavascriptExecutor) driver).executeScript(
        SC
    );
    Reporter.log("<p>Testing report... "+test+ "</p>");
}

PS: jquery on the page is already connected

4

1 回答 1

0

我发现了问题 - 在测试页面上也是 MooTols。我更改了“jQuery”上的 $ 符号并且它有效

于 2013-09-06T06:50:32.937 回答