Skip to content

Conversation

sakhisheikh
Copy link
Contributor

@sakhisheikh sakhisheikh commented Oct 9, 2025

Problem: It was only possible to navigate to next element

Solution

  • Made direction as configurable argument in the method call deviceInspectorMoveWithOptions
  • Move() is implemented that returns PlatformElementValue_V1 unique base64 identifier which could potentially be used to tap on element.
  • Added ReceiveMethodCallWithTimeout because ReceiveMethodCall expects the dtx message to be always arrived, reading channel inside ReceiveMethodCall becomes blocking forever

Reproducible Steps for blocking ReceiveMethodCall:

  • Enable Ax Inspector on home screen
  • Navigate to Previous element, ReceiveMethodCall will be blocked because no message is received on the reader channel.
  • hostInspectorCurrentElementChanged doesn't receive dtx message because AX inspector doesn't find an element in accessibility tree.

Comment on lines 19 to 25
// Direction represents navigation direction values used by AX service
const (
DirectionPrevious int32 = 3
DirectionNext int32 = 4
DirectionFirst int32 = 5
DirectionLast int32 = 6
)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets use a custom type to represent the direction to make it a bit more clear that Move doesn't take any random integer valuye

Suggested change
// Direction represents navigation direction values used by AX service
const (
DirectionPrevious int32 = 3
DirectionNext int32 = 4
DirectionFirst int32 = 5
DirectionLast int32 = 6
)
type MoveDirection int32
// Direction represents navigation direction values used by AX service
const (
DirectionPrevious MoveDirection(3)
DirectionNext MoveDirection(4)
DirectionFirst MoveDirection(5)
DirectionLast MoveDirection(6)
)

// GetElement moves the green selection rectangle one element further
func (a ControlInterface) GetElement() {
// Move navigates focus using the given direction and returns selected fields as a map.
func (a ControlInterface) Move(direction int32) map[string]interface{} {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are the contents of the map that we return here? It would be nice to return a struct here to make that less error prone

msg, err := a.channel.ReceiveMethodCallWithTimeout("hostInspectorCurrentElementChanged:", timeout)
if err != nil {
log.Errorf("Timeout waiting for hostInspectorCurrentElementChanged (timeout: %v): %v", timeout, err)
panic(fmt.Sprintf("Timeout waiting for hostInspectorCurrentElementChanged: %s", err))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please don't use panics. And why a 2s timeout, is this unreliable?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just to add to the timeout. I think that's a case where context.Context could/should be used, and then it's up to the caller how long that context is valid, and then how long we would wait at most

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah i return an error now. Yeah I would reduce the timeout. It was arbitrary

@sakhisheikh sakhisheikh requested a review from dmissmann October 10, 2025 13:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants