From d317f611a4a0d53f8595c1e6a8069aca3e3d1fdc Mon Sep 17 00:00:00 2001 From: Milan Rakic Date: Thu, 9 May 2019 14:40:59 +0200 Subject: [PATCH] Improved Selenium test AdminDynamicField.t. --- .../Selenium/Agent/Admin/AdminDynamicField.t | 35 +++++++++++++++++-- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/scripts/test/Selenium/Agent/Admin/AdminDynamicField.t b/scripts/test/Selenium/Agent/Admin/AdminDynamicField.t index cdf78c133ae..8bbc19b5c1f 100644 --- a/scripts/test/Selenium/Agent/Admin/AdminDynamicField.t +++ b/scripts/test/Selenium/Agent/Admin/AdminDynamicField.t @@ -162,9 +162,14 @@ $Selenium->RunTest( ); $Selenium->find_element("//button[\@type='submit']")->VerifiedClick(); + $Selenium->WaitFor( + JavaScript => + "return typeof(\$) === 'function' && \$('#DynamicFieldsTable tr:contains($RandomID)').length;" + ); + # Check if test DynamicField show on AdminDynamicField screen. $Self->True( - index( $Selenium->get_page_source(), $RandomID ) > -1, + $Selenium->execute_script("return \$('#DynamicFieldsTable tr:contains($RandomID)').length;"), "$RandomID $ID $Type DynamicField found on page", ); @@ -179,6 +184,10 @@ $Selenium->RunTest( . $RandomID ); + $Selenium->WaitFor( + JavaScript => "return typeof(\$) === 'function' && \$('#Label').length && \$('#ValidID').length;" + ); + $Selenium->find_element( "#Label", 'css' )->clear(); $Selenium->find_element( "#Label", 'css' )->send_keys( $RandomID . "-update" ); $Selenium->InputFieldValueSet( @@ -187,6 +196,11 @@ $Selenium->RunTest( ); $Selenium->find_element("//button[\@type='submit']")->VerifiedClick(); + $Selenium->WaitFor( + JavaScript => + "return typeof(\$) === 'function' && \$('tr.Invalid td a:contains($RandomID)').length;" + ); + # Check class of invalid DynamicField in the overview table. $Self->True( $Selenium->execute_script( @@ -198,6 +212,10 @@ $Selenium->RunTest( # Go to new DynamicField again after update and check values. $Selenium->find_element( $RandomID, 'link_text' )->VerifiedClick(); + $Selenium->WaitFor( + JavaScript => "return typeof(\$) === 'function' && \$('#Name').length;" + ); + # Check new DynamicField values. $Self->Is( $Selenium->find_element( '#Name', 'css' )->get_value(), @@ -288,10 +306,15 @@ $Selenium->RunTest( # Navigate to AdminDynamiField screen. $Selenium->VerifiedGet("${ScriptAlias}index.pl?Action=AdminDynamicField"); + $Selenium->WaitFor( + JavaScript => + "return typeof(\$) === 'function' && \$('#ShowContextSettingsDialog').length;" + ); + # Set 10 fields per page. $Selenium->find_element( "a#ShowContextSettingsDialog", 'css' )->click(); $Selenium->WaitFor( - JavaScript => 'return typeof($) === "function" && $("#AdminDynamicFieldsOverviewPageShown").length;' + JavaScript => 'return $("#AdminDynamicFieldsOverviewPageShown").length && $("#DialogButton1").length;' ); $Selenium->InputFieldValueSet( Element => '#AdminDynamicFieldsOverviewPageShown', @@ -325,9 +348,15 @@ $Selenium->RunTest( # Go back to AdminDynamiField screen. $Selenium->VerifiedGet("${ScriptAlias}index.pl?Action=AdminDynamicField"); + # Wait until page has finished loading. + $Selenium->WaitFor( JavaScript => 'return typeof($) === "function" && $("#AdminDynamicFieldPage2").length;' ); + # Go to the second page. $Selenium->find_element( "#AdminDynamicFieldPage2", 'css' )->VerifiedClick(); + # Wait until page has finished loading. + $Selenium->WaitFor( JavaScript => 'return typeof($) === "function" && $("#TicketDynamicField").length;' ); + # Click to create 'Text' type ticket dynamic field from the second page. $Selenium->InputFieldValueSet( Element => '#TicketDynamicField', @@ -335,7 +364,7 @@ $Selenium->RunTest( ); # Wait until page has finished loading. - $Selenium->WaitFor( JavaScript => 'return typeof($) === "function" && $("#Name").length;' ); + $Selenium->WaitFor( JavaScript => 'return typeof($) === "function" && $("#FieldOrder").length;' ); # Check FieldOrder default value. $Self->Is(