Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix sporadic test failure in t/ui/10-tests_overview.t #6268

Merged
merged 2 commits into from
Mar 8, 2025

Conversation

Martchus
Copy link
Contributor

@Martchus Martchus commented Mar 7, 2025

This test sometimes runs into:

getElementText: stale element reference: stale element not found at /home/squamata/project/t/ui/../lib/OpenQA/SeleniumTest.pm:77 at /home/squamata/project/t/ui/../lib/OpenQA/SeleniumTest.pm line 80.
OpenQA::SeleniumTest::__ANON__(Test::Selenium::Chrome=HASH(0x561a52552560), "Error while executing command: getElementText: stale element "..., HASH(0x561a528c1030)) called at /usr/lib/perl5/vendor_perl/5.26.1/Selenium/Remote/Driver.pm line 356
Selenium::Remote::Driver::catch {...} ("Error while executing command: getElementText: stale element "...) called at /usr/lib/perl5/vendor_perl/5.26.1/Try/Tiny.pm line 123
…
Selenium::Remote::WebElement::_execute_command(Test::Selenium::Remote::WebElement=HASH(0x561a528b82b0), HASH(0x561a528c1030)) called at /usr/lib/perl5/vendor_perl/5.26.1/Selenium/Remote/WebElement.pm line 358
Selenium::Remote::WebElement::get_text(Test::Selenium::Remote::WebElement=HASH(0x561a528b82b0)) called at t/ui/10-tests_overview.t line 460
…
Test::Builder::subtest(Test::Builder=HASH(0x561a46ef9a28), "filter for specific machine", CODE(0x561a528b5b00)) called at /usr/lib/perl5/5.26.1/Test/More.pm line 807
Test::More::subtest("filter for specific machine", CODE(0x561a528b5b00)) called at t/ui/10-tests_overview.t line 463
…
Test::Builder::subtest(Test::Builder=HASH(0x561a46ef9a28), "filtering by machine", CODE(0x561a52888920)) called at /usr/lib/perl5/5.26.1/Test/More.pm line 807
Test::More::subtest("filtering by machine", CODE(0x561a52888920)) called at t/ui/10-tests_overview.t line 464

There is no AJAX or dynamic loading of these elements at play. So the
problem is perhaps that the wait_for_element still finds the element
before the reload is done and then accessing the text of the element is no
longer possible when the page has actually reloaded. If this is true then
simply reordering the wait_for_element calls will help as the test now
looks for the element that is not present before reloading first.

Martchus added 2 commits March 7, 2025 15:46
This test sometimes runs into:

```
getElementText: stale element reference: stale element not found at /home/squamata/project/t/ui/../lib/OpenQA/SeleniumTest.pm:77 at /home/squamata/project/t/ui/../lib/OpenQA/SeleniumTest.pm line 80.
OpenQA::SeleniumTest::__ANON__(Test::Selenium::Chrome=HASH(0x561a52552560), "Error while executing command: getElementText: stale element "..., HASH(0x561a528c1030)) called at /usr/lib/perl5/vendor_perl/5.26.1/Selenium/Remote/Driver.pm line 356
Selenium::Remote::Driver::catch {...} ("Error while executing command: getElementText: stale element "...) called at /usr/lib/perl5/vendor_perl/5.26.1/Try/Tiny.pm line 123
…
Selenium::Remote::WebElement::_execute_command(Test::Selenium::Remote::WebElement=HASH(0x561a528b82b0), HASH(0x561a528c1030)) called at /usr/lib/perl5/vendor_perl/5.26.1/Selenium/Remote/WebElement.pm line 358
Selenium::Remote::WebElement::get_text(Test::Selenium::Remote::WebElement=HASH(0x561a528b82b0)) called at t/ui/10-tests_overview.t line 460
…
Test::Builder::subtest(Test::Builder=HASH(0x561a46ef9a28), "filter for specific machine", CODE(0x561a528b5b00)) called at /usr/lib/perl5/5.26.1/Test/More.pm line 807
Test::More::subtest("filter for specific machine", CODE(0x561a528b5b00)) called at t/ui/10-tests_overview.t line 463
…
Test::Builder::subtest(Test::Builder=HASH(0x561a46ef9a28), "filtering by machine", CODE(0x561a52888920)) called at /usr/lib/perl5/5.26.1/Test/More.pm line 807
Test::More::subtest("filtering by machine", CODE(0x561a52888920)) called at t/ui/10-tests_overview.t line 464
```

There is no AJAX or dynamic loading of these elements at play. So the
problem is perhaps that the `wait_for_element` still finds the element
before the reload is done and then accessing the text of the element is no
longer possible when the page has actually reloaded. If this is true then
simply reordering the `wait_for_element` calls will help as the test now
looks for the element that is not present before reloading first.
Copy link
Member

@kalikiana kalikiana left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense

Copy link

codecov bot commented Mar 7, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.00%. Comparing base (92b047c) to head (7dc98eb).
Report is 5 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #6268   +/-   ##
=======================================
  Coverage   99.00%   99.00%           
=======================================
  Files         398      398           
  Lines       40057    40057           
=======================================
  Hits        39660    39660           
  Misses        397      397           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@mergify mergify bot merged commit 9d36fca into os-autoinst:master Mar 8, 2025
46 checks passed
@Martchus Martchus deleted the tests-overview branch March 8, 2025 16:25
@perlpunk
Copy link
Contributor

perlpunk commented Mar 8, 2025

@Martchus
Copy link
Contributor Author

Martchus commented Mar 9, 2025

Yes, now the check for whether the element is displayed is failing:

[23:22:28] t/ui/10-tests_overview.t ................... 12/? isElementDisplayed: stale element reference: stale element not found at /home/squamata/project/t/ui/../lib/OpenQA/SeleniumTest.pm:78 at /home/squamata/project/t/ui/../lib/OpenQA/SeleniumTest.pm line 81.
        OpenQA::SeleniumTest::__ANON__(Test::Selenium::Chrome=HASH(0x561c0aeeb4e8), "Error while executing command: isElementDisplayed: stale elem"..., HASH(0x561c0b224910)) called at /usr/lib/perl5/vendor_perl/5.26.1/Selenium/Remote/Driver.pm line 356
        Selenium::Remote::Driver::catch {...} ("Error while executing command: isElementDisplayed: stale elem"...) called at /usr/lib/perl5/vendor_perl/5.26.1/Try/Tiny.pm line 123
        Try::Tiny::try(CODE(0x561c0b2300e8), Try::Tiny::Catch=REF(0x561c0b22a010)) called at /usr/lib/perl5/vendor_perl/5.26.1/Selenium/Remote/Driver.pm line 361
        Selenium::Remote::Driver::__ANON__(CODE(0x561c0aa3e310), Test::Selenium::Chrome=HASH(0x561c0aeeb4e8), HASH(0x561c0b224910)) called at (eval 1584)[/usr/lib/perl5/vendor_perl/5.26.1/Class/Method/Modifiers.pm:89] line 1
        Selenium::Remote::Driver::__ANON__(Test::Selenium::Chrome=HASH(0x561c0aeeb4e8), HASH(0x561c0b224910)) called at (eval 1586)[/usr/lib/perl5/vendor_perl/5.26.1/Class/Method/Modifiers.pm:148] line 2
        Selenium::Remote::Driver::_execute_command(Test::Selenium::Chrome=HASH(0x561c0aeeb4e8), HASH(0x561c0b224910)) called at (eval 1556)[/usr/lib/perl5/vendor_perl/5.26.1/Sub/Quote.pm:3] line 17
        Selenium::Remote::WebElement::_execute_command(Test::Selenium::Remote::WebElement=HASH(0x561c0b2396b0), HASH(0x561c0b224910)) called at /usr/lib/perl5/vendor_perl/5.26.1/Selenium/Remote/WebElement.pm line 322
        Selenium::Remote::WebElement::is_displayed(Test::Selenium::Remote::WebElement=HASH(0x561c0b2396b0)) called at /home/squamata/project/t/ui/../lib/OpenQA/SeleniumTest.pm line 245
        OpenQA::SeleniumTest::element_visible("#flavor_DVD_arch_i586", qr(i586)u) called at t/ui/10-tests_overview.t line 254
        main::__ANON__() called at /usr/lib/perl5/5.26.1/Test/Builder.pm line 309
        eval {...} called at /usr/lib/perl5/5.26.1/Test/Builder.pm line 309
        Test::Builder::subtest(Test::Builder=HASH(0x561bff7ad7f8), "filter for specific archs", CODE(0x561c0b21d3a0)) called at /usr/lib/perl5/5.26.1/Test/More.pm line 807
        Test::More::subtest("filter for specific archs", CODE(0x561c0b21d3a0)) called at t/ui/10-tests_overview.t line 258
        main::__ANON__() called at /usr/lib/perl5/5.26.1/Test/Builder.pm line 309
        eval {...} called at /usr/lib/perl5/5.26.1/Test/Builder.pm line 309
        Test::Builder::subtest(Test::Builder=HASH(0x561bff7ad7f8), "filtering by architecture", CODE(0x561c0b229920)) called at /usr/lib/perl5/5.26.1/Test/More.pm line 807
        Test::More::subtest("filtering by architecture", CODE(0x561c0b229920)) called at t/ui/10-tests_overview.t line 259
[23:22:28] t/ui/10-tests_overview.t ................... 13/? # Tests were run but no plan was declared and done_testing() was not seen.
[23:22:28] t/ui/10-tests_overview.t ................... Dubious, test returned 254 (wstat 65024, 0xfe00)
All 13 subtests passed

So the theory mentioned in this PR's description is maybe still correct but the change is not sufficient. Maybe we can just catch that exception and treat the case when the exception occurs as "element does not exist at all" and continue waiting until it does. I'll come up with another PR tomorrow.

EDIT: This actually failed in a different place than the place this PR tries to fix - but for a similar reason. So maybe it helps to apply a similar approach to other places in this test: #6277

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants