Open CamJN opened 6 years ago
I'm assuming you only came to vent, and hope it made you feel better, but there's nothing here that would encourage anyone to try to help you.
👋 Thanks for using Material-UI!
We use the issue tracker exclusively for bug reports and feature requests, however, this issue appears to be a support request or question. Please ask on StackOverflow where the community will do their best to help. There is a "material-ui" tag that you can use to tag your question.
If you would like to link from here to your question on SO, it will help others find it. If your issues is confirmed as a bug, you are welcome to reopen the issue using the issue template.
In case anyone is looking at this in 2024, this bug report may have come across as abrasive, but speaking as a developer converting frontend code to use Material-UI controls with a ton of Capybara tests, I completely understand the frustration here.
It's a horrible experience. The controls are literally on the screen, and capybara can't find them.
It took me a while to figure this out. The problem is that the opacity of input
controls within Material-UI rendered controls is 0, making them invisible to Capybara.
My solution is to have a SASS file included when in the test environment containing this:
.MuiCheckbox-root, .MuiFormControlLabel-root
input
opacity: 0.00001 !important
I'm still refining this, but this generally seems to work. I think Material-UI could have a non-zero opacity for native controls out of the box and it would save much aggravation.
@scottschafer Thanks for some actionable insight. I can't promise that it will get fixed any time soon (five years with no upvotes! 😅) but at least it's on our radar.
You bet. What I ended up doing in addition to tweaking the CSS slightly when in test mode was to write some wrapper classes around
It is literally impossible to test material ui using capybara+selenium-webdriver
Expected Behavior
This library should not use elements so wrongly that it is impossible to test projects that use it with standard automated tools.
Current Behavior
Material-ui currently abuses elements so thoroughly that there is currently no way to test pages that use material-ui using capybara/selenium-webdriver.
Steps to Reproduce
codesandbox.io can't handle ruby deps, so no point in setting anything up there. Link: I'll fill this in when i have a second
Selenium::WebDriver::Error::UnknownError: unknown error: option element is not in a select
Context
I'm trying to write tests for my project, using capybara & a headless browser driven by selenium-webdriver.
Your Environment