"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "Kernel/System/UnitTest/Selenium.pm" between
otrs-5.0.39.tar.bz2 and otrs-5.0.40.tar.bz2

About: OTRS (formerly "Open Ticket Request System" now "Open Technology – Real Service") is a web-based ticketing systems used for Customer Service, Help Desk, IT Service Management. 5.x release ("Community Edition").

Selenium.pm  (otrs-5.0.39.tar.bz2):Selenium.pm  (otrs-5.0.40.tar.bz2)
skipping to change at line 122 skipping to change at line 122
|| die "Could not load Kernel::System::UnitTest::Selenium::WebElement"; || die "Could not load Kernel::System::UnitTest::Selenium::WebElement";
my $Self; my $Self;
# TEMPORARY WORKAROUND FOR GECKODRIVER BUG https://github.com/mozilla/geckod river/issues/1470: # TEMPORARY WORKAROUND FOR GECKODRIVER BUG https://github.com/mozilla/geckod river/issues/1470:
# If marionette handshake fails, wait and try again. Can be removed after the bug is fixed # If marionette handshake fails, wait and try again. Can be removed after the bug is fixed
# in a new geckodriver version. # in a new geckodriver version.
eval { eval {
$Self = $Class->SUPER::new( $Self = $Class->SUPER::new(
webelement_class => 'Kernel::System::UnitTest::Selenium::WebElement' , webelement_class => 'Kernel::System::UnitTest::Selenium::WebElement' ,
error_handler => \&SeleniumErrorHandler,
%SeleniumTestsConfig %SeleniumTestsConfig
); );
}; };
if ($@) { if ($@) {
my $Exception = $@; my $Exception = $@;
# Only handle this specific geckodriver exception. # Only handle this specific geckodriver exception.
die $Exception if $Exception !~ m{Socket timeout reading Marionette hand shake data}; die $Exception if $Exception !~ m{Socket timeout reading Marionette hand shake data};
# Sleep and try again, bail out if it fails a second time. # Sleep and try again, bail out if it fails a second time.
skipping to change at line 158 skipping to change at line 159
my $Width = $SeleniumTestsConfig{window_width} || 1400; my $Width = $SeleniumTestsConfig{window_width} || 1400;
$Self->set_window_size( $Height, $Width ); $Self->set_window_size( $Height, $Width );
$Self->{BaseURL} = $Kernel::OM->Get('Kernel::Config')->Get('HttpType') . ':/ /'; $Self->{BaseURL} = $Kernel::OM->Get('Kernel::Config')->Get('HttpType') . ':/ /';
$Self->{BaseURL} .= Kernel::System::UnitTest::Helper->GetTestHTTPHostname(); $Self->{BaseURL} .= Kernel::System::UnitTest::Helper->GetTestHTTPHostname();
# Remember the start system time for the selenium test run. # Remember the start system time for the selenium test run.
$Self->{TestStartSystemTime} = $Kernel::OM->Get('Kernel::System::Time')->Sys temTime(); $Self->{TestStartSystemTime} = $Kernel::OM->Get('Kernel::System::Time')->Sys temTime();
# Force usage of legacy webdriver methods in Chrome until things are more st
able.
if ( lc $SeleniumTestsConfig{browser_name} eq 'chrome' ) {
$Self->{is_wd3} = 0;
}
return $Self; return $Self;
} }
sub SeleniumErrorHandler {
my ( $Self, $Error ) = @_;
my $Caller = 0;
my $StackTrace = "Selenium stack trace: ($$): \n";
COUNT:
for ( my $Count = 0; $Count < 30; $Count++ ) {
my ( $Package1, $Filename1, $Line1, $Subroutine1 ) = caller( $Caller + $
Count );
last COUNT if !$Line1;
my ( $Package2, $Filename2, $Line2, $Subroutine2 ) = caller( $Caller + 1
+ $Count );
# if there is no caller module use the file name
$Subroutine2 ||= $0;
# print line if upper caller module exists
my $VersionString = '';
eval { $VersionString = $Package1->VERSION || ''; }; ## no critic
# version is present
if ($VersionString) {
$VersionString = ' (v' . $VersionString . ')';
}
$StackTrace .= " Module: $Subroutine2$VersionString Line: $Line1\n";
last COUNT if !$Line2;
}
$Self->{_SeleniumStackTrace} = $StackTrace;
$Self->{_SeleniumException} = $Error;
die $Error;
}
=item RunTest() =item RunTest()
runs a selenium test if Selenium testing is configured and performs proper runs a selenium test if Selenium testing is configured and performs proper
error handling (calls C<HandleError()> if needed). error handling (calls C<HandleError()> if needed).
$SeleniumObject->RunTest( sub { ... } ); $SeleniumObject->RunTest( sub { ... } );
=cut =cut
sub RunTest { sub RunTest {
skipping to change at line 444 skipping to change at line 488
# Eval is needed because the method would throw if no alert is prese nt (yet). # Eval is needed because the method would throw if no alert is prese nt (yet).
return 1 if eval { $Self->get_alert_text() }; return 1 if eval { $Self->get_alert_text() };
} }
elsif ( $Param{Callback} ) { elsif ( $Param{Callback} ) {
return 1 if $Param{Callback}->(); return 1 if $Param{Callback}->();
} }
elsif ( $Param{ElementExists} ) { elsif ( $Param{ElementExists} ) {
my @Arguments my @Arguments
= ref( $Param{ElementExists} ) eq 'ARRAY' ? @{ $Param{ElementExi sts} } : $Param{ElementExists}; = ref( $Param{ElementExists} ) eq 'ARRAY' ? @{ $Param{ElementExi sts} } : $Param{ElementExists};
if ( eval { $Self->find_element(@Arguments) } ) { if ( eval { $Self->find_element(@Arguments) } ) {
Time::HiRes::sleep($WaitSeconds); Time::HiRes::sleep($WaitSeconds);
return 1; return 1;
} }
} }
elsif ( $Param{ElementMissing} ) { elsif ( $Param{ElementMissing} ) {
my @Arguments my @Arguments
= ref( $Param{ElementMissing} ) eq 'ARRAY' ? @{ $Param{ElementMi ssing} } : $Param{ElementMissing}; = ref( $Param{ElementMissing} ) eq 'ARRAY' ? @{ $Param{ElementMi ssing} } : $Param{ElementMissing};
if ( !eval { $Self->find_element(@Arguments) } ) { if ( !eval { $Self->find_element(@Arguments) } ) {
Time::HiRes::sleep($WaitSeconds); Time::HiRes::sleep($WaitSeconds);
return 1; return 1;
} }
} }
Time::HiRes::sleep($Interval); Time::HiRes::sleep($Interval);
$WaitedSeconds += $Interval; $WaitedSeconds += $Interval;
$Interval += 0.1; $Interval += 0.1;
} }
skipping to change at line 583 skipping to change at line 629
$SeleniumObject->HandleError($@); $SeleniumObject->HandleError($@);
It will create a failing test result and store a screen shot of the page It will create a failing test result and store a screen shot of the page
for analysis (in folder /var/otrs-unittest if it exists, in $Home/var/httpd/htdo cs otherwise). for analysis (in folder /var/otrs-unittest if it exists, in $Home/var/httpd/htdo cs otherwise).
=cut =cut
sub HandleError { sub HandleError {
my ( $Self, $Error ) = @_; my ( $Self, $Error ) = @_;
$Self->{UnitTestDriverObject}->False( 1, "Exception in Selenium': $Error" ); $Self->{UnitTestDriverObject}->False( 1, $Error );
# If we really have a selenium error, get the stack trace for it.
if ( $Error eq $Self->{_SeleniumException} && $Self->{_SeleniumStackTrace} )
{
$Self->{UnitTestDriverObject}->False( 1, $Self->{_SeleniumStackTrace} );
}
#eval {
my $Data = $Self->screenshot(); my $Data = $Self->screenshot();
return if !$Data; return if !$Data;
$Data = MIME::Base64::decode_base64($Data); $Data = MIME::Base64::decode_base64($Data);
# #
# Store screenshots in a local folder from where they can be opened directly in the browser. # Store screenshots in a local folder from where they can be opened directly in the browser.
# #
my $LocalScreenshotDir = $Kernel::OM->Get('Kernel::Config')->Get('Home') . ' /var/httpd/htdocs/SeleniumScreenshots'; my $LocalScreenshotDir = $Kernel::OM->Get('Kernel::Config')->Get('Home') . ' /var/httpd/htdocs/SeleniumScreenshots';
mkdir $LocalScreenshotDir || return $Self->False( 1, "Could not create $Loca lScreenshotDir." ); mkdir $LocalScreenshotDir || return $Self->False( 1, "Could not create $Loca lScreenshotDir." );
 End of changes. 7 change blocks. 
2 lines changed or deleted 56 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)