This is a migrated thread and some comments may be shown as answers.

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

4 Answers 146 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Ryan
Top achievements
Rank 2
Ryan asked on 19 Jun 2013, 01:37 AM
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);

4 Answers, 1 is accepted

Sort by
0
Ryan
Top achievements
Rank 2
answered on 19 Jun 2013, 03:48 AM
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"));
0
Boyan Boev
Telerik team
answered on 19 Jun 2013, 11:07 AM
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
0
Ryan
Top achievements
Rank 2
answered on 24 Jun 2013, 12:28 AM
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
0
Boyan Boev
Telerik team
answered on 25 Jun 2013, 10:51 AM
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
Tags
General Discussions
Asked by
Ryan
Top achievements
Rank 2
Answers by
Ryan
Top achievements
Rank 2
Boyan Boev
Telerik team
Share this question
or