I have site with multiple redirects leading to login page. The number of redirects could vary and I solved it with :
<transaction name="get_login_page">
<request>
<dyn_variable name="redirect" re="Location: ((http|https)://.*)\r"/>
<http url='/' version='1.1' method='GET'>
</http>
</request>
<repeat name="redirect_loop" max_repeat="5">
<request subst="true">
<dyn_variable name="redirect" re="Location: ((http|https)://.*)\r"/>
<http url="%%_redirect%%" method="GET"></http>
</request>
<until var="redirect" eq=""/>
</repeat>
</transaction>
And from this point I have a problem, because on login page I have to submit data to current URL, but after last iteration variable "redirect" becomes empty. I've tried to create additional variable with condition in cycle to save last non-empty value :
<transaction name="get_login_page">
<request>
<dyn_variable name="redirect" re="Location: ((http|https)://.*)\r"/>
<http url='/' version='1.1' method='GET'>
</http>
</request>
<repeat name="redirect_loop" max_repeat="5">
<request subst="true">
<dyn_variable name="redirect" re="Location: ((http|https)://.*)\r"/>
<if var="redirect" eq=''>
<dyn_variable name="login_url" re="Location: ((http|https)://.*)\r"/>
</if>
<http url="%%_redirect%%" method="GET"></http>
</request>
<until var="redirect" eq=""/>
</repeat>
</transaction>
But now I've got an error on tsung run :
Starting Tsung
"Log directory is: /home/***/login_portal/logs/20141103-0945"
594- fatal: {failed_validation,element_unauthorize_in_choice}
Config Error, aborting ! {{badmatch,
{<<"<arrivalphase phase=\"1\" duration=\"5\" unit=\"second\">\n <users maxnumber=\"1\" arrivalrate=\"1\" unit=\"second\"></users>\n</arrivalphase>\n">>,
{xmerl_sax_parser_state,undefined,
#Fun<xmerl_sax_parser.1.53952608>,
{file_descriptor,prim_file,
{#Port<0.1047>,13}},
#Fun<xmerl_sax_parser.default_continuation_cb.1>,
utf8,1,
[{"xml",
"http://www.w3.org/XML/1998/namespace"}],
[],[],true,69656,no,normal,
"/home/***/login_portal/.",
"tsung_config_load.xml",false}}},
[{xmerl_sax_parser_utf8,handle_external_entity,2,
[{file,"xmerl_sax_parser_utf8.erl"},
{line,1692}]},
{xmerl_sax_parser_utf8,parse_external_entity,3,
[{file,"xmerl_sax_parser_utf8.erl"},
{line,1670}]},
{xmerl_sax_parser_utf8,parse_content,4,
[{file,"xmerl_sax_parser_utf8.erl"},
{line,1157}]},
{xmerl_sax_parser_utf8,parse_document,2,
[{file,"xmerl_sax_parser_utf8.erl"},
{line,179}]},
{xmerl_sax_parser_utf8,parse,2,
[{file,"xmerl_sax_parser_utf8.erl"},
{line,115}]},
{xmerl_sax_parser,file,2,
[{file,"xmerl_sax_parser.erl"},{line,77}]},
{ts_config,read,2,
[{file,"src/tsung_controller/ts_config.erl"},
{line,77}]},
{ts_config_server,handle_call,3,
[{file,
"src/tsung_controller/ts_config_server.erl"},
{line,206}]}]}
Is there is a way to get last accessed URL or to get it from DOM model using built-in functions? Or how I should make condition to let it work properly?