Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Perform actions on device #635

Closed
rolfb opened this issue Mar 22, 2018 · 7 comments
Closed

Perform actions on device #635

rolfb opened this issue Mar 22, 2018 · 7 comments

Comments

@rolfb
Copy link

rolfb commented Mar 22, 2018

It would be nice to perform gestures, swipes and taps on the device without having to find an element first.

Use case:

  • Auth0 login using in-app browser.
  • Scroll on device/screen
  • Tap approximate location of input field
  • typeText when keyboard shows
  • submit using typeText?
@LeoNatan LeoNatan changed the title Enhancement: Perform actions on device Perform actions on device Mar 25, 2018
@LeoNatan
Copy link
Contributor

Do you mean, calling these on the device object itself? I was thinking about that myself recently.

It makes sense on one hand. On the other, these APIs, I feel, encourage bad practices. Understandably, some things cannot be tested with Detox due to technical limitations, and those would greatly help. I fear, however, that people would use those APIs instead of properly using byId() and co.

I guess people cannot be saved from themselves, and the greater benefits of this will outweigh the downsides.

The point to point API is still to come. It's a missing link in many requests.

There is also the question whether Earl Grey, our internal iOS infrastructure, allows for such "decentralized" actions. I am not sure. On Android, I don't even have an idea how that system works. Greater minds will chip-in on that.

@eflath
Copy link

eflath commented May 17, 2018

My two-cents: I understand the concern that broad, top-level APIs like this could encourage bad practices, but they could also unblock certain potential users who would otherwise not be able to use the detox at all. For example: my app has a bunch of long React Native list views and I need to be able to scroll them. scrollTo() and scroll() are essentially useless in these cases so I pretty much can't use detox at all for this app. If i could just scroll by swiping somewhere on the screen on the other hand...

@LeoNatan
Copy link
Contributor

In what way is Detox useless for list views?

@eflath
Copy link

eflath commented May 18, 2018

I'm referring to
#103
and #164

some combination of these two issues had made it impossible to scroll list views in my app via detox. After typing this yesterday, though, i tried applying this PR as a patch https://github.com/wix/detox/pull/458/files as suggested in the second thread. That works for me so we're unblocked, but still not an ideal situation.

The broader point being: this is a young and still evolving library so features will be lacking. Providing more generic gesture APIs could help unblock users while a proper version of the requested feature can be designed and built.

Also, a (maybe contrived) example of a UI that would want a general swipe gesture (from point x,y to point x', y') would be a drawing app.

@Nick-Lucas
Copy link

Please revisit this. It's hugely painful trying to scroll around when you can't be sure what elements are on screen or whether their scroll-point has fallen off the edge of the screen.

We have a pretty complex form with collapsible sections (hit continue and see the next section) and so we can end up in random scroll positions after a section collapses. Having a robust way to reset to the top or (separate idea from this issue) scroll directly to an element would be very helpful.

@Nick-Lucas
Copy link

Nick-Lucas commented Feb 28, 2019

We found a solution to this problem that should work with any Detox version.

We overlay a non-interactable view over the entire app, which means the app is still usable, but you can match on that view and swipe against it. In our complex forms we can now robustly swipe back to the top and then swipe down slowly, searching for a particular element.

// The overlay
const TestingAppPane = () => (
  <View
    testID="TestingAppPane"
    style={StyleSheet.absoluteFill}
    pointerEvents="none"
  />
)

// Root app render
export default () => (
  <Provider store={store}>
      <AppContainer />

      // IS_TESTING is used just so it doesn't show up in production
      // but it shouldn't cause any problems anyway
      {IS_TESTING && <TestingAppPane />}
  </Provider>
)

@LeoNatan
Copy link
Contributor

This will not be implemented for the time being. If scroll position is uncertain, first that's a big UX problem for you users, and second, you can use the whileElement() to scroll your container scroll view until the target view is visible.

@lock lock bot locked as resolved and limited conversation to collaborators Apr 19, 2019
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants