In FF4 Actions.InvokeScript is broken for arrays

12 posts, 0 answers
  1. Alexey Ivanov
    Alexey Ivanov avatar
    45 posts
    Member since:
    Sep 2009

    Posted 31 May 2011 Link to this post

    Hello

    to reproduce use this code:
    var actions = Manager.Current.ActiveBrowser.Actions;
    actions.InvokeScript("window.my_list=[1,2,3]");
    var list = actions.InvokeScript<IList>("window.my_list"); // here

    In IE and FF3: object[3] { 1, 2, 3}
    In FF4: empty array object[0]

    Fix please

  2. Stoich
    Admin
    Stoich avatar
    1 posts

    Posted 07 Jun 2011 Link to this post

    Hi Alexey Ivanov,

           could you please also provide the javascript against which we can reproduce this issue. Please create a small sample page with the javascript code and we'll analyze the problem.

    Greetings,
    Stoich
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. Alexey Ivanov
    Alexey Ivanov avatar
    45 posts
    Member since:
    Sep 2009

    Posted 08 Jun 2011 Link to this post

    Stoich, you can use code that I shown in my prev message with any html page.
    As you can see, it first creates an array and then reads it back.
  4. Stoich
    Admin
    Stoich avatar
    1 posts

    Posted 15 Jun 2011 Link to this post

    Hello Alexey,
        I've logged this as a bug and you can track its progress here:
    http://www.telerik.com/support/pits.aspx#/public/test-studio/6501
    My guess is that this issue is related to the way FF4 interprets Javascript code and it's not related to our product at all. However, our developers will have to determine whether this is really the case.

    Kind regards,
    Stoich
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  5. Alexey Ivanov
    Alexey Ivanov avatar
    45 posts
    Member since:
    Sep 2009

    Posted 15 Jun 2011 Link to this post

    Thanks Stoich.
    I think your developers will be able to find a way around this :)
  6. Stoich
    Admin
    Stoich avatar
    1 posts

    Posted 06 Jul 2011 Link to this post

    Hi Alexey,
          would you please describe your use case. We're currently discussing the issue with our developers. We would like to learn a bit more about the functionality you're trying to achieve. We might be able to assist you in finding an alternative way to handle your automation task.

    Regards,
    Stoich
    the Telerik team
    Register today for a live 'What's New in Test Studio R1 2011 SP2' event on Tuesday, July 19 at 2pm EST!

    Have you looked at the new Online User Guide for Telerik Test Studio?
  7. Alexey Ivanov
    Alexey Ivanov avatar
    45 posts
    Member since:
    Sep 2009

    Posted 07 Jul 2011 Link to this post

    My use case:
    On the page I have a javascript function which returns an array. I check items of this array.
    I understand that I might join items with separators and check the string.
    But why not to make the script API uniform on your side? Moreover it worked earlier.
  8. Stoich
    Admin
    Stoich avatar
    1 posts

    Posted 13 Jul 2011 Link to this post

    Hello Alexey,
      the issue is probably related to a change in FF4+’s Javascript handling.

    Firefox seems to be treating the list as a map, and returning a JSON-encoded version of it. You can probably work around it by not casting the result to IList and handling the JSON value yourself.

    Greetings,
    Stoich
    the Telerik team
    Register today for a live 'What's New in Test Studio R1 2011 SP2' event on Tuesday, July 19 at 2pm EST!

    Have you looked at the new Online User Guide for Telerik Test Studio?
  9. Alexey Ivanov
    Alexey Ivanov avatar
    45 posts
    Member since:
    Sep 2009

    Posted 13 Jul 2011 Link to this post

    Regarding "can probably work around":
    would you please show me a simple example?

    InvokeScript returns an array. I cannot figure out how to treat it as JSON and parse manually.
  10. Cody
    Admin
    Cody avatar
    3354 posts

    Posted 18 Jul 2011 Link to this post

    Hi Alexey Ivanov,

    It took a little research but here's how to get at the array and it's contents/values:

    var actions = Manager.Current.ActiveBrowser.Actions;
    JsonObject result = actions.InvokeScript <JsonObject>("window.my_list=[1,2,3]");
    JsonArray arr = (JsonArray)result["root"];
    for (int i = 0; i < 3; i++)
    {
        double val = arr[i];
        Log.WriteLine(val.ToString());
    }

    Regards,
    Cody
    the Telerik team
    Register today for a live 'What's New in Test Studio R1 2011 SP2' event on Tuesday, July 19 at 2pm EST!

    Have you looked at the new Online User Guide for Telerik Test Studio?
  11. Alexey Ivanov
    Alexey Ivanov avatar
    45 posts
    Member since:
    Sep 2009

    Posted 20 Jul 2011 Link to this post

    Thank you Cody for this information.
    Is there anything preventing you from including this to the WebAii library code?
    It would make the InvokeScript API consistent among browsers.

  12. Cody
    Admin
    Cody avatar
    3354 posts

    Posted 20 Jul 2011 Link to this post

    Hello Alexey Ivanov,

    We will add it to this page of our online documentation.

    Kind regards,
    Cody
    the Telerik team
    Register today for a live 'What's New in Test Studio R1 2011 SP2' event on Tuesday, July 19 at 2pm EST!

    Have you looked at the new Online User Guide for Telerik Test Studio?
Back to Top