File tree 1 file changed +22
-1
lines changed
1 file changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -585,6 +585,7 @@ getByRole(
585
585
hidden?: boolean = true ,
586
586
name?: TextMatch ,
587
587
normalizer?: NormalizerFn ,
588
+ selected?: boolean ,
588
589
}): HTMLElement
589
590
```
590
591
@@ -637,7 +638,27 @@ case. For example in
637
638
assertions about the ` Open dialog ` -button you would need to use
638
639
` getAllByRole('button', { hidden: true }) ` .
639
640
640
- The default value can [ be configured] ( api-configuration#configuration ) .
641
+ The default value for ` hidden ` can [ be configured] ( api-configuration#configuration ) .
642
+
643
+ Certain roles can have a selected state. You can filter the
644
+ returned elements that by their selected state
645
+ by setting ` selected: true ` or ` selected: false ` .
646
+
647
+ For example in
648
+
649
+ ``` html
650
+ <body >
651
+ <div role =" tablist" >
652
+ <button role =" tab" aria-selected =" true" >Native</button >
653
+ <button role =" tab" aria-selected =" false" >React</button >
654
+ <button role =" tab" aria-selected =" false" >Cypress</button >
655
+ </div >
656
+ </body >
657
+ ```
658
+
659
+ you can get the "Native"-tab by calling ` getByRole('tab', { selected: true }) ` .
660
+ To learn more about the selected state and which elements can
661
+ have this state see [ ARIA ` aria-selected ` ] ( https://www.w3.org/TR/wai-aria-1.2/#aria-selected ) .
641
662
642
663
``` html
643
664
<div role =" dialog" >...</div >
You can’t perform that action at this time.
0 commit comments