Can't trigger jquery events in Chrome, Firefox, IE10

5 posts, 0 answers
  1. Ryan
    Ryan avatar
    9 posts
    Member since:
    Sep 2012

    Posted 18 Jun 2013 Link to this post

    Hi. I'm having trouble triggering jquery events to satisfy our required field validators.
    The following code works fine in IE9 but not in any other browser.
    I get a validation error even though there is text in the textbox (screenshot attached, if it helps)
               
    //Get the mandatory field: family name
    var familyName = Client.Browser.Find.ByAttributes<HtmlInputText>("id=FamilyName");
     
    //Enter some text
    Client.Browser.Actions.SetText(familyName, "Chrome and Firefox problems");
     
    //Trigger a bunch of jquery events that indicate the control has changed
    familyName.InvokeEvent(ArtOfTest.WebAii.Core.ScriptEventType.OnChange);
    familyName.AsjQueryControl().InvokejQueryEvent(jQueryControl.jQueryControlEvents.keydown);
    familyName.AsjQueryControl().InvokejQueryEvent(jQueryControl.jQueryControlEvents.keyup);
    familyName.AsjQueryControl().InvokejQueryEvent(jQueryControl.jQueryControlEvents.keypress);
    familyName.AsjQueryControl().InvokejQueryEvent(jQueryControl.jQueryControlEvents.change);
  2. Ryan
    Ryan avatar
    9 posts
    Member since:
    Sep 2012

    Posted 18 Jun 2013 Link to this post

    I've solved this issue now. Angular.js and some other frameworks listen to the input event, which is only supported properly by HTML5 browsers.
    If the browser is IE9 it will instead listen for the change event, otherwise it listens for input.

    The jQueryControlEvents enum doesn't have a value for the input event, but you can trigger it like so:

    myControl.InvokeEvent(new ArtOfTest.WebAii.Javascript.ScriptEvent("input"));
  3. Boyan Boev
    Admin
    Boyan Boev avatar
    1040 posts

    Posted 19 Jun 2013 Link to this post

    Hello Ryan,

    I am glad to hear you found a solution.

    Please read more about invoking javascript events here


    Please do not hesitate to contact us if you require any further assistance.
     

    Regards,
    Boyan Boev
    Telerik
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
  4. Ryan
    Ryan avatar
    9 posts
    Member since:
    Sep 2012

    Posted 23 Jun 2013 Link to this post

    Thanks Boyan,
    I've solved the problem for Chrome and Firefox, but it doesn't seem to work with IE10.

    The following line should work but it seems to be blocked or something:
    mycontrol.InvokeEvent(new ArtOfTest.WebAii.Javascript.ScriptEvent("input"));

    It works if I invoke the "input" event from the IE console, but not from the automation code.
    R
  5. Boyan Boev
    Admin
    Boyan Boev avatar
    1040 posts

    Posted 25 Jun 2013 Link to this post

    Hi Ryan,

    Does it work in IE 9?

    In order to assist you best please:

    1. Send us the execution log.

    2. Please record a Jing video demonstrating the entire process, so we can better understand what is happening. 

    3. Please provide us with a copy of your test and access to your application. If it is not possible to grant us access to your application, please take a Fiddler trace using FiddlerCap and send it to us in a zip file.

    Hope to hear from you soon. 

    Regards,
    Boyan Boev
    Telerik
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
Back to Top