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

Scripting

7 Answers 85 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
sitefinitysteve asked on 02 Nov 2012, 02:38 PM
Hey there,
  I need to test an SPA build with Kendo MVVM.  So pretty much I need to call some set methods on the viewmodel in the test (in javascript), then record\test the results in the viewmodel.  So like test step 1 says $viewModel.set("isActive", true); ...then I check visibility of some items.  Then set it to false, and check other things (etc etc)

How can I accomplish this?

Thanks,
Steve

7 Answers, 1 is accepted

Sort by
0
Cody
Telerik team
answered on 07 Nov 2012, 09:48 PM
Hello Steve,

To make JavaScript calls requires a coded step. For example:

Actions.InvokeScript("$viewModel.set("isActive", true);");

You should be able to test the visibility of an element using our standard Element menu that comes with our recorder.

If you need further assistance let us know, along with any additional details that will help us fully understand your exact test case.

Regards,
Cody
the Telerik team
Are you enjoying Test Studio? We’d appreciate your vote in the ATI automation awards.
Vote now
0
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
answered on 17 Dec 2012, 04:21 PM
Are there plans for a better method?

I have to do a bunch of pre-work on the page to setup the test and having to script it out as strings (frankly) sucks
0
Cody
Telerik team
answered on 18 Dec 2012, 08:52 PM
Hi Steve,

Are there plans for a better method?

Better method to do what? Run JavaScript? Test visibility?

For running JavaScript, as we see it, you pretty much have to be a programmer in order to know how to put together the correct JavaScript. With this in mind it's not a priority to us to provide a non-coded solution to do this. Adding a coded step, which takes just one line of code, should be an easy thing to do for someone familiar with programming in JavaScript.

For testing visibility, this is already available on our element menu. I don't see how we can make it any eaiser.

Greetings,
Cody
the Telerik team
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
0
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
answered on 18 Dec 2012, 08:56 PM
Better method to handle large javascript...

Sure, if I want to kick off one line, throw in a C# coded step, why not....what if I want to add in a 20+ line jQuery setup or teardown script...that'd be horrible to look at and maintain as one long string.
0
Cody
Telerik team
answered on 18 Dec 2012, 10:12 PM
Hello,

I would declare a static variable to hold the JavaScript and reference the variable in the method call:

private readonly static string initScript = "Codeline 1;" +
    "Codeline 2;" +
    "Codeline 3;";
 
[CodedStep(@"New Coded Step")]
public void ScratchTest_CodedStep()
{
    Actions.InvokeScript(initScript);
}

All the best,
Cody
the Telerik team
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
0
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
answered on 19 Dec 2012, 02:13 PM
Yeah...that's the part that "sucks" :)

Writing javascript as a string literal in C# is horrible; I've got a huge SPA to test.

Can we not have a feature request to perhaps load in an run an external script (or does that exist?)....OR an actual javascript window to run the code in there as a step (with syntax highlighting).
0
Cody
Telerik team
answered on 19 Dec 2012, 06:44 PM
Hi Steve,

I have created a new feature request for your idea here. In the meantime I would use Visual Studio to create a new .js file in my solution and then write code to load this .js file as a text file into a string variable and pass it into the InvokeScript function.

Greetings,
Cody
the Telerik team
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
Tags
General Discussions
Asked by
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
Answers by
Cody
Telerik team
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
Share this question
or