Skip to content

Commit

Permalink
Fixed SeleniumTests.
Browse files Browse the repository at this point in the history
  • Loading branch information
NiklasSchmitt committed Nov 8, 2023
1 parent 111f7d3 commit ae7ab7f
Show file tree
Hide file tree
Showing 16 changed files with 102 additions and 71 deletions.
12 changes: 0 additions & 12 deletions scripts/test/Selenium/Agent/Admin/AdminGenericAgent.t
Original file line number Diff line number Diff line change
Expand Up @@ -297,18 +297,6 @@ $Selenium->RunTest(
$Selenium->find_element( "#Profile", 'css' )->send_keys($GenericAgentJob);
$Selenium->find_element( "#Title", 'css' )->send_keys($GenericTicketSearch);

# Check 'NewNoteBody' length validation from Add Note section (see bug#13912).
my $FieldValue = "a" x 201;
$Selenium->find_element( "#NewNoteBody", 'css' )->send_keys($FieldValue);
$Selenium->find_element( "#Submit", 'css' )->click();
$Selenium->WaitFor( JavaScript => "return \$('#NewNoteBody.Error').length === 1;" );

$Self->True(
$Selenium->execute_script("return \$('#NewNoteBody.Error').length === 1;"),
"Validation for 'NewNoteBody' field is correct",
);
$Selenium->find_element( "#NewNoteBody", 'css' )->clear();

# Insert needed dynamic fields.
$Selenium->execute_script(
"\$('#AddNewDynamicFields').val('DynamicField_$CheckboxDynamicFieldName').trigger('redraw.InputField').trigger('change');"
Expand Down
12 changes: 6 additions & 6 deletions scripts/test/Selenium/Agent/Admin/AdminPGP.t
Original file line number Diff line number Diff line change
Expand Up @@ -99,18 +99,18 @@ $Selenium->RunTest(
$Count++;
}

my $Location1 = $Selenium->{Home}
. "/scripts/test/sample/Crypt/PGPPrivateKey-1.asc";
my $LocalFile = $Selenium->{Home} . "/scripts/test/sample/Crypt/PGPPrivateKey-1.asc";
my $SeleniumFile = $Selenium->upload_file($LocalFile);

$Selenium->find_element( "#FileUpload", 'css' )->send_keys($Location1);
$Selenium->find_element( "#FileUpload", 'css' )->send_keys($SeleniumFile);
$Selenium->find_element("//button[\@type='submit']")->VerifiedClick();

# Add second test PGP key.
$Selenium->find_element("//a[contains(\@href, \'Action=AdminPGP;Subaction=Add' )]")->VerifiedClick();
my $Location2 = $Selenium->{Home}
. "/scripts/test/sample/Crypt/PGPPrivateKey-2.asc";

$Selenium->find_element( "#FileUpload", 'css' )->send_keys($Location2);
my $LocalFile2 = $Selenium->{Home} . "/scripts/test/sample/Crypt/PGPPrivateKey-2.asc";
my $SeleniumFile2 = $Selenium->upload_file($LocalFile2);
$Selenium->find_element( "#FileUpload", 'css' )->send_keys($SeleniumFile2);
$Selenium->find_element("//button[\@type='submit']")->VerifiedClick();

# Check if test PGP keys show on AdminPGP screen.
Expand Down
29 changes: 24 additions & 5 deletions scripts/test/Selenium/Agent/Admin/AdminPackageManager.t
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,10 @@ $Selenium->RunTest(
$Element->is_displayed();

# Install test package.
my $Location = $Selenium->{Home} . '/scripts/test/sample/PackageManager/TestPackage.opm';
my $LocalFile = $Selenium->{Home} . '/scripts/test/sample/PackageManager/TestPackage.opm';
my $SeleniumFile = $Selenium->upload_file($LocalFile);

$Selenium->find_element( '#FileUpload', 'css' )->send_keys($Location);
$Selenium->find_element( '#FileUpload', 'css' )->send_keys($SeleniumFile);

$Selenium->execute_script('window.Core.App.PageLoadComplete = false;');
$Selenium->find_element("//button[contains(.,'Install Package')]")->click();
Expand Down Expand Up @@ -214,8 +215,10 @@ $Selenium->RunTest(
$NavigateToAdminPackageManager->();

# Try to install incompatible test package.
$Location = $Selenium->{Home} . '/scripts/test/sample/PackageManager/TestPackageIncompatible.opm';
$Selenium->find_element( '#FileUpload', 'css' )->send_keys($Location);
$LocalFile = $Selenium->{Home} . '/scripts/test/sample/PackageManager/TestPackageIncompatible.opm';
$SeleniumFile = $Selenium->upload_file($LocalFile);

$Selenium->find_element( '#FileUpload', 'css' )->send_keys($SeleniumFile);

$Selenium->execute_script('window.Core.App.PageLoadComplete = false;');

Expand All @@ -239,6 +242,10 @@ $Selenium->RunTest(
{
Name => "Example repository 1",
URL => "https://addons.znuny.com/api/addon_repos/",
},
{
Name => "Example repository 2",
URL => "https://example.com",
}
],
);
Expand All @@ -249,7 +256,7 @@ $Selenium->RunTest(
$NavigateToAdminPackageManager->();
$Selenium->InputFieldValueSet(
Element => '#Source',
Value => 'Example repository 1',
Value => 'Example repository 2',
);

$ClickAction->("//button[\@name=\'GetRepositoryList']");
Expand All @@ -260,6 +267,18 @@ $Selenium->RunTest(
$Selenium->execute_script("return \$('.MessageBox.Notice p:contains($Notification)').length"),
"$Notification - notification is found."
);

# Check that this notification is not shown on success.
$Selenium->InputFieldValueSet(
Element => '#Source',
Value => 'Example repository 1',
);

$ClickAction->("//button[\@name=\'GetRepositoryList']");
$Self->False(
$Selenium->execute_script("return \$('.MessageBox.Notice p:contains($Notification)').length"),
"$Notification - notification is found."
);
}
);

Expand Down
15 changes: 7 additions & 8 deletions scripts/test/Selenium/Agent/Admin/AdminSMIME.t
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,9 @@ $Selenium->RunTest(
}

# Add certificate.
my $CertLocation = $Selenium->{Home}
. "/scripts/test/sample/SMIME/SMIMECertificate-smimeuser1.crt";

$Selenium->find_element( "#FileUpload", 'css' )->send_keys($CertLocation);
my $LocalCertFile = $Selenium->{Home} . "/scripts/test/sample/SMIME/SMIMECertificate-smimeuser1.crt";
my $SeleniumCertFile = $Selenium->upload_file($LocalCertFile);
$Selenium->find_element( "#FileUpload", 'css' )->send_keys($SeleniumCertFile);
$Selenium->find_element("//button[\@type='submit']")->VerifiedClick();

# Click 'Add private key'.
Expand All @@ -160,10 +159,10 @@ $Selenium->RunTest(
}

# Add private key.
my $PrivateLocation = $Selenium->{Home}
. "/scripts/test/sample/SMIME/SMIMEPrivateKey-smimeuser1.pem";
my $LocalPrivateFile = $Selenium->{Home} . "/scripts/test/sample/SMIME/SMIMEPrivateKey-smimeuser1.pem";
my $SeleniumPrivateFile = $Selenium->upload_file($LocalPrivateFile);
$Selenium->find_element( "#FileUpload", 'css' )->send_keys($SeleniumPrivateFile);

$Selenium->find_element( "#FileUpload", 'css' )->send_keys($PrivateLocation);
$Selenium->find_element("//button[\@type='submit']")->click();

$Selenium->WaitFor( JavaScript => "return typeof(\$) === 'function' && \$('#Secret.Error').length" );
Expand All @@ -176,7 +175,7 @@ $Selenium->RunTest(
'Client side validation correctly detected missing input value',
);

$Selenium->find_element( "#FileUpload", 'css' )->send_keys($PrivateLocation);
$Selenium->find_element( "#FileUpload", 'css' )->send_keys($SeleniumPrivateFile);
$Selenium->find_element( "#Secret", 'css' )->send_keys("secret");
$Selenium->find_element("//button[\@type='submit']")->VerifiedClick();

Expand Down
7 changes: 4 additions & 3 deletions scripts/test/Selenium/Agent/Admin/AgentTicketEmailPGP.t
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,11 @@ $Selenium->RunTest(

# Add test PGP key.
$Selenium->find_element("//a[contains(\@href, \'Action=AdminPGP;Subaction=Add' )]")->VerifiedClick();
my $Location = $Selenium->{Home}
. "/scripts/test/sample/Crypt/PGPPrivateKey-$Key.asc";

$Selenium->find_element( "#FileUpload", 'css' )->send_keys($Location);
my $LocalFile = $Selenium->{Home} . "/scripts/test/sample/Crypt/PGPPrivateKey-$Key.asc";
my $SeleniumFile = $Selenium->upload_file($LocalFile);

$Selenium->find_element( "#FileUpload", 'css' )->send_keys($SeleniumFile);
$Selenium->find_element("//button[\@type='submit']")->VerifiedClick();
}

Expand Down
15 changes: 7 additions & 8 deletions scripts/test/Selenium/Agent/Admin/AgentTicketEmailSMIME.t
Original file line number Diff line number Diff line change
Expand Up @@ -72,21 +72,20 @@ $Selenium->RunTest(
$Selenium->find_element("//a[contains(\@href, \'Subaction=ShowAddCertificate' )]")->VerifiedClick();

# Add certificate.
my $CertLocation = $Selenium->{Home}
. "/scripts/test/sample/SMIME/SMIMEtest3\@example.net-$Key.crt";

$Selenium->find_element( "#FileUpload", 'css' )->send_keys($CertLocation);
my $LocalCertFile = $Selenium->{Home} . "/scripts/test/sample/SMIME/SMIMEtest3\@example.net-$Key.crt";
my $SeleniumCertFile = $Selenium->upload_file($LocalCertFile);
$Selenium->find_element( "#FileUpload", 'css' )->send_keys($SeleniumCertFile);
$Selenium->find_element("//button[\@type='submit']")->VerifiedClick();

# Click 'Add private key'.
$Selenium->find_element("//a[contains(\@href, \'Subaction=ShowAddPrivate' )]")->VerifiedClick();

# Add private key.
my $PrivateLocation = $Selenium->{Home}
. "/scripts/test/sample/SMIME/SMIMEtest3\@example.net-$Key.key";
my $LocalPrivateFile = $Selenium->{Home} . "/scripts/test/sample/SMIME/SMIMEtest3\@example.net-$Key.key";
my $SeleniumPrivateFile = $Selenium->upload_file($LocalPrivateFile);
$Selenium->find_element( "#FileUpload", 'css' )->send_keys($SeleniumPrivateFile);

$Selenium->find_element( "#FileUpload", 'css' )->send_keys($PrivateLocation);
$Selenium->find_element( "#Secret", 'css' )->send_keys("secret");
$Selenium->find_element( "#Secret", 'css' )->send_keys("secret");
$Selenium->find_element("//button[\@type='submit']")->VerifiedClick();
}

Expand Down
9 changes: 9 additions & 0 deletions scripts/test/Selenium/Agent/AgentAppointmentTimeZone.t
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ $Selenium->RunTest(
# Go to calendar overview page.
$Selenium->VerifiedGet("${ScriptAlias}index.pl?Action=AgentAppointmentCalendarOverview");

sleep 2;

# Wait for AJAX to finish.
$Selenium->WaitFor(
JavaScript =>
Expand All @@ -90,6 +92,7 @@ $Selenium->RunTest(
# Hide indicator line if visible. This was causing issue in some of tests in specific execution time.
if ( $Selenium->execute_script("return \$('.fc-now-indicator.fc-now-indicator-line:visible').length;") ) {
$Selenium->execute_script("\$('.fc-now-indicator.fc-now-indicator-line').hide();");
sleep 2;
$Selenium->WaitFor(
JavaScript =>
'return typeof($) === "function" && $(".fc-now-indicator.fc-now-indicator-line:visible").length === 0;'
Expand Down Expand Up @@ -129,6 +132,8 @@ $Selenium->RunTest(
$Selenium->mouse_move_to_location( element => $EditFormSubmit );
$EditFormSubmit->click();

sleep 2;

# Wait for dialog to close and AJAX to finish.
$Selenium->WaitFor(
JavaScript =>
Expand Down Expand Up @@ -232,13 +237,17 @@ $Selenium->RunTest(
$Selenium->WaitFor( JavaScript => 'return typeof($) === "function" && !$(".CalendarWidget.Loading").length' );
$Selenium->WaitFor( JavaScript => "return \$.active == 0" );

sleep 2;

$Selenium->execute_script(
"\$('.fc-timeline-event')[0].scrollIntoView(true);",
);

# Click on an appointment.
$Selenium->execute_script("\$('.fc-timeline-event').click();");

sleep 2;

# Wait until form and overlay has loaded, if necessary.
$Selenium->WaitFor(
JavaScript => "return typeof(\$) === 'function' && \$('.Dialog').length && \$('#StartHour').length"
Expand Down
4 changes: 2 additions & 2 deletions scripts/test/Selenium/Agent/AgentTicketNoteToLinkedTicket.t
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ my $SeleniumTest = sub {
);

my @TicketIDs;
for my $Count ( 1 .. 2 ) {
for my $Count ( 0 .. 2 ) {

# create test Ticket and Articles
my $TicketID = $HelperObject->TicketCreate();
Expand Down Expand Up @@ -174,7 +174,7 @@ my $SeleniumTest = sub {
# IsVisibleForCustomer => 1,
);
my @ArticleBox;
for my $Article (@Articles) {
for my $Article ( \@Articles ) {
my %Article = $ArticleBackendObject->ArticleGet(
TicketID => $TicketIDs[1],
ArticleID => $Article->{ArticleID},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,12 @@ $Selenium->RunTest(
"\$('#FileUpload').css('display', 'block')"
);

my $Location = "$Selenium->{Home}/scripts/test/sample/Main/Main-Test1.doc";
$Selenium->find_element( "#FileUpload", 'css' )->clear();
$Selenium->find_element( "#FileUpload", 'css' )->send_keys($Location);

my $LocalFile = $Selenium->{Home} . "/scripts/test/sample/Main/Main-Test1.doc";
my $SeleniumFile = $Selenium->upload_file($LocalFile);
$Selenium->find_element( "#FileUpload", 'css' )->send_keys($SeleniumFile);

$Selenium->WaitFor(
JavaScript =>
"return typeof(\$) === 'function' && \$('.AttachmentDelete i').length"
Expand Down
24 changes: 16 additions & 8 deletions scripts/test/Selenium/Customer/MultiAttachmentUpload/TicketZoom.t
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,12 @@ $Selenium->RunTest(
);

my $CheckFileTypeFilename = 'Test1.png';
my $Location = "$Selenium->{Home}/scripts/test/sample/Cache/$CheckFileTypeFilename";
$Selenium->find_element( "#FileUpload", 'css' )->clear();
$Selenium->find_element( "#FileUpload", 'css' )->send_keys($Location);

my $LocalFile = $Selenium->{Home} . "/scripts/test/sample/Cache/$CheckFileTypeFilename";
my $SeleniumFile = $Selenium->upload_file($LocalFile);
$Selenium->find_element( "#FileUpload", 'css' )->send_keys($SeleniumFile);

$Selenium->WaitFor( JavaScript => 'return typeof($) === "function" && $(".Dialog:visible").length' );

# Verify dialog message.
Expand Down Expand Up @@ -130,19 +133,22 @@ $Selenium->RunTest(
);

# Now try to upload two files of which one exceeds the max size (.pdf should work (5KB), .png shouldn't (20KB))
$Location = "$Selenium->{Home}/scripts/test/sample/Cache/Test1.pdf";
$LocalFile = $Selenium->{Home} . "/scripts/test/sample/Cache/Test1.pdf";
$SeleniumFile = $Selenium->upload_file($LocalFile);
$Selenium->find_element( "#FileUpload", 'css' )->clear();
$Selenium->find_element( "#FileUpload", 'css' )->send_keys($Location);
$Selenium->find_element( "#FileUpload", 'css' )->send_keys($SeleniumFile);

$Selenium->WaitFor(
JavaScript =>
"return typeof(\$) === 'function' && \$('.AttachmentDelete i').length"
);
sleep 1;

my $CheckMaxAllowedSizeFilename = 'Test1.png';
$Location = "$Selenium->{Home}/scripts/test/sample/Cache/$CheckMaxAllowedSizeFilename";
$Selenium->find_element( "#FileUpload", 'css' )->clear();
$Selenium->find_element( "#FileUpload", 'css' )->send_keys($Location);
$LocalFile = $Selenium->{Home} . "/scripts/test/sample/Cache/$CheckMaxAllowedSizeFilename";
$SeleniumFile = $Selenium->upload_file($LocalFile);
$Selenium->find_element( "#FileUpload", 'css' )->send_keys($SeleniumFile);
$Selenium->WaitFor(
JavaScript => 'return typeof($) === "function" && $(".Dialog:visible").length'
);
Expand Down Expand Up @@ -175,9 +181,11 @@ $Selenium->RunTest(

# Upload file again.
my $CheckUploadAgainFilename = 'Test1.pdf';
$Location = "$Selenium->{Home}/scripts/test/sample/Cache/$CheckUploadAgainFilename";
$Selenium->find_element( "#FileUpload", 'css' )->clear();
$Selenium->find_element( "#FileUpload", 'css' )->send_keys($Location);

$LocalFile = $Selenium->{Home} . "/scripts/test/sample/Cache/$CheckUploadAgainFilename";
$SeleniumFile = $Selenium->upload_file($LocalFile);
$Selenium->find_element( "#FileUpload", 'css' )->send_keys($SeleniumFile);
$Selenium->WaitFor( JavaScript => 'return typeof($) === "function" && $(".Dialog:visible").length' );

# Verify dialog message.
Expand Down
7 changes: 4 additions & 3 deletions scripts/test/Selenium/Output/NavBar/AgentTicketProcess.t
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,10 @@ $Selenium->RunTest(

# Import test selenium process.
$Selenium->VerifiedGet("${ScriptAlias}index.pl?Action=AdminProcessManagement");
my $Location = $Selenium->{Home}
. "/scripts/test/sample/ProcessManagement/TestProcess.yml";
$Selenium->find_element( "#FileUpload", 'css' )->send_keys($Location);
my $LocalFile = $Selenium->{Home} . "/scripts/test/sample/ProcessManagement/TestProcess.yml";
my $SeleniumFile = $Selenium->upload_file($LocalFile);
$Selenium->find_element( "#FileUpload", 'css' )->send_keys($SeleniumFile);

$Selenium->find_element( "#OverwriteExistingEntitiesImport", 'css' )->click();
$Selenium->WaitFor(
JavaScript => "return typeof(\$) === 'function' && !\$('#OverwriteExistingEntitiesImport:checked').length"
Expand Down
7 changes: 4 additions & 3 deletions scripts/test/Selenium/Output/NavBar/CustomerTicketProcess.t
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,10 @@ $Selenium->RunTest(

# Import test selenium process.
$Selenium->VerifiedGet("${ScriptAlias}index.pl?Action=AdminProcessManagement");
my $Location = $Selenium->{Home}
. "/scripts/test/sample/ProcessManagement/TestProcess.yml";
$Selenium->find_element( "#FileUpload", 'css' )->send_keys($Location);
my $LocalFile = $Selenium->{Home} . "/scripts/test/sample/ProcessManagement/TestProcess.yml";
my $SeleniumFile = $Selenium->upload_file($LocalFile);
$Selenium->find_element( "#FileUpload", 'css' )->send_keys($SeleniumFile);

$Selenium->find_element( "#OverwriteExistingEntitiesImport", 'css' )->click();
$Selenium->WaitFor(
JavaScript => "return typeof(\$) === 'function' && !\$('#OverwriteExistingEntitiesImport:checked').length"
Expand Down
6 changes: 4 additions & 2 deletions scripts/test/Selenium/Output/Preferences/Customer/PGP.t
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,10 @@ $Selenium->RunTest(
$Selenium->VerifiedGet("${ScriptAlias}customer.pl?Action=CustomerPreferences");

# change customer PGP key preference
my $Location = $Selenium->{Home} . '/scripts/test/sample/Crypt/PGPPrivateKey-1.asc';
$Selenium->find_element( "#UserPGPKey", 'css' )->send_keys($Location);
my $LocalFile = $Selenium->{Home} . "/scripts/test/sample/Crypt/PGPPrivateKey-1.asc";
my $SeleniumFile = $Selenium->upload_file($LocalFile);

$Selenium->find_element( "#UserPGPKey", 'css' )->send_keys($SeleniumFile);
$Selenium->find_element( "#UserPGPKeyUpdate", 'css' )->VerifiedClick();

# Check if PGP key was uploaded correctly.
Expand Down
7 changes: 4 additions & 3 deletions scripts/test/Selenium/Output/Preferences/Customer/SMIME.t
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,10 @@ $Selenium->RunTest(
$Selenium->VerifiedGet("${ScriptAlias}customer.pl?Action=CustomerPreferences");

# change customer SMIME certificate preference
my $Location = $Selenium->{Home}
. "/scripts/test/sample/SMIME/SMIMECertificate-1.asc";
$Selenium->find_element( "#UserSMIMEKey", 'css' )->send_keys($Location);
my $LocalFile = $Selenium->{Home} . "/scripts/test/sample/SMIME/SMIMECertificate-1.asc";
my $SeleniumFile = $Selenium->upload_file($LocalFile);

$Selenium->find_element( "#UserSMIMEKey", 'css' )->send_keys($SeleniumFile);
$Selenium->find_element( "#UserSMIMEKeyUpdate", 'css' )->VerifiedClick();

# check for update SMIME certificate preference on screen
Expand Down
6 changes: 3 additions & 3 deletions scripts/test/Selenium/Output/Ticket/MenuProcess.t
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ $Selenium->RunTest(
# Import test selenium process.
my $ScriptAlias = $ConfigObject->Get('ScriptAlias');
$Selenium->VerifiedGet("${ScriptAlias}index.pl?Action=AdminProcessManagement");
my $Location = $Selenium->{Home}
. "/scripts/test/sample/ProcessManagement/TestProcess.yml";
$Selenium->find_element( "#FileUpload", 'css' )->send_keys($Location);
my $LocalFile = $Selenium->{Home} . "/scripts/test/sample/ProcessManagement/TestProcess.yml";
my $SeleniumFile = $Selenium->upload_file($LocalFile);
$Selenium->find_element( "#FileUpload", 'css' )->send_keys($SeleniumFile);
$Selenium->find_element( "#OverwriteExistingEntitiesImport", 'css' )->click();
$Selenium->WaitFor(
JavaScript => "return typeof(\$) === 'function' && !\$('#OverwriteExistingEntitiesImport:checked').length"
Expand Down
Loading

0 comments on commit ae7ab7f

Please sign in to comment.