Capture token in url and re-use it
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Capture token in url and re-use it
Hi,
I am writing tests for testing a web application. This web application uses accesstokens, to authenticate a user.
After having logged into the webapplication, the url is displayed as follows:
http://localhost:4000/main?accessToken=weoiwjfwoefnawioefnOHOHOE&sessionId=b7b8ab96-7c75-40e3-a54c-be8cb90d4
The values for accessToken and sessionId changes after every login. So, now my tests fail after every login because of changed values for accesstoken and sessionID.
To make my tests re-usable, I want to capture the accesstoken and sessionId in variables, and use these in the name mapping so that my tests are versatile.
What is the best approach for this?
Thanks,
Mathijs
Is this a good approach?
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
For namemapping, you shouldn't need to capture the tokens. Simply replace the variable parts of the URL string in your namemapping with an asterisk (*) like http://localhost:4000/main?access=*&sessionid=*.
For that matter, you might be able to just replace everything after the ? with the asterisk.
Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----
Why automate? I do automated testing because there's only so much a human being can do and remain healthy. Sleep is a requirement. So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.
Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@tristaanogre wrote:For namemapping, you shouldn't need to capture the tokens. Simply replace the variable parts of the URL string in your namemapping with an asterisk (*) like http://localhost:4000/main?access=*&sessionid=*.
For that matter, you might be able to just replace everything after the ? with the asterisk.
Hi @tristaanogre,
thanks for the tip.
Suppose I want to 'catch' the values for the accesstoken, and sessionId, and save them in a variable. How to do that?
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You'll have to write some sort of function to parse the URL to grab those values, I'd imagine, using some combination of aqString methods to find the segments and pull them out. I think I recall somewhere that those values might be saved as properties or attributes on the page object itself but I can't guarentee the veracity of that. Because they are such variable values and I haven't had need to use them in functional testing, I can't help much with specifics on this. Sorry. 😞
Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----
Why automate? I do automated testing because there's only so much a human being can do and remain healthy. Sleep is a requirement. So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.
Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
This https://community.smartbear.com/t5/TestComplete-Functional-Web/How-do-I-access-security-code-from-em... may use full for you.
Let me know if you are not able to capture.
Thanks
Shankar R
LinkedIn | CG-VAK Software | Bitbucket | shankarr.75@gmail.com
“You must expect great things from you, before you can do them”