Skip to content

Commit

Permalink
fullstack: Make find_status_text wait for the element
Browse files Browse the repository at this point in the history
Fixes the following error:

    findElement: no such element: Unable to locate element: {"method":"css
    selector","selector":"#info_box .card-body"}`

See: https://progress.opensuse.org/issues/98952
  • Loading branch information
kalikiana committed Oct 8, 2021
1 parent addc5c2 commit c7e3a71
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
18 changes: 8 additions & 10 deletions t/full-stack.t
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,6 @@ $driver->click_element_ok('tour-end', 'id', 'confirm dismissing tour');

schedule_one_job_over_api_and_verify($driver, OpenQA::Test::FullstackUtils::job_setup(PAUSE_AT => 'shutdown'));

sub status_text { find_status_text($driver) }

# add a function to verify the test setup before trying to run a job
my $setup_timeout = OpenQA::Test::TimeLimit::scale_timeout($ENV{OPENQA_FULLSTACK_SETUP_TIMEOUT} // 2);
sub check_scheduled_job_and_wait_for_free_worker ($worker_class) {
Expand Down Expand Up @@ -130,7 +128,7 @@ my $job_name = 'tinycore-1-flavor-i386-Build1-core@coolone';
$driver->find_element_by_link_text('core@coolone')->click();
$driver->title_is("openQA: $job_name test results", 'scheduled test page');
my $job_page_url = $driver->get_current_url();
like(status_text, qr/State: scheduled/, 'test 1 is scheduled');
like(wait_for_status_text, qr/State: scheduled/, 'test 1 is scheduled');
ok javascript_console_has_no_warnings_or_errors, 'no javascript warnings or errors after test 1 was scheduled';

sub assign_jobs ($worker_class = undef) {
Expand Down Expand Up @@ -199,7 +197,7 @@ client_call('jobs/1', qr/group_id.+$group_id/, 'group has been altered correctly

client_call('-X POST jobs/1/restart', qr|test_url.+1.+tests.+2|, 'client returned new test_url for test 2');
$driver->refresh();
like status_text, qr/Cloned as 2/, 'test 1 is restarted';
like wait_for_status_text, qr/Cloned as 2/, 'test 1 is restarted';
$driver->click_element_ok('2', 'link_text', 'clicked link to test 2');

# start a job and stop the worker; the job should be incomplete
Expand All @@ -209,7 +207,7 @@ assign_jobs;
ok wait_for_job_running($driver), 'job 2 running';
stop_worker;
ok wait_for_result_panel($driver, qr/Result: incomplete/), 'test 2 crashed' or show_job_info 2;
like status_text, qr/Cloned as 3/, 'test 2 is restarted by killing worker';
like wait_for_status_text, qr/Cloned as 3/, 'test 2 is restarted by killing worker';

client_call(
'-X POST jobs ' . OpenQA::Test::FullstackUtils::job_setup(MACHINE => 'noassets', HDD_1 => 'nihilist_disk.hda'));
Expand All @@ -232,7 +230,7 @@ wait_for_ajax(msg => 'wait for All Tests displayed before looking for 3');
$driver->click_element_ok('core@noassets', 'link_text', 'clicked on 4');
$job_name = 'tinycore-1-flavor-i386-Build1-core@noassets';
$driver->title_is("openQA: $job_name test results", 'scheduled test page');
like status_text, qr/State: scheduled/, 'test 4 is scheduled';
like wait_for_status_text, qr/State: scheduled/, 'test 4 is scheduled';

ok javascript_console_has_no_warnings_or_errors, 'no javascript warnings or errors after test 4 was scheduled';
start_worker_and_assign_jobs;
Expand Down Expand Up @@ -285,7 +283,7 @@ subtest 'Cache tests' => sub {
$job_name = 'tinycore-1-flavor-i386-Build1-core@coolone';
client_call('-X POST jobs ' . OpenQA::Test::FullstackUtils::job_setup(PUBLISH_HDD_1 => ''));
$driver->get('/tests/5');
like status_text, qr/State: scheduled/, 'test 5 is scheduled' or die;
like wait_for_status_text, qr/State: scheduled/, 'test 5 is scheduled' or die;
start_worker_and_assign_jobs;
ok wait_for_job_running($driver, 1), 'job 5 running' or show_job_info 5;
ok -e $db_file, 'cache.sqlite file created';
Expand Down Expand Up @@ -349,7 +347,7 @@ subtest 'Cache tests' => sub {
#simple limit testing.
client_call('-X POST jobs/5/restart', qr|test_url.+5.+tests.+6|, 'client returned new test_url for test 6');
$driver->get('/tests/6');
like status_text, qr/State: scheduled/, 'test 6 is scheduled';
like wait_for_status_text, qr/State: scheduled/, 'test 6 is scheduled';
start_worker_and_assign_jobs;
ok wait_for_result_panel($driver, qr/Result: passed/), 'test 6 is passed' or show_job_info 6;
stop_worker;
Expand All @@ -366,7 +364,7 @@ subtest 'Cache tests' => sub {
#simple limit testing.
client_call('-X POST jobs/6/restart', qr|test_url.+6.+tests.+7|, 'client returned new test_url for test 7');
$driver->get('/tests/7');
like status_text, qr/State: scheduled/, 'test 7 is scheduled';
like wait_for_status_text, qr/State: scheduled/, 'test 7 is scheduled';
start_worker_and_assign_jobs;
ok wait_for_result_panel($driver, qr/Result: passed/), 'test 7 is passed' or show_job_info 7;
$autoinst_log = autoinst_log(7);
Expand All @@ -379,7 +377,7 @@ subtest 'Cache tests' => sub {
assign_jobs;
$driver->get('/tests/8');
ok wait_for_result_panel($driver, qr/Result: incomplete/), 'test 8 is incomplete' or show_job_info 8;
like find_status_text($driver), qr/Failed to download.*non-existent.qcow2/, 'reason for incomplete specified';
like wait_for_status_text, qr/Failed to download.*non-existent.qcow2/, 'reason for incomplete specified';

subtest 'log shown within details tab (without page reload)' => sub {
$driver->find_element_by_link_text('Details')->click();
Expand Down
8 changes: 4 additions & 4 deletions t/lib/OpenQA/Test/FullstackUtils.pm
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use Test::Most;
use base 'Exporter';

our @EXPORT = qw(get_connect_args client_output client_call prevent_reload
reload_manually find_status_text wait_for_result_panel
reload_manually wait_for_status_text wait_for_result_panel
wait_for_job_running wait_for_developer_console_like
wait_for_developer_console_available
verify_one_job_displayed_as_scheduled
Expand Down Expand Up @@ -75,7 +75,7 @@ sub client_call {
}
}

sub find_status_text { shift->find_element('#info_box .card-body')->get_text() }
sub wait_for_status_text { wait_for_element(selector => '#info_box .card-body')->get_text() }

sub _bail_with_result_panel_contents {
my ($result_panel_contents) = @_;
Expand All @@ -92,7 +92,7 @@ sub wait_for_result_panel {
my $timeout = OpenQA::Test::TimeLimit::scale_timeout(ONE_MINUTE * 3) / $check_interval;
for (my $count = 0; $count < $timeout; $count++) {
wait_for_ajax(msg => "result panel shows '$result_panel'");
my $status_text = find_status_text($driver);
my $status_text = wait_for_status_text($driver);
return 1 if $status_text =~ $result_panel;
if ($fail_on_incomplete && $status_text =~ qr/Result: (incomplete|timeout_exceeded)/) {
diag('test result is incomplete but shouldn\'t');
Expand All @@ -105,7 +105,7 @@ sub wait_for_result_panel {
javascript_console_has_no_warnings_or_errors;
sleep $check_interval if $check_interval;
}
my $final_status_text = find_status_text($driver);
my $final_status_text = wait_for_status_text($driver);
return 1 if $final_status_text =~ $result_panel;
return _bail_with_result_panel_contents $final_status_text;
}
Expand Down

0 comments on commit c7e3a71

Please sign in to comment.