Skip to content

Commit

Permalink
Simplify text selection in "select event update the txt"
Browse files Browse the repository at this point in the history
This approach also make it more cross-platform resistant
  • Loading branch information
Schahen committed Jun 30, 2021
1 parent b1d8682 commit c0bba88
Showing 1 changed file with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@ import org.openqa.selenium.WebDriver

class EventTests : BaseIntegrationTests() {

companion object {
private val COMMAND_CROSS_PLATFORM = System.getProperty("os.name").lowercase().let { osName ->
when {
osName.contains("mac os") -> Keys.COMMAND
else -> Keys.CONTROL
}
}
}

@ResolveDrivers
fun `double click updates text`(driver: WebDriver) {
driver.openTestPage("doubleClickUpdatesText")
Expand Down Expand Up @@ -105,14 +114,8 @@ class EventTests : BaseIntegrationTests() {

val selectableText = driver.findElement(By.id("selectableText"))

val action = Actions(driver)

action.moveToElement(selectableText,3,3)
.click().keyDown(Keys.SHIFT)
.moveToElement(selectableText,200, 0)
.click().keyUp(Keys.SHIFT)
.build()
.perform()
val selectAll = Keys.chord(COMMAND_CROSS_PLATFORM, "a")
selectableText.sendKeys(selectAll)

driver.waitTextToBe(value = "Text Selected")
}
Expand Down

0 comments on commit c0bba88

Please sign in to comment.