Detox icon indicating copy to clipboard operation
Detox copied to clipboard

How to test with pasteboard?

Open iwater opened this issue 8 years ago • 26 comments

I'm using detox to test a RN app, how to test with Clipboard?

iwater avatar Aug 05 '17 17:08 iwater

@iwater what is that?

isnifer avatar Aug 05 '17 19:08 isnifer

set some string at clipboard, then read that from app, or set string into clipboard from app and check it from test as expected

2017-08-06 3:39 GMT+08:00 Anton Kuznetsov [email protected]:

@iwater https://github.com/iwater what is that?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/wix/detox/issues/222#issuecomment-320466013, or mute the thread https://github.com/notifications/unsubscribe-auth/AAGpiWv2it9N_1EB9Ns5Dg4M_BwSG7Zwks5sVMTdgaJpZM4Oug5d .

iwater avatar Aug 06 '17 06:08 iwater

not sure that it will be a main priority feature :)

isnifer avatar Aug 06 '17 18:08 isnifer

It's a perfectly valid feature request though. I quickly checked Earlgrey, It seems there is no support for this there.

simonracz avatar Aug 06 '17 18:08 simonracz

What will this feature test? That the system clipboard is working correctly?

rotemmiz avatar Aug 06 '17 20:08 rotemmiz

I had an app many many years ago, where the primary event to it was copy pasting a longer text to it. It is actually a different event than typing characters into the textfield one after another. (Although, you have to work a bit for that. ;) )

I am not talking about what @iwater described.

I am thinking about actions like, copy paste into a specific view the current clipboard.

Edge case? Definitely. But, I think it can't be covered by simply long clicking into a textview then trying to tap the paste button.

simonracz avatar Aug 06 '17 23:08 simonracz

in my app, it check the clipboard , if there is a url as expected, the app will show a dialog

2017-08-07 7:16 GMT+08:00 Simon Racz [email protected]:

I had an app many many years ago, where the primary event to it was copy pasting a longer text to it. It is actually a different event than typing characters into the textfield one after another. (Although, you have to work a bit for that. ;) )

I am not talking about what @iwater https://github.com/iwater described.

I am thinking about actions like, copy paste into a specific view the current clipboard.

Edge case? Definitely. But, I think it can't be covered by simply long clicking into a textview then trying to tap the paste button.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/wix/detox/issues/222#issuecomment-320539242, or mute the thread https://github.com/notifications/unsubscribe-auth/AAGpiYO_uoDDHlMbZHGcIb8Q7y5bV8tTks5sVkldgaJpZM4Oug5d .

iwater avatar Aug 07 '17 00:08 iwater

I can think of many cases where apps would want to test that they have copied the correct text to clipboard. For example, a passwords keeping app.

LeoNatan avatar Aug 09 '17 13:08 LeoNatan

You can use xcrun simctl pbcopy/pbpaste to pass clipboard between device and computer. This would be nice if you could add this feature via PR.

rotemmiz avatar Aug 15 '17 13:08 rotemmiz

Would Paste text be faster than "simulated" typing? Speed is valuable when running [many] automated test cases.

markhu avatar May 03 '18 18:05 markhu

@markhu No, it should be the same. Detox’ future support for Pasteboard will only be for expecting values in the pasteboard, so I don’t see how Detox can be helpful in your case. Replacing text is the fastest way to enter text.

LeoNatan avatar May 03 '18 18:05 LeoNatan

I would welcome readPasteboard method.

I have a usecase with copy to clipboard button. I would like to read the device's pasteboard to verify, that the button actually works.

As mentioned above there is simctl in the xcode utils (for iOS of course), but seems somehow broken.

I found JS sim utils, which don't work properly... https://github.com/appium/node-simctl/issues/79 It would be valuable to have this API...

MiroslavPetrik avatar Feb 25 '19 14:02 MiroslavPetrik

Would be nice https://github.com/wix/Detox/pull/658/files

FDiskas avatar Mar 23 '20 14:03 FDiskas

@LeoNatan Can you please share why the related pull request was deleted without any comment?

lumberman avatar Oct 22 '20 19:10 lumberman

The issue has been closed for inactivity.

FDiskas avatar Oct 23 '20 14:10 FDiskas

Pull request was closed because it had many issues, the person working on it was no longer working on it and it went stale. We don’t have the resources to commit to this. If someone takes the JS side and implements it in a PR, I’ll add the iOS native side.

LeoNatan avatar Oct 23 '20 15:10 LeoNatan

@LeoNatan I think I'm able to work on it on the last week of the year. Do you mind pointing me to the PR and related information? Feel free to share any thoughts on how to best implement it.

sidferreira avatar Dec 15 '20 13:12 sidferreira

@sidferreira Hello, thank you for offering to assist!

We need to come up with the Detox API first, I think, and its limitations, and then we can discuss implementation. I can give pointers with iOS.

Pasteboard on iOS can hold many different objects, such as generic data, images, colors, etc. I don't think we can support all of them. Perhaps we can limit testing to strings? Or other common objects. I think strings are enough.

UIPasteboard reference: https://developer.apple.com/documentation/uikit/uipasteboard?language=objc

API design is problematic, I think. We don't currently have expectations over device.

My idea of API is:

await expect(device.pasteboard()).toHaveValue("hello");

LeoNatan avatar Dec 15 '20 16:12 LeoNatan

@LeoNatan I think we should, at least for now, focus on string content. The only note is that, if possible, I would like to have a way to return such string. What you think?

sidferreira avatar Dec 15 '20 17:12 sidferreira

@sidferreira That's also possible, and then let the user test the value on their own.

So, an API of this sort:

await device.getPasteboard()

could work.

LeoNatan avatar Dec 16 '20 09:12 LeoNatan

@sidferreira did you end up working on this? I have an interesting use case as I wrote here, where we want to test a flow where a user shares a deeplink to the app. Assuming I'll be able to get Detox to tap the 'copy link' dialog (an assumption I'm not sure is valid), having this feature could really help. Otherwise we'll resort to mocking the Share.share(arguments) call and somehow pass the arguments to the test.

electricmonk avatar Mar 16 '21 12:03 electricmonk

@electricmonk Sadly I couldn't. Some last-minute plans changed all my December schedule and still trying to get back on track.

sidferreira avatar Mar 16 '21 14:03 sidferreira

Hi @electricmonk is there any news on this topic. I'd be highly interested in this as well. Thanks for contributing to such an awesome framework.

taschik avatar Jul 30 '21 10:07 taschik

Ended up mocking Share.share

electricmonk avatar Jul 30 '21 11:07 electricmonk

Is there any news in regards to the possible device.getPasteboard() API?

Noitham avatar Aug 18 '21 10:08 Noitham

One possibility is that when you tap on the copy to clipboard button, a toast with that information appears but only for the E2E environment or some environment variable that enables showing toast when copying to the clipboard.

luke92 avatar Sep 07 '24 00:09 luke92