question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

PF4 testability for integration UI tests

See original GitHub issue

Hi, we’re facing some issues with writing integration UI tests (tests that use real browsers) for our PF4/React based application. The problem is in the selectors. We currently need to strongly rely on CSS classes and element sequence so most of our selectors now look like this:

*[@id='main_react_container']//header/div[@class='pf-l-toolbar__item pf-m-mobile']/div[contains(@class, 'pf-c-dropdown')]/ul/nav/ul/li

This is quite unusable for us in long term. All it takes to break a test will be just minor change to the UI, like adding a button or a class name change with a PF4 update. Also writing the selectors this way is very time consuming as it requires deep DOM investigation.

We’d like to use the ID attributes to select elements as the most robust way. However, the issue with this is that even though IDs are present on most of the elements, they’re generated and therefore dynamic.

This issue doesn’t seem to affect only a specific component but rather petternfly-react in general.

Are we missing something? Can we somehow force the components to use static IDs?

We’re using Selenium Webdriver and the testsuite is Java.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
dgutridecommented, Oct 16, 2019

Hi @vmuzikar - we directly support using OUIA tags with our components to support automated test suites. You can read more about those in this issue on the forum: https://forum.patternfly.org/t/open-web-ui-design-specification-for-enabling-automation-ouia/154

and this closed issue that resulted in a way to turn OUIA tags on for discoverability when running automated tests - https://github.com/patternfly/patternfly-react/issues/2303. We chose not to include them by default with the components in order not to add bloat to the DOM when reusing components.

Defining selectors the way you have them is problematic since structure can change periodically and using classes instead of definitive id’s is not great (as you mentioned). @quarckster has done quite a bit of the work contributing to these components as well.

All that being said - we also do support using id’s on the components. I’d recommend enabling OUIA and using those attributes to select after you get to a parent component with an id.

0reactions
vmuzikarcommented, Nov 25, 2019

@tlabaj Thanks for the confirmation!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unit Tests, UI Tests, Integration Tests & End-To-End Tests
Interaction Tests help us to ensure our Application Interaction works by simulating them using native or third-party tools. UI Tests. UI Testing ......
Read more >
How to use automated testing in Unity in a productive way ...
Integration tests should help to solidify contracts between systems and nail down invariants/assumptions or even reproduce complex bug cases. I' ...
Read more >
Testable Frontend: The Good, The Bad And The Flaky
The most reliable way to test contextual components is within their true context — the app, as seen by the user. Test those...
Read more >
The Practical Test Pyramid - Martin Fowler
The Practical Test Pyramid. The "Test Pyramid" is a metaphor that tells us to group software tests into buckets of different granularity.
Read more >
What is testability in the software development lifecycle? - Xray
The main reason for UI test flakiness for the tester is fragile locators and never-ending refactoring of the frontend part. Testability Tip. The ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found