Carousel implementation does not pass WCAG2a using Axe tests in Cypress
See original GitHub issuepure-react-carousel
version: ^1.27.5react
version: ^16.8browser
used: Chromenode
version: v12.18.4
Relevant code or config:
<div
data-testid="spotlights"
style={{ height: '100%', position: 'relative' }}
role="region"
aria-label="Spotlights carousel"
>
<CarouselProvider
visibleSlides={1}
totalSlides={totalSlides}
step={1}
naturalSlideWidth={1967}
naturalSlideHeight={721}
isPlaying={!account}
interval={10000}
style={{ height: '100%' }}
>
{totalSlides > 1 && (
<div
style={{
width: 36,
height: '100%',
position: 'absolute',
top: 4,
left: 4,
zIndex: 101,
}}
>
<ButtonBack>
<ChevronLeftIcon />
</ButtonBack>
</div>
)}
{totalSlides > 1 && (
<div
style={{
width: 36,
height: '100%',
position: 'absolute',
top: 4,
right: 0,
zIndex: 101,
}}
>
<ButtonNext>
<ChevronRightIcon />
</ButtonNext>
</div>
)}
{totalSlides > 1 && (
<div
style={{
width: 36,
position: 'absolute',
top: 4,
left: 32,
zIndex: 101,
}}
>
<ButtonPlay childrenPlaying={<PauseIcon />} childrenPaused={<PlayArrowIcon />} />
</div>
)}
{totalSlides > 1 && (
<div
style={{
width: 200,
marginLeft: -100,
position: 'absolute',
top: 0,
left: '50%',
zIndex: 101,
textAlign: 'center',
}}
>
<DotGroup />
</div>
)}
<div
style={{
zIndex: 99,
}}
>
<Slider>
{slides.map((item, index) => {
return (
<Slide index={item.index} key={index}>
<a href={item.link} aria-label={item.aria}>
<Image
src={item.src}
alt={item.alt}
style={{ width: '100%' }}
aria-label={item.aria}
/>
</a>
</Slide>
);
})}
</Slider>
</div>
</CarouselProvider>
</div>
What you did:
Running Axe in Cypress tests for WCAG compliance.
What happened:
failureSummary: "Fix any of the following:↵ aria-label attribute does not exist or is empty↵ aria-labelledby attribute does not exist, references elements that do not exist or references elements that are empty↵ Element has no title attribute or the title attribute is empty"
html: "<div class="horizontalSlider___281Ls carousel__slider carousel__slider--horizontal" aria-live="polite" tabindex="0" role="listbox">"
impact: "serious"
failureSummary: "Fix all of the following:↵ List element has direct children that are not allowed inside <li> elements"
html: "<ul class="sliderTray___-vHFQ sliderAnimation___300FY carousel__slider-tray carousel__slider-tray--horizontal" style="width: 400%; transform: translateX(0%) translateX(0px); flex-direction: row;">"
impact: "serious"
Problem description:
Does not pass WCAG2a tests at the moment.
Suggested solution:
Fixes are explained in the errors above.
Can you help us fix this issue by submitting a pull request?
TBH - Have never tried - but happy to when I get some time.
Issue Analytics
- State:
- Created 3 years ago
- Comments:9 (2 by maintainers)
Top Results From Across the Web
Issues · component-driven/cypress-axe - GitHub
Resolved path for axe-core/axe.min.js is incorrect if the Cypress Config is in a sub-directory when using Cypress v10+.
Read more >How to test for accessibility with Cypress - Deque Systems
In this article, we're going to discuss how to: Create test cases in Cypress. Integrate and use axe to check for accessibility violations....
Read more >Implement A Test That Finds A Particular Slide In A Carousel
This test shows how to check if an element is visible, and if not, click on the "Next" button in the carousel. The...
Read more >A Complete Guide To Accessibility Tooling
This time we look into different kinds of tools to help you streamline your accessibility testing process. Don't miss the next one.
Read more >How to test carousel with image in Cypress? - Stack Overflow
I would like to check whether the carousel is displayed on the page and whether the active image has the correct class. I...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The first violation can be solved by passing your own
aria-label
prop toSlider
The second violation is “List element has direct children with a role that is not allowed: option”. Apparently putting a role of
option
on anli
element is a no no. This can be solved by changing theul
andli
tags to a different element.Should probably be fixed up the code though… Also this is not a Cypress only issue, I also saw these violations surfaced in our Storybook.
This issue has been automatically closed becuase it has not had recent activity.