Skip to content

Commit 6088fe2

Browse files
committed
test: added iframe test
1 parent 859f06c commit 6088fe2

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

‎test/iframe.test.ts‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { getByTestIdSelector, Ivya } from '../src'
2+
import { expect, test } from 'vitest'
3+
4+
test('locates element inside iframe', async () => {
5+
const button = document.createElement('button')
6+
button.textContent = 'Click me'
7+
8+
const iframe = document.createElement('iframe')
9+
iframe.setAttribute('data-testid', 'test-iframe')
10+
iframe.srcdoc = button.outerHTML
11+
document.body.appendChild(iframe)
12+
13+
const ivya = Ivya.create({
14+
browser: 'chromium',
15+
})
16+
17+
// wait for iframe to load
18+
await new Promise((resolve) => (iframe.onload = resolve))
19+
20+
const iframeSelector = getByTestIdSelector('data-testid', 'test-iframe')
21+
expect(ivya.queryLocatorSelector(iframeSelector)).toBe(iframe)
22+
23+
expect(
24+
ivya.queryLocatorSelector('iframe >> internal:control=enter-frame >> button')
25+
).toEqual(button)
26+
})

0 commit comments

Comments
 (0)