Skip to content

Commit abbe605

Browse files
committed
Issue #682: Fiddle with the testing contexts
1 parent 3702c24 commit abbe605

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

Kernel/System/UnitTest/Selenium.pm

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ use Time::HiRes qw();
2929

3030
# CPAN modules
3131
use Devel::StackTrace();
32+
use Test2::V0;
3233
use Test2::API qw(context run_subtest);
3334
use Net::DNS::Resolver;
3435

@@ -439,8 +440,6 @@ sub Login {
439440
}
440441
}
441442

442-
my $Context = context();
443-
444443
my $Code = sub {
445444
# we will try several times to log in
446445
my $MaxTries = 5;
@@ -460,7 +459,7 @@ sub Login {
460459
$LogoutXPath = q{//a[@title='Logout']};
461460
}
462461

463-
$Self->get("${ScriptAlias}");
462+
$Self->get($ScriptAlias);
464463

465464
$Self->delete_all_cookies();
466465
$Self->VerifiedGet("${ScriptAlias}?Action=Login;User=$Param{User};Password=$Param{Password}");
@@ -476,19 +475,17 @@ sub Login {
476475
# login successful?
477476
$Self->find_element( $LogoutXPath, 'xpath' ); # dies if not found
478477

479-
$Context->pass( 'Login sequence ended...' );
478+
pass( 'Login sequence ended...' );
480479
};
481480

482481
# an error happend
483482
if ($@) {
484483

485-
$Context->note( "Login attempt $Try of $MaxTries not successful." );
484+
note( "Login attempt $Try of $MaxTries not successful." );
486485

487486
# try again
488487
next TRY if $Try < $MaxTries;
489488

490-
$Context->release();
491-
492489
die "Login failed!";
493490
}
494491

@@ -499,6 +496,8 @@ sub Login {
499496
}
500497
};
501498

499+
my $Context = context();
500+
502501
run_subtest( 'Login', $Code, { buffered => 1, inherit_trace => 1 } );
503502

504503
$Context->release;

0 commit comments

Comments
 (0)