Forum Discussion
"How do I record script for handling dynamic user input based on dynamic question when navigating from page 1 to page 2."
You don't.
You will need to do something more than just record/replay for this sort of scenario. I would highly recommend doing this in script rather than trying to fight your way through using a keyword test (which may be possible, but incredibly painful).
I'm assuming a couple things here:
- You know the data you want to send to the SUT, system under test, or the actions you want to perform
- You know ALL of the dynamic questions the user could be asked during the navigation operation
I would grab the text from the screen that the user is prompted with and store it in a variable... then I would write a function that uses that variable value in a Switch Statement. Then for each Case in the switch statement, you would create the desired actions (I'm betting it's something like "type this answer to that question" or the like).
Your code should end up something like this:
switch(Project.Variable.WhichQuestion) { case "Question 1": code block // Do stuff break; case "Question 2": code block // Do other stuff break; default: default code block // Stop the test; the developers made up a new question without telling you!
}
Good luck!
We have a similar scenario where the user has to answer a challenge question when logging into the site. The questions that can be displayed may be changed by others, so I never know what will display. We have agreed that the answer to the challenge questions will always be set up to be the last word in the question. So I wrote a function to grab the question, take the last word and strip off the "?" to arrive at the answer to enter. This has worked well for me.