Skip to content

feat: add longpress logic#13888

Merged
christian-bromann merged 2 commits intomainfrom
ws/add-longpress-logic
Nov 20, 2024
Merged

feat: add longpress logic#13888
christian-bromann merged 2 commits intomainfrom
ws/add-longpress-logic

Conversation

@wswebcreation
Copy link
Member

This PR adds duration to the click command so it can be used for a longPress on mobile.

It can be used like this

    it('should be able to open the contacts menu on iOS by executing a longPress', async () => {
        const contacts = await $('~Contacts')
        // opens the Contacts menu on iOS where you can quickly create
        // a new contact, edit your home screen, or remove the app
        await contacts.click({ duration: 2000 })
    })

Proposed changes

Types of changes

  • Polish (an improvement for an existing feature)
  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update (improvements to the project's docs)
  • Specification changes (updates to WebDriver command specifications)
  • Internal updates (everything related to internal scripts, governance documentation and CI files)

Checklist

  • I have read the CONTRIBUTING doc
  • I have added tests that prove my fix is effective or that my feature works
  • I have added the necessary documentation (if appropriate)
  • I have added proper type definitions for new commands (if appropriate)

Backport Request

//: # (The current main branch is the development branch for WebdriverIO v9. If your change should be released to the current major version of WebdriverIO (v8), please raise another PR with the same changes against the v8 branch.)

  • This change is solely for v9 and doesn't need to be back-ported
  • Back-ported PR at #XXXXX

Further comments

Reviewers: @webdriverio/project-committers

- add docs
- add ut's
@wswebcreation
Copy link
Member Author

@christian-bromann and @erwinheitzman ,

This PR is the preparation for adding a "pseudo" mobile command called longPress which will be based on the click

@pkg-pr-new
Copy link

pkg-pr-new bot commented Nov 17, 2024

Open in Stackblitz

eslint-plugin-wdio

pnpm add https://pkg.pr.new/webdriverio/webdriverio/eslint-plugin-wdio@13888

@wdio/allure-reporter

pnpm add https://pkg.pr.new/webdriverio/webdriverio/@wdio/allure-reporter@13888

@wdio/browser-runner

pnpm add https://pkg.pr.new/webdriverio/webdriverio/@wdio/browser-runner@13888

@wdio/appium-service

pnpm add https://pkg.pr.new/webdriverio/webdriverio/@wdio/appium-service@13888

@wdio/browserstack-service

pnpm add https://pkg.pr.new/webdriverio/webdriverio/@wdio/browserstack-service@13888

@wdio/cli

pnpm add https://pkg.pr.new/webdriverio/webdriverio/@wdio/cli@13888

@wdio/concise-reporter

pnpm add https://pkg.pr.new/webdriverio/webdriverio/@wdio/concise-reporter@13888

@wdio/config

pnpm add https://pkg.pr.new/webdriverio/webdriverio/@wdio/config@13888

@wdio/cucumber-framework

pnpm add https://pkg.pr.new/webdriverio/webdriverio/@wdio/cucumber-framework@13888

@wdio/dot-reporter

pnpm add https://pkg.pr.new/webdriverio/webdriverio/@wdio/dot-reporter@13888

@wdio/firefox-profile-service

pnpm add https://pkg.pr.new/webdriverio/webdriverio/@wdio/firefox-profile-service@13888

@wdio/globals

pnpm add https://pkg.pr.new/webdriverio/webdriverio/@wdio/globals@13888

@wdio/jasmine-framework

pnpm add https://pkg.pr.new/webdriverio/webdriverio/@wdio/jasmine-framework@13888

@wdio/json-reporter

pnpm add https://pkg.pr.new/webdriverio/webdriverio/@wdio/json-reporter@13888

@wdio/junit-reporter

pnpm add https://pkg.pr.new/webdriverio/webdriverio/@wdio/junit-reporter@13888

@wdio/lighthouse-service

pnpm add https://pkg.pr.new/webdriverio/webdriverio/@wdio/lighthouse-service@13888

@wdio/local-runner

pnpm add https://pkg.pr.new/webdriverio/webdriverio/@wdio/local-runner@13888

@wdio/logger

pnpm add https://pkg.pr.new/webdriverio/webdriverio/@wdio/logger@13888

@wdio/mocha-framework

pnpm add https://pkg.pr.new/webdriverio/webdriverio/@wdio/mocha-framework@13888

@wdio/protocols

pnpm add https://pkg.pr.new/webdriverio/webdriverio/@wdio/protocols@13888

@wdio/repl

pnpm add https://pkg.pr.new/webdriverio/webdriverio/@wdio/repl@13888

@wdio/reporter

pnpm add https://pkg.pr.new/webdriverio/webdriverio/@wdio/reporter@13888

@wdio/runner

pnpm add https://pkg.pr.new/webdriverio/webdriverio/@wdio/runner@13888

@wdio/sauce-service

pnpm add https://pkg.pr.new/webdriverio/webdriverio/@wdio/sauce-service@13888

@wdio/shared-store-service

pnpm add https://pkg.pr.new/webdriverio/webdriverio/@wdio/shared-store-service@13888

@wdio/smoke-test-cjs-service

pnpm add https://pkg.pr.new/webdriverio/webdriverio/@wdio/smoke-test-cjs-service@13888

@wdio/smoke-test-reporter

pnpm add https://pkg.pr.new/webdriverio/webdriverio/@wdio/smoke-test-reporter@13888

@wdio/smoke-test-service

pnpm add https://pkg.pr.new/webdriverio/webdriverio/@wdio/smoke-test-service@13888

@wdio/spec-reporter

pnpm add https://pkg.pr.new/webdriverio/webdriverio/@wdio/spec-reporter@13888

@wdio/static-server-service

pnpm add https://pkg.pr.new/webdriverio/webdriverio/@wdio/static-server-service@13888

@wdio/sumologic-reporter

pnpm add https://pkg.pr.new/webdriverio/webdriverio/@wdio/sumologic-reporter@13888

@wdio/testingbot-service

pnpm add https://pkg.pr.new/webdriverio/webdriverio/@wdio/testingbot-service@13888

@wdio/types

pnpm add https://pkg.pr.new/webdriverio/webdriverio/@wdio/types@13888

@wdio/utils

pnpm add https://pkg.pr.new/webdriverio/webdriverio/@wdio/utils@13888

@wdio/webdriver-mock-service

pnpm add https://pkg.pr.new/webdriverio/webdriverio/@wdio/webdriver-mock-service@13888

webdriver

pnpm add https://pkg.pr.new/webdriverio/webdriverio/webdriver@13888

webdriverio

pnpm add https://pkg.pr.new/webdriverio/webdriverio@13888

commit: 26bcde9

Copy link
Member

@erwinheitzman erwinheitzman left a comment

Choose a reason for hiding this comment

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

Got some small comments but looks good overall 👌
Great work @wswebcreation!

try {
return await element.elementClick(element.elementId)
} catch (error) {
// We will never reach this code in the case of a mobile app, the implicitWait will wait for the element but will throw
Copy link
Member

Choose a reason for hiding this comment

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

Let's add a check for mobile and assign the never type to it so that it is clear this code should never be reached in this particular scenario

Copy link
Member Author

Choose a reason for hiding this comment

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

Not sure if I understand what you mean here, can you give some more context?

Copy link
Member

Choose a reason for hiding this comment

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

@wswebcreation can you clarify why this catch block will never be reached for mobile apps?

Copy link
Member

@christian-bromann christian-bromann left a comment

Choose a reason for hiding this comment

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

Great job 👏 will go ahead and merge as my question is not blocking.

@christian-bromann christian-bromann added the PR: Polish 💅 PRs that contain improvements on existing features label Nov 20, 2024
@christian-bromann christian-bromann merged commit be4fea7 into main Nov 20, 2024
@christian-bromann christian-bromann deleted the ws/add-longpress-logic branch November 20, 2024 19:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PR: Polish 💅 PRs that contain improvements on existing features

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants