Skip to content

Webdriverio : touch events#4446

Open
karunkop wants to merge 7 commits into
cybersemics:mainfrom
karunkop:ios-toolbar-color-swatches
Open

Webdriverio : touch events#4446
karunkop wants to merge 7 commits into
cybersemics:mainfrom
karunkop:ios-toolbar-color-swatches

Conversation

@karunkop

Copy link
Copy Markdown
Collaborator

@karunkop karunkop self-assigned this Jun 24, 2026
@karunkop karunkop requested a review from raineorshine June 24, 2026 12:06
Comment thread src/e2e/iOS/__tests__/color.ts Outdated
Comment thread src/e2e/iOS/__tests__/color.ts Outdated
Comment thread src/e2e/iOS/helpers/gesture.ts Outdated

await browser.execute(() => {
const active = document.activeElement
if (active instanceof HTMLElement) active.blur()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What happens on a physical iPhone when the keyboard is closed by tapping Done? Is document.activeElement already cleared?

We want to make sure our tests don't deviate from actual behavior.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

What do you mean when you say we don't want tests to deviate from actual behavior in this case?

@raineorshine raineorshine Jun 30, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I mean that we don't want integration tests to do anything that the user can't do with their device. The user closes the keyboard by tapping the Done button and they don't have access to blur(). So why is the test doing something "special" that the user can't do?

We don't want to give integration tests special powers. Then we end up having test coverage of those special powers instead of test coverage over the actual behavior that the user is capable of.

@github-actions

Copy link
Copy Markdown
Contributor

Vercel preview: https://em-772c99ts2-cybersemics.vercel.app

Comment thread src/e2e/iOS/__tests__/color.ts Outdated
await tapElementBySelector('[data-testid="toolbar-icon"][aria-label="Text Color"]')
await tapElementBySelector('[aria-label="background color swatches"] [aria-label="red"]')
await tapElementBySelector('[aria-label="text color swatches"] [aria-label="red"]')
await tap('[data-testid="toolbar-icon"][aria-label="Text Color"]', { horizontalTapLine: 'center' })

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why doesn't the default horizontalTapLine work?

Color tests should not have to worry about where to tap the button.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

The default value for horizontalTapLine is left. However, for toolbar icon buttons, calculating the tap coordinates from the left edge does not consistently target the button accurately. To address this, the center option was introduced, which calculates the tap coordinates at the horizontal center of the button, resulting in more reliable and accurate tap interactions.

Color tests should not have to worry about where to tap the button.

You're right about this part. I was thinking if we want to keep this functionality within tap, we could introduce a new option that indicates the target is a toolbar icon, allowing the tap coordinates to be calculated accordingly.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What about making center the global default? This more closely matches user semantics. If you tell a user to tap on a button, they're more likely to tap somewhere near the center than tap the exact edge.

The question is whether that will break other tests. If other tests depend on the tap occurring on the left edge (for example to set the cursor at the beginning of the thought), then arguably those tests should make that dependency explicit by specifying horizontalTapLine.

Please try to avoid phrases like "reliable" or "accurate" without going into the details. We're dealing with exact pixels. The button is rendered in the same place every time. You should understand exactly why left edge tap breaks on toolbar buttons. Only then can we determine the best solution. If we lack understanding, then our solution may be based on false assumptions and we may fail to apply the lesson properly in future scenarios.

I was thinking if we want to keep this functionality within tap, we could introduce a new option that indicates the target is a toolbar icon, allowing the tap coordinates to be calculated accordingly.

tap is a general function. General functions should not be concerned with specific usage. Your gut feeling should tell you that parameterizing general functions with context-dependent behavior is a bad idea. At least horizontalTapLine is general.

@raineorshine

Copy link
Copy Markdown
Contributor

@karunkop Is this ready for review or are you still working on it? Thanks!

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.

Find out if webdriverio can trigger touch events

2 participants