IJPL-239037 UiInfrastructureTest.occurence navigation test is failing occasionally

(cherry picked from commit 7d8aeda3548a62fa1bad620947003ff93bdb7104)

IJ-CR-196535

GitOrigin-RevId: d62bb265eebeee524122804211eddbb5ffe9901a
This commit is contained in:
Dmitry Batrak
2026-03-24 17:43:24 +00:00
committed by intellij-monorepo-bot
parent 99408f596e
commit a69259f959
@@ -5,6 +5,9 @@ import com.intellij.openapi.util.text.StringUtil
import com.intellij.ui.SimpleColoredComponent
import com.intellij.util.ui.UIUtil
import java.awt.Component
import java.awt.Robot
import java.awt.event.InputEvent
import javax.swing.JFrame
import javax.swing.JLabel
import javax.swing.text.JTextComponent
@@ -35,3 +38,15 @@ private fun Component.getText() : String? {
}
}
}
fun JFrame.focusByClick() {
val frameBounds = bounds
val targetX = frameBounds.x + frameBounds.width / 2
val taretY = frameBounds.y + 1 // top center point, right below the frame edge
with(Robot()) {
autoDelay = 50
mouseMove(targetX, taretY)
mousePress(InputEvent.BUTTON1_DOWN_MASK)
mouseRelease(InputEvent.BUTTON1_DOWN_MASK)
}
}