#82 Testing calls to javascript functions

Release_2.1
open
Core API (44)
3
2008-11-18
2007-01-22
No

Add a function to do a javascript function call. Retrieving the result of the call would be nice to have (ie for asserting its content or passing it to another call)

Discussion

  • Bernard de Terwangne

    Logged In: YES
    user_id=1623716
    Originator: YES

    Julien,

    Just to bring some contribution I made a first trial of implementation of this function. Not sure all is done the right way. Anyway, here it is (from HtmlUnitDialog) :

    public Object executeJavascriptIfPossible(String sourceCode, String elementId)
    {
    Page page = win.getEnclosedPage();
    if (page instanceof HtmlPage)
    {
    HtmlPage htmlPage = (HtmlPage) page;
    HtmlElement htmlElement = elementId == null ? null : getElement(elementId);
    ScriptResult scriptResult = htmlPage.executeJavaScriptIfPossible(sourceCode, "jsWebUnit", true, htmlElement);
    Page newPage = scriptResult.getNewPage();
    if (null != newPage)
    {
    win.setEnclosedPage(newPage);
    form = null;
    }
    return scriptResult.getJavaScriptResult();
    }
    return null;
    }

    Amicalement,

    Bernard

     
  • Jevon Wright

    Jevon Wright - 2008-11-18
    • labels: 455548 --> Core API
    • milestone: 427570 --> Release_2.1
    • priority: 5 --> 3
    • assigned_to: nobody --> jevonwright
     
  • Jevon Wright

    Jevon Wright - 2008-11-18

    I will look at adding this to JWebUnit 2.1. While not strictly part of web application testing (we are testing black-box), it would be useful to have the ability to white-box test the Javascript.

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks