I'm currently unsure how to go about this. Take for instance this simplified version of the issue as shown in this series of tests as steps.
1. Log in as user A
2. Perform actions Q,R,S
3. Log out of user A's profile
4. Log in as user B
5. Perform actions T,U,V
6. Log out of user B's profile.
Currently, I don't have a way to let the application know that the second time the "Log in" test runs, it's supposed to use a different bit of data. If I have two rows of data for that test. It simply runs the entire list of tests (from 1-6) for each row. But I'd like for it to run only once, but using different data for each Log in.
Any assistance is greatly appreciated.
1 Answer, 1 is accepted
Hello Daniel,
I analyzed the scenario that you want to automate and prepared sample tests against publicly accessible application. Please explore the attached tests and the details below.
One of the options is to data bind actions Q,R,S to work as actions T,U,V in the second iteration and only have steps for login (A) and one set of data driven actions (Q,R,S) - see test LoginDifferentUsersDataDriveAll. However, this might not be possible and my other suggestion is to use a condition, based on the logged in user. For example, if the logged in user is from the first iteration, the test will execute all steps in the If block. Otherwise, it will execute the steps in the Else block. This is showcased in test LoginDifferentUsersConditional.
I hope the above suggestions and sample tests will be helpful to you for this specific automation. Of course, I remain available to continue our discussion, if you need further assistance.
Regards,
Plamen Mitrev
Progress Telerik
Hi Daniel, thank you for the additional information. In this case, you can change the data from the current iteration in a coded step right before the second login. I prepared a sample test with coded step, which changes the local data of the iteration, so it uses the new values. Please explore the code and local data of the attached test.
For your scenario, I assume that the coded step should be placed before the second login test as step. You can give it a try and let me know if this helped you automate this scenario.
Hello, this logic would solve the problem i'm having. However when i try to integrate it into my solution i'm getting this error.
error CS0012: The type 'System.Xml.Serialization.IXmlSerializable' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
15:21:50 'INFO' > Build Failed
any ideas on what would be causing this/ how i can fix it?
Hello Daniel, the compilation error says that your project is missing reference to assembly System.Xml and probably System.Data. You need to reference them in your Test Studio project, so they can be used by the coded step. You can follow the instructions to do that in this article.
In my sample test's coded step, I declared System.Xml and System.Data assemblies with the "using" keyword and added references to them in my project. Your project should compile after you add a reference to the required assemblies. Let me know if you encounter any troubles.
Hi Daniel, it should work if the steps are test as steps as long as they have the correct data source. Either the test as steps should be data driven or inherit the parent test's data. Based on the tests as step and the overall scenario, you need to decide where to put the coded step that updates the data of the current iteration. I assume that it would be better to place it in the main test, outside of the login test as step, according to the information about your scenario.
Let me know if the suggestions worked and whether you need further assistance on the topic. I will be more than happy to help!
Hi Daniel,
You can use a coded step and write into data source, if this is an external source - here is an example for an Excel file.
An alternative of this could be to use the extracted variables in code. Here you can read the general concept for extracting some value from the page and store it into variable. For more complicated scenarios these variables can be used in coded steps to change their value following some requirements. Then, these new values can be used back in the test through the step bindings (there is a sample project, which demonstrates a complete scenario for this).
I hope these possible options will be of further help for you to setup the automation tests. Let us know in case you have further questions .
Regards,
Elena
Hello Elena, it is not for an external source, simply for the built in local data. Meanwhile, I will take a look at the other resources provided. Thank you!
Hi Daniel,
I am sorry for any possible misunderstanding. You cannot directly write into the built-in data of a test. The options you have is to use the extracted variables either in code, or if these values don't require modification - directly in the UI.
If the scenario is more complex and you need to keep some info in a data source, you can switch to using an external source and write into it from a coded step.
I hope this helps!
Regards,
Elena