Skip to content

Commit d4393b4

Browse files
committed
more tab tests
1 parent f315363 commit d4393b4

1 file changed

Lines changed: 94 additions & 0 deletions

File tree

  • core/src/jvmTest/kotlin/dev/kdriver/core/tab

core/src/jvmTest/kotlin/dev/kdriver/core/tab/TabTest.kt

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import dev.kdriver.cdp.domain.network
66
import dev.kdriver.core.browser.createBrowser
77
import dev.kdriver.core.connection.addHandler
88
import dev.kdriver.core.connection.send
9+
import dev.kdriver.core.dom.NodeOrElement
910
import dev.kdriver.core.exceptions.EvaluateException
1011
import dev.kdriver.core.exceptions.TimeoutWaitingForElementException
1112
import dev.kdriver.core.sampleFile
@@ -411,6 +412,18 @@ class TabTest {
411412
browser.stop()
412413
}
413414

415+
@Test
416+
fun testGetAllUrlsRelative() = runBlocking {
417+
val browser = createBrowser(this, headless = true, sandbox = false)
418+
val tab = browser.get(sampleFile("profile.html"))
419+
tab.waitForReadyState(ReadyState.COMPLETE)
420+
421+
val urls = tab.getAllUrls(absolute = false)
422+
assertNotNull(urls)
423+
424+
browser.stop()
425+
}
426+
414427
@Test
415428
fun testGetAllLinkedSources() = runBlocking {
416429
val browser = createBrowser(this, headless = true, sandbox = false)
@@ -423,4 +436,85 @@ class TabTest {
423436
browser.stop()
424437
}
425438

439+
// Mouse Operation Tests
440+
441+
@Test
442+
fun testMouseMove() = runBlocking {
443+
val browser = createBrowser(this, headless = true, sandbox = false)
444+
val tab = browser.get(sampleFile("groceries.html"))
445+
446+
tab.mouseMove(100.0, 100.0)
447+
448+
browser.stop()
449+
}
450+
451+
@Test
452+
fun testMouseClick() = runBlocking {
453+
val browser = createBrowser(this, headless = true, sandbox = false)
454+
val tab = browser.get(sampleFile("groceries.html"))
455+
456+
tab.mouseClick(100.0, 100.0)
457+
458+
browser.stop()
459+
}
460+
461+
// Advanced Selection Tests
462+
463+
@Test
464+
fun testSelectWithTimeout() = runBlocking {
465+
val browser = createBrowser(this, headless = true, sandbox = false)
466+
val tab = browser.get(sampleFile("groceries.html"))
467+
468+
val element = tab.select("li", timeout = 5000)
469+
assertNotNull(element)
470+
471+
browser.stop()
472+
}
473+
474+
@Test
475+
fun testFindAllByText() = runBlocking {
476+
val browser = createBrowser(this, headless = true, sandbox = false)
477+
val tab = browser.get(sampleFile("groceries.html"))
478+
479+
val elements = tab.findAll("Apples")
480+
assertTrue(elements.isNotEmpty())
481+
482+
browser.stop()
483+
}
484+
485+
@Test
486+
fun testQuerySelectorWithNode() = runBlocking {
487+
val browser = createBrowser(this, headless = true, sandbox = false)
488+
val tab = browser.get(sampleFile("groceries.html"))
489+
490+
val list = tab.select("ul")
491+
val item = tab.querySelector("li", NodeOrElement.WrappedElement(list))
492+
assertNotNull(item)
493+
494+
browser.stop()
495+
}
496+
497+
@Test
498+
fun testQuerySelectorAllWithNode() = runBlocking {
499+
val browser = createBrowser(this, headless = true, sandbox = false)
500+
val tab = browser.get(sampleFile("groceries.html"))
501+
502+
val list = tab.select("ul")
503+
val items = tab.querySelectorAll("li", NodeOrElement.WrappedElement(list))
504+
assertTrue(items.isNotEmpty())
505+
506+
browser.stop()
507+
}
508+
509+
@Test
510+
fun testSelectAll() = runBlocking {
511+
val browser = createBrowser(this, headless = true, sandbox = false)
512+
val tab = browser.get(sampleFile("groceries.html"))
513+
514+
val elements = tab.selectAll("li")
515+
assertTrue(elements.isNotEmpty())
516+
517+
browser.stop()
518+
}
519+
426520
}

0 commit comments

Comments
 (0)