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
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.
Cody
the Telerik team
Vote now
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
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.
Cody
the Telerik team
Test Studio Trainings
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.
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);
}
Cody
the Telerik team
Test Studio Trainings
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).
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
Test Studio Trainings