'Draw a line in a detox test
We are using react-native-signature-capture library in our react-native project and we want to test that a signature is sent correctly. To do that the user draws the signature using his finger, is there a way to simulate some drawing using detox? Even a single line would work.
I tried swipe and scroll methods, but neither worked.
Solution 1:[1]
Swipe action works for me. I just added a div around the SignatureCapture component.
<div testID="signatureBox">
<SignatureCapture
{...this.props}
onDragEvent={this.handleDragEvent}
onSaveEvent={this.props.onSave}
key={this.state.signaturePadId}
minStrokeWidth={8}
maxStrokeWidth={13}
showTitleLabel={false}
square={true}
style={styles.signaturePad}/>
</div>
In my test, I get the div by Id, then swipe down and left to make a cross signature.
it("should sign", async () => {
await element(by.id("signatureBox")).swipe("down", "slow");
await element(by.id("signatureBox")).swipe("left", "slow");
)};
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | b1617 |
