mirror of
				https://github.com/microsoft/playwright.git
				synced 2025-06-26 21:40:17 +00:00 
			
		
		
		
	fix(codgen): assertValue works with disabled select (#31315)
This commit is contained in:
		
							parent
							
								
									ea33137a0e
								
							
						
					
					
						commit
						4089f4593b
					
				| @ -578,8 +578,8 @@ class TextAssertionTool implements RecorderTool { | ||||
| 
 | ||||
|   onPointerUp(event: PointerEvent) { | ||||
|     const target = this._hoverHighlight?.elements[0]; | ||||
|     if (this._kind === 'value' && target && target.nodeName === 'INPUT' && (target as HTMLInputElement).disabled) { | ||||
|       // Click on a disabled input does not produce a "click" event, but we still want
 | ||||
|     if (this._kind === 'value' && target && (target.nodeName === 'INPUT' || target.nodeName === 'SELECT') && (target as HTMLInputElement).disabled) { | ||||
|       // Click on a disabled input (or select) does not produce a "click" event, but we still want
 | ||||
|       // to assert the value.
 | ||||
|       this._commitAssertValue(); | ||||
|     } | ||||
|  | ||||
| @ -631,6 +631,27 @@ await page.GetByLabel("Coun\\"try").ClickAsync();`); | ||||
|     expect.soft(sources2.get('C#')!.text).toContain(`await Expect(page.Locator("#second")).ToHaveValueAsync("bar")`); | ||||
|   }); | ||||
| 
 | ||||
|   test('should assert value on disabled select', async ({ openRecorder, browserName }) => { | ||||
|     const recorder = await openRecorder(); | ||||
| 
 | ||||
|     await recorder.setContentAndWait(` | ||||
|       <select id=first><option value=foo1>Foo1</option><option value=bar1>Bar1</option></select> | ||||
|       <select id=second disabled><option value=foo2>Foo2</option><option value=bar2 selected>Bar2</option></select> | ||||
|     `);
 | ||||
| 
 | ||||
|     await recorder.page.click('x-pw-tool-item.value'); | ||||
|     await recorder.hoverOverElement('#second'); | ||||
|     const [sources2] = await Promise.all([ | ||||
|       recorder.waitForOutput('JavaScript', '#second'), | ||||
|       recorder.trustedClick(), | ||||
|     ]); | ||||
|     expect.soft(sources2.get('JavaScript')!.text).toContain(`await expect(page.locator('#second')).toHaveValue('bar2')`); | ||||
|     expect.soft(sources2.get('Python')!.text).toContain(`expect(page.locator("#second")).to_have_value("bar2")`); | ||||
|     expect.soft(sources2.get('Python Async')!.text).toContain(`await expect(page.locator("#second")).to_have_value("bar2")`); | ||||
|     expect.soft(sources2.get('Java')!.text).toContain(`assertThat(page.locator("#second")).hasValue("bar2")`); | ||||
|     expect.soft(sources2.get('C#')!.text).toContain(`await Expect(page.Locator("#second")).ToHaveValueAsync("bar2")`); | ||||
|   }); | ||||
| 
 | ||||
|   test('should assert visibility', async ({ openRecorder }) => { | ||||
|     const recorder = await openRecorder(); | ||||
| 
 | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 4ydx
						4ydx