File tree Expand file tree Collapse file tree 2 files changed +54
-0
lines changed 
packages/devtools/src/commands Expand file tree Collapse file tree 2 files changed +54
-0
lines changed Original file line number Diff line number Diff line change 1+ /** 
2+  * Get the computed WAI-ARIA label of an element. 
3+  * 
4+  * @alias  browser.getElementComputedLabel 
5+  * @see  https://w3c.github.io/webdriver/#get-computed-label 
6+  * @param  {string } elementId  the id of an element returned in a previous call to Find Element(s) 
7+  * @return  {string }           The result of computing the WAI-ARIA label of element. 
8+  */ 
9+ 
10+ import  type  DevToolsDriver  from  '../devtoolsdriver' 
11+ 
12+ export  default  async  function  getElementComputedLabel  ( 
13+     this : DevToolsDriver , 
14+     {  elementId } : {  elementId : string  } 
15+ )  { 
16+     const  page  =  this . getPageHandle ( true ) 
17+     const  elementHandle  =  await  this . elementStore . get ( elementId ) 
18+     const  snapshot  =  await  page . accessibility . snapshot ( { 
19+         root : elementHandle 
20+     } ) 
21+ 
22+     if  ( ! snapshot )  { 
23+         return  '' 
24+     } 
25+ 
26+     return  snapshot . name 
27+ } 
Original file line number Diff line number Diff line change 1+ /** 
2+  * Get the computed WAI-ARIA role of an element. 
3+  * 
4+  * @alias  browser.getElementComputedRole 
5+  * @see  https://w3c.github.io/webdriver/#get-computed-role 
6+  * @param  {string } elementId  the id of an element returned in a previous call to Find Element(s) 
7+  * @return  {string }           The result of computing the WAI-ARIA role of element. 
8+  */ 
9+ 
10+ import  type  DevToolsDriver  from  '../devtoolsdriver' 
11+ 
12+ export  default  async  function  getElementComputedRole  ( 
13+     this : DevToolsDriver , 
14+     {  elementId } : {  elementId : string  } 
15+ )  { 
16+     const  page  =  this . getPageHandle ( true ) 
17+     const  elementHandle  =  await  this . elementStore . get ( elementId ) 
18+     const  snapshot  =  await  page . accessibility . snapshot ( { 
19+         root : elementHandle 
20+     } ) 
21+ 
22+     if  ( ! snapshot )  { 
23+         return  'Ignored' 
24+     } 
25+ 
26+     return  snapshot . role 
27+ } 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments