-
Notifications
You must be signed in to change notification settings - Fork 133
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Way to force showing the captcha input view? For testing #19
Comments
There's no way to force it, mostly because it's using the Invisible ReCaptcha API. Even, if the embedded html were changed to use the explicit one, you'd need to use a different API key for the different methods. Can I help you with your tests? Maybe what you're trying to do is already covered by our tests. |
All good then. Just trying to clean up how some UI looks when the webview is presented. Had to keep refreshing a bunch, ha. |
Hello guys, I think there is a way to make it appear by forcing a user agent switch. In my tests it worked. Based on these two links: https://stackoverflow.com/questions/43397678/is-it-possible-to-force-fail-a-recaptcha-v2-for-testing-purposes-i-e-pretend and https://stackoverflow.com/questions/478387/change-user-agent-in-uiwebview-iphone-sdk , I was able to put the following code in my function
Could you guys test too please and update me with the results? @fjcaetano do you think we are able to put this as a feature into the ReCaptcha library? I can help with this if you want :) Best regards |
Interesting. This does seem to work, but when would it be interesting to show the challenge to the user? Would this work with a non-Invisible API key? If not, I don't think it would be an interesting addition, since it could cause confusion. |
Interestingly enough, it didn't work for UI tests (which I think would be the most reasonable use for this), unless the defaults are set in the main application's AppDelegate as @augustorsouza said. It'd be interesting to have this working in a |
@fjcaetano some libraries, such as Analytics ones for exempla sometimes have a initialization in the app delegate with some configuration or extra information. Do you think this might be a way to proceed? For example, some libs have a debug boolean flag in the initialization |
I'm still not sold on why would anyone want to explicitly show the challenge. @MaximusMcCann you were the one who brought this up. Were you just trying to write tests for it? Doesn't the libraries tests cover what you were trying to do? |
I think the main reason is that sometimes it is hard to reproduce the behaviour some users of your app will see. When using the invisible API at my network I hardly get a recaptcha input view. With the workaround I described I am able to see the input view and check if there is something wrong in my UI for the user. |
Okay, I guess it makes sense to debug the webview position and layout. Still, this is something that should only be available for development. What do you think of making a boolean public only in class ReCaptcha {
...
#if DEBUG
public var forceVisibleChallenge: Bool // Defaults to false
#endif
} This may need to be set in the Luckily, |
@MaximusMcCann and @augustorsouza, please take a look at PR #32 |
@fjcaetano the PR #32 looks great to me 👍 thank you very much for the improvement! |
No description provided.
The text was updated successfully, but these errors were encountered: