Skip to content
This repository has been archived by the owner on Jan 27, 2021. It is now read-only.

Commit

Permalink
Improved Selenium test AdminDynamicField.t.
Browse files Browse the repository at this point in the history
  • Loading branch information
milanrakic committed May 9, 2019
1 parent 32b6191 commit d317f61
Showing 1 changed file with 32 additions and 3 deletions.
35 changes: 32 additions & 3 deletions scripts/test/Selenium/Agent/Admin/AdminDynamicField.t
Expand Up @@ -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",
);

Expand All @@ -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(
Expand All @@ -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(
Expand All @@ -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(),
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -325,17 +348,23 @@ $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',
Value => 'Text',
);

# 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(
Expand Down

0 comments on commit d317f61

Please sign in to comment.