Is there a way to camper values from the Data table? For example:
If([User Role] = “Admin”) then run anything under the true branch. In my case I want to do different validation for each role and do not want to go down the coding path as of yet.
Any ideas?
Thanks,
John
10 Answers, 1 is accepted
you can record separate tests for each specific type of user. Then you can add multiple (non-coded) IF/ELSE statements each of which checks whether you're logged in with a specific type of user.
Now you can make use of the TestAsStep feature:
http://www.telerik.com/automated-testing-tools/support/documentation/user-guide/add-custom-step/test-as-step.aspx
Inside each IF clause you can add the corresponding (in terms of user type) test as a TestAsStep.
Let me know if you have any additional questions on this.
Kind regards,
Stoich
the Telerik team
we are on the same page but the question is that I will have mixed rolls. Each row will have the ID of admin, manager, or staff. Can I place a condition to compare the current Row data in the none coded IF? I was not sure on how to place the compare in the none code form?
Thanks,
John
Test Studio does not support data driving the IF ELSE logical blocks. They can be driven by properties of the UI. is there anything unique that shows up based on the user type e.g. Admin in the upper right vs Manager vs Staff? If so you can write an IF UI text block = "Admin" do this ELSE IF UI text block = "Manager" do this ELSE do this.
Otherwise you'll have to do something in code like this:
if
(Data[
"Role"
] ==
"Admin"
)
this
.ExecuteTest(@
"c:\testprojectdir\AdminTest.aii"
);
if
(Data[
"Role"
] ==
"Manager"
)
this
.ExecuteTest(@
"c:\testprojectdir\ManagerTest.aii"
);
if
(Data[
"Role"
] ==
"Staff"
)
this
.ExecuteTest(@
"c:\testprojectdir\StaffTest.aii"
);
Cody
the Telerik team
1) Can you show the VB version of the code?
2) What file extension is it that I need to call?
thanks,
John
Using our code conversion tool, here's the VB.NET equivalent:
If
Data(
"Role"
) =
"Admin"
Then
Me
.ExecuteTest(
"c:\testprojectdir\AdminTest.aii"
)
End
If
If
Data(
"Role"
) =
"Manager"
Then
Me
.ExecuteTest(
"c:\testprojectdir\ManagerTest.aii"
)
End
If
If
Data(
"Role"
) =
"Staff"
Then
Me
.ExecuteTest(
"c:\testprojectdir\StaffTest.aii"
)
End
If
You can use any file extension. That API call assumes whatever file you point to is a valid Test Studio test file and will attempt to load and parse the file.
All the best,
Cody
the Telerik team
If (Data("License") = "Site") Then
Me.ExecuteTest("Edition 4.0\OFA Site WebTest.tstest")
ElseIf (Data("License") = "Single") Then
Me.ExecuteTest("Edition 4.0\OFA Single WebTest.tstest")
ElseIf (Data("License") = "Single") Then
Me.ExecuteTest("Edition 4.0\OFA Free WebTest.tstest")
End If
I ran it and it works, let me know if you see any issues with this code?
thanks again,
John
Did you mean to use "Free" (or something similar) where I highlighted instead of "Single"?
If (Data("License") = "Site") Then
Me.ExecuteTest("Edition 4.0\OFA Site WebTest.tstest")
ElseIf (Data("License") = "Single") Then
Me.ExecuteTest("Edition 4.0\OFA Single WebTest.tstest")
ElseIf (Data("License") = "Single") Then
Me.ExecuteTest("Edition 4.0\OFA Free WebTest.tstest")
End If
Other than that I see nothing of concern with this code.
Cody
the Telerik team
Thanks for the catch... lol I did catch it in execution... :P I changed it but did not save it... lol ;)
thanks,
John
Is it Friday yet?!!?!?!!
The following is a coded step I am trying to execute. However, it seem to not being executing through the step. I have a local data bind (using telerik test studio instead of an external source). It doesn't seem to be checking the column "Action". Any help would be very useful.
if
(Data[
"Action"
] ==
"1"
|| Data[
"Action"
]==
"3"
)
// Set text contents of TboxMemoCapistextbox to 'Test'
Pages.DEVCAPISHub.SilverlightApp.TboxMemoCapistextbox.SetText(
false
,
"Test"
, 10, 100,
false
,
true
);
else
Log.CaptureBrowser(ActiveBrowser,
"InvoiceActionMenu"
);
Since the column values are of type string you should convert the data to string. Your code should look like:
if
(Data[
"Action"
].ToString() ==
"1"
|| Data[
"Action"
].ToString()==
"3"
)
Let me know if that helps.
Regards,
Boyan Boev
Telerik