tolmasky / demokit

DemoKit is a Library and Electron app for building product demos and tutorials using web technologies
MIT License
428 stars 17 forks source link

Scripting demos for apps that require authentication #16

Open justinmayer opened 7 years ago

justinmayer commented 7 years ago

We have a web app that requires authentication, and I can't quite figure out a way to manually log into the app beforehand and then run demokit index.js to run the scripted demo on the authenticated browser instance.

We don't need or want to show the login process as part of the video, so it doesn't make much sense to include that in the script.

Anyone have any suggestions as to the best way to handle this? I'm happy to add documentation that covers this once I understand what the appropriate solution(s) might be.

tolmasky commented 7 years ago

You can start the recording AFTER the authentication (or create a demo account where the password deosn't matter). But, I agree that ideally none of this would be necessary. I think it might be possible to share sessions, would have to look into it (and certainly be careful that that doesn't open up your normal session).

justinmayer commented 7 years ago

Many thanks for the response, @tolmasky. I agree that some kind of persistent/shared session would be helpful. Perhaps there could even be a script directive to expire the session manually.

tolmasky commented 7 years ago

Here's an interesting idea:

So you should have access to command line arguments in demokit, so you could do something like this:

<type selector = 'password'>{ process.argv[2] }</type>

That way, you can run it as demokit index.js THE_PASSWORD and not include it in the script itself.

thekarladam commented 7 years ago

I imagine a more generic need might be the ability to crossfade from one event to another. In a world where that exists, one could temporarily pause the recording, allow the script to perform login, maybe even insert an interstitial prop that says "login" or explains the passing of time not shown, then cross-fade (or some choice of transition) and continue recording after the portion that's omitted.

It occurs to me that those portions could also be edited out of the final video given they were wrapped in an block that did this by marking what CMTime to snip to and from.

justinmayer commented 7 years ago

@tolmasky: Thanks for the follow-up idea. When I try passing the password in the command line invocation as you suggested (i.e., demokit index.js THE_PASSWORD), I get the following error:

Error: Cannot find module '/Users/myuser/myproject/demo/THE_PASSWORD'

Any idea how I might work around this problem?

tolmasky commented 7 years ago

I think you have to pass it as the first parameter

On Saturday, December 3, 2016, Justin Mayer notifications@github.com wrote:

@tolmasky https://github.com/tolmasky: Thanks for the follow-up idea. When I try passing the password in the command line invocation as you suggested (i.e., demokit index.js THE_PASSWORD), I get the following error:

Error: Cannot find module '/Users/myuser/myproject/demo/THE_PASSWORD'

Any idea how I might work around this problem?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/runkitdev/demokit/issues/16#issuecomment-264654593, or mute the thread https://github.com/notifications/unsubscribe-auth/AABcyY25kE8PVIQ-rbJTryxzYil-k7IQks5rEa0_gaJpZM4KlVoY .

-- Francisco Tolmasky www.tolmasky.com tolmasky@gmail.com

justinmayer commented 7 years ago

Many thanks for the quick reply. That did indeed do the trick! (^_^)

Follow-up question... Once the scripted login process is completed, we need to open a specific route in the existing browser instance (there is no link on the post-login page we can tap on to get there). How would that be done via Demokit? I tried the Executing Arbitrary Javascript approach, but it doesn't seem to have any effect:

<execute    window = "mywindow"
                script =
                {
                    function(resolve, reject)
                    {
                        window.open("http://localhost:8000/#/myroute","_self");
                    }
                } />

(Please forgive any blatantly silly mistakes here — I'm new to JS.)

Any idea what I should be doing instead to open a specific route in the existing (authenticated) browser session?

tolmasky commented 7 years ago

You'll want to do something like location.href = new location; resolve(). But it might get a bit more complicated. Maybe worth opening a new issue for this.