[tests] KTNB-1296 fix selectItem() in ComboBoxActionButton

repeate() doesn't help when a UiElement is not found

GitOrigin-RevId: c8632e18c5991df1121e4c561de33aba9a67f822
This commit is contained in:
Ilya.Komolkin
2026-01-14 10:31:26 +00:00
committed by intellij-monorepo-bot
parent 6097eb7fb1
commit 8e77f9ffe3
@@ -5,6 +5,7 @@ import com.intellij.driver.sdk.ui.components.UiComponent
import com.intellij.driver.sdk.ui.components.common.ideFrame
import com.intellij.driver.sdk.ui.components.elements.list
import com.intellij.driver.sdk.ui.ui
import com.intellij.driver.sdk.withRetries
/**
* Represents the UI component for Kotlin-specific toolbar actions
@@ -31,15 +32,13 @@ class ComboBoxActionButton(data: ComponentData) : UiComponent(data) {
// it looks like due to some race condition,
// sometimes the combobox is not updated after the mode change, so we need to retry a few times
val attemptCount = 5
repeat(times = attemptCount) {
if (getAllTexts().any { it.text == itemText }) return
withRetries(times = attemptCount) {
if (getAllTexts().any { it.text == itemText }) return@withRetries
click()
val dropdown = driver.ui.ideFrame().list { byClass("MyList") }
dropdown.clickItem(itemText = itemText)
}
if (getAllTexts().none { it.text == itemText }) {
error("Failed to select item '$itemText' after $attemptCount attempts")
}
waitOneText(itemText, "Failed to select item '$itemText' after $attemptCount attempts")
}
}