@@ -29,6 +29,7 @@ use Time::HiRes qw();
29
29
30
30
# CPAN modules
31
31
use Devel::StackTrace();
32
+ use Test2::V0;
32
33
use Test2::API qw( context run_subtest) ;
33
34
use Net::DNS::Resolver;
34
35
@@ -439,8 +440,6 @@ sub Login {
439
440
}
440
441
}
441
442
442
- my $Context = context();
443
-
444
443
my $Code = sub {
445
444
# we will try several times to log in
446
445
my $MaxTries = 5;
@@ -460,7 +459,7 @@ sub Login {
460
459
$LogoutXPath = q{ //a[@title='Logout']} ;
461
460
}
462
461
463
- $Self -> get(" ${ ScriptAlias} " );
462
+ $Self -> get($ ScriptAlias );
464
463
465
464
$Self -> delete_all_cookies();
466
465
$Self -> VerifiedGet(" ${ScriptAlias} ?Action=Login;User=$Param {User};Password=$Param {Password}" );
@@ -476,19 +475,17 @@ sub Login {
476
475
# login successful?
477
476
$Self -> find_element( $LogoutXPath , ' xpath' ); # dies if not found
478
477
479
- $Context -> pass( ' Login sequence ended...' );
478
+ pass( ' Login sequence ended...' );
480
479
};
481
480
482
481
# an error happend
483
482
if ($@ ) {
484
483
485
- $Context -> note( " Login attempt $Try of $MaxTries not successful." );
484
+ note( " Login attempt $Try of $MaxTries not successful." );
486
485
487
486
# try again
488
487
next TRY if $Try < $MaxTries ;
489
488
490
- $Context -> release();
491
-
492
489
die " Login failed!" ;
493
490
}
494
491
@@ -499,6 +496,8 @@ sub Login {
499
496
}
500
497
};
501
498
499
+ my $Context = context();
500
+
502
501
run_subtest( ' Login' , $Code , { buffered => 1, inherit_trace => 1 } );
503
502
504
503
$Context -> release;
0 commit comments