@@ -89,6 +89,42 @@ describe('StringifyExtension', () => {
8989 expect ( writer . toString ( ) ) . toBe ( 'await browser.$("=Guides").setValue("webdriverio")\n' )
9090 } )
9191
92+ it ( 'should fetch by text' , async ( ) => {
93+ const ext = new StringifyExtension ( )
94+ const step = {
95+ type : 'change' as const ,
96+ value : 'webdriverio' ,
97+ selectors : [ [
98+ 'aria/Flat White $18.00'
99+ ] , [
100+ '#app > div:nth-child(4) > ul > li:nth-child(5) > h4'
101+ ] ] ,
102+ target : 'main' ,
103+ }
104+ const flow = { title : 'change step' , steps : [ step ] }
105+ const writer = new InMemoryLineWriter ( ' ' )
106+ await ext . stringifyStep ( writer , step , flow )
107+ expect ( writer . toString ( ) ) . toBe ( 'await browser.$("h4=Flat White $18.00").setValue("webdriverio")\n' )
108+ } )
109+
110+ it ( 'should fetch by text with pseudo selector' , async ( ) => {
111+ const ext = new StringifyExtension ( )
112+ const step = {
113+ type : 'change' as const ,
114+ value : 'webdriverio' ,
115+ selectors : [ [
116+ 'aria/Yes'
117+ ] , [
118+ '[data-cy=add-to-cart-modal] > form > button:nth-child(1)'
119+ ] ] ,
120+ target : 'main' ,
121+ }
122+ const flow = { title : 'change step' , steps : [ step ] }
123+ const writer = new InMemoryLineWriter ( ' ' )
124+ await ext . stringifyStep ( writer , step , flow )
125+ expect ( writer . toString ( ) ) . toBe ( 'await browser.$("button=Yes").setValue("webdriverio")\n' )
126+ } )
127+
92128 it ( 'should correctly exports keyDown step' , async ( ) => {
93129 const ext = new StringifyExtension ( )
94130 const step = {
0 commit comments