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.

Test Automation IDs

See original GitHub issue

As we are trying to roll out end to end testing on our frontend assets using webdriver.io and selenium we find it increasingly challenging to target elements from our underlying UI library, material-ui.

There is no easy single solution to this problem. Adding data-test attributes to all elements would be the optimal solution, with an option to parameterize per component to avoid conflicts.

Please consider automated testing on your next iteration of your awesome library.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:3
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
eps1loncommented, Oct 1, 2018

Following https://material-ui.com/customization/themes/#properties you can already set attributes on a per component basis.

This is currently only missing an option for all components.

Depending on your target you could fake this with a Proxy. Checkout this codesandbox: https://codesandbox.io/s/zp0jrmkox (the interesting part is in withRoot)

This is just something hacked together in a few minutes so use this with caution.

0reactions
oliviertassinaricommented, Oct 3, 2018

< MuiButton > Could directly assign a data-test attribute < IconButton> Could directly assign a data-test attribute <MuiSelect> Had to define MenuProps and SelectDisplayProps to target the two elements

You can use the theme.props.MuiButton['date-test'] = 'MuiButton' feature of Material-UI for that.

Read more comments on GitHub >

github_iconTop Results From Across the Web

ID & Automation ID - Progress Test Studio - Documentation
Static and unique id attribute for the elements in a dynamic application. It is recommended to assign such during the application development process...
Read more >
Why automation attributes are a non-negotiable part of web ...
Test ids work best when they are unique, readable, and concise. It should be unique so the framework doesn't need logic to figure...
Read more >
ID's Required for UI automation in selenium in all html pages
Using ids for element's lookup in automation is generally considered as a best practice. If you use ids your automation tests will become ......
Read more >
5 tips for a stable element ID in Selenium automation - ACCELQ
Element Identification is a crucial step in achieving automated test interaction in Selenium against browser-based applications.
Read more >
Is adding IDs to everything standard practice when using ...
It's not unusual. IDs tend to aid greatly in creating more stable UI tests, since class name changes or other refactoring is less...
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