Skip to content
This repository has been archived by the owner on Jul 29, 2024. It is now read-only.

Add browser.fork function that returns a promise #3892

Open
juliemr opened this issue Dec 29, 2016 · 6 comments
Open

Add browser.fork function that returns a promise #3892

juliemr opened this issue Dec 29, 2016 · 6 comments

Comments

@juliemr
Copy link
Member

juliemr commented Dec 29, 2016

This promise will resolve to the new browser instance, so it can be used nicely with await and in a control-flow-less world:

TODO - think of a better name.

let b2 = await browser.forkAndInitializeNewBrowserInstance();
await b2.get('example.com');
// continue to use b2 as a browser instance.
@sjelin
Copy link
Contributor

sjelin commented Dec 29, 2016

Actually, it should probably just be an optional parameter to forkNewDriverInstance. Typescript can handle "return type X if param 3 is true, return type Y if param 3 is false". It sucks that it has to go at the end of the parameter list, but that's life I guess.

@juliemr
Copy link
Member Author

juliemr commented Dec 29, 2016

What's your reasoning for that? Sure, we'll have a duplicate list of other parameters, but they can go to the same function under the hood.

@sjelin
Copy link
Contributor

sjelin commented Dec 29, 2016

Just seems more natural? Maybe I'd feel better about separate functions if we could come up with a good name 😛

@sjelin
Copy link
Contributor

sjelin commented Dec 29, 2016

Like, you rarely have two different functions that do almost exactly the same thing. It's pretty common to use params in this case, yeah?

@sjelin
Copy link
Contributor

sjelin commented Dec 29, 2016

(Not a strongly held opinion though)

@sjelin
Copy link
Contributor

sjelin commented Jan 27, 2017

As of version 5.1, you can do this indirectly by using .ready:

forkedBrowserPromise = browser.forkNewDriverInstance().ready

We may still implement this as its own function in the future, but it's not super high priority

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants