-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Feature Suggestion: Support multiple browser instances from single test #381
Comments
I'm so happy you brought this up, because a while ago we'd had a discussion and decided that no one would ever actually use that functionality! So, you could do this now by basically rewriting runner.js (which is what you've started). I don't think there's any way to generalize your use case enough that it would be worth it to make it reusable, so I'd encourage you to just go ahead and write your own runner.js. If anyone else would use this though, I'd love for them to chime in here! |
We would definitely use this. We are writing a web app that allows insurance policy holders to communicate with construction contractors who are supposed to do repairs on the policy holders' homes. Currently, we have to write e2e tests for each side of the app separately. We have to write one test that signs in as a policy holder, does some setup and then sends off a communication to the contractor. And then we have to log out as a policy holder, log in as a contractor, and then make sure that the communication arrived in the contractor's inbox as expected. However, if the functionality described above were possible, then we could run two parallel versions of the browser at the same time where one is signed in as a policy holder and the other is signed in as a contractor and we could instantly verify that the communications can go back and forth as expected. That would be a huge benefit to us. I can imagine there are many other such websites out there that could use this type of functionality. |
I'd like to use this as well. I'd like to test a game that needs multiple instances to exercise all scenarios |
Would definitely use this as well! Been logging out and logging in as different users as well, with this support we would no longer have to do that =) |
@juliemr Curious why this couldn't be generalized? I was thinking it might make more sense if the concept of a "primary driver" remained, with a config option to specify n number of "helper drivers" that could be kept in an array similar to the example from @bobthekingofegypt. Would this approach make it any less intrusive to the mainline use case while allowing the multi-driver flexibility? Granted I don't understand how saucelab compatibility comes into play here. However, if two two concepts simply aren't compatible, that could be accounted for in the config logic. I wouldn't mind attempting a PR. |
I need this to test instant messaging and notifications between two logged in users. My suggestion is similar to @bobthekingofegypt but using blocks instead of And having browser1, browser2, ... kind of globals: By default Sample usage of browser2
|
+1 need for this. |
+1. Would be able to use this as well. Saves having to log out and log in
|
/sub |
Will leave a reminder here that this feature won't work on IE: Not sure about Safari, probably won't support this either. |
It was a while ago that I did this, and I haven't been working with Angular/protractor since so it is a bit hazy. But looking at my diff I don't think I did anything beyond what was required to make a proof of concept work. All the promise work is because you need to block till all sessions are ready, and then make sure all sessions terminate at the end of the test. I also left in some code so single browser tests would work as normal. The fork does work, I used it for two projects; it does have flaws though. I haven't tracked the changes in protractor but if what you want to do is simple you can try checking out my fork and npm link it, I changed the name from protractor to protractor-multi so I could run them both at the same time. |
+1 for this. I would like to test asynchronous pub/sub with 2 browsers. |
You can generalize this with implementing the ability of parallelization tests with scaling that is not limited to 2. Sometimes we implement tests that are not affecting each other and can be run in parallel. So, the POC is to implement running parallel tests within single protractor instance (with single output and ability to collect results to single report). Maybe there can be way to use something like Async.JS to run different specs in threads. Maybe there is a way to do that with some Grunt package, but it is not convenient to have many Protractor config files, we would like to have all configs in one file. Thanks in advance for your reply. |
+1 for this (writing a websockets app that could benefit from this) |
+1 still needing some support... From issue #569... I need 2 instances of browser running within a single test and must be able to manipulate them individually. I haven't found any info on how to perform it. Would be glad if you could enlighten me. This is a definite roadblock for my test suite. Thanks. Thanks @hankduan. The problem I see is. If I use multiCapabilities, I can't manipulate both instances as I want to. The action of a user in one browser must reflect in the other browser. Like in google docs, when a user writes in a shared document, the other can see what is happening. This is basically what I must test. And if the second user deletes what had been written beforehand, the first must see it. |
@rafaelbattesti wrote: "Thanks @hankduan. The problem I see is. If I use multiCapabilities, I can't manipulate both instances as I want to. The action of a user in one browser must reflect in the other browser. Like in google docs, when a user writes in a shared document, the other can see what is happening. This is basically what I must test. And if the second user deletes what had been written beforehand, the first must see it." What about using "wait" functions. For about, you can implement something like "waitForElement" and in one spec file (1) start to wait with your timeout (e.g. 30s), in other spec file (2) run test that should reflect the first browser. spec file (2) makes actions and after them new element appears. spec file (1) sees that his element appears and continues his actions. |
@rafaelbattesti If your backend is not mocked out, you can give @Mikrovolnovka's method a try. It might be a little flakey some times, but that is the best solution for the use case at the moment as we do not have any "official" way of doing this right now. |
+1 . I would like to test client 2 client web app (#949). |
+1 as this would be very very useful |
+1 |
1 similar comment
+1 |
Hi, we would use this too! |
+1 |
This might be a work around. Please let me know if this a a good way of doing it or not.
I'm essentially opening two different browser and in the same test script, defining what each browser should act as different user. |
+1 |
I am not sure if I solved the exact same problem already a year ago. We also had an interacting socket.io app. We wrote the protractor e2e tests one year ago, so the code is right now only compatible with a very early version of protractor (0.12 if I remember it right). The following code is just a small demo code for a blog post I wrote a year ago about our first steps with protractor in an interacting dual browser setup (Source in german http://blog.cnc.io/allgemein/e2e-tests-in-angularjs-with-protractor/) Maybe we can translate this code to work with version 1.3.1 and have this feature out of the box?
|
This is my thought: Since I am using multiCapabilities to start multiple threads, the global I am trying a new way of identifying browsers so that it no longer rely on The ticket management is written in the conf.js : if(fs.existsSync(location)){ //when file exists, add 1 for the new In your spec: If the global variable in protractor.conf works then your solution is On Thu, Oct 16, 2014 at 8:51 AM, carlhopf [email protected] wrote:
|
Sorry, I've had to delete my old comment due to a bug. Here is my new take on the problem to allow multiple browsers windows/instances for protractor 1.3.1: https://github.com/carlhopf/protractor/commit/dd76f72bcc2e6fc338b95e3465a19034b4591241 This allows to call
and you'll get a new browser window to work with (supports as many as you'd like to use). All new windows will also automatically close when protractor quits. NOTE: you must add "chromeOnly: true;" to protractor.conf.js, I've just made lib/driverProviders/chome.js compatible so far! Test it out yourself:
|
Here is another workaround i'd like to propose for multiple windows/instances for protractor 1.3.1: https://github.com/carlhopf/protractor/commit/9aa1a7e4b10ca3becd699ea7f3ae63158dfd8b9e This gives you newBrowser(), quitBrowser(index) and switchBrowser(index) and assigns the currently selected browser to the global protractor objects (browser, element, protractor.getInstance(), ...). So there is no need to change test syntax, simply switchBrowser() and continue as before.
NOTE: you must add "chromeOnly: true;" to protractor.conf.js, I've just made lib/driverProviders/chome.js compatible so far! Test it out yourself:
|
"I'm so happy you brought this up, because a while ago we'd had a discussion and decided that no one would ever actually use that functionality!" I think at least every "real-time" app need this testing functionality. At least for chrome there is no problem to open new window through: This feature is very important for me too. |
Got my multi-browser test to run again with the "vanilla" protractor package. Perfect for chat or any other multi-window live interaction web project testing. Just had to change the following includes:
The full example code is:
I have not tested it a lot, i just had the time to get it running again. Any suggestions are welcome if there are some bugs or misconceptions in the code. |
Implemented with 0bbfd2b. This will be released in protractor 1.5.0 |
@hankduan Can I get a documentation link for how to control multiple browsers for instant messaging kind of applications. I have tried searching for this and I am unable to find some code except multiCapabilities. |
note to self: I should work on the docs. For now, read the api annotation: https://github.com/angular/protractor/blob/master/lib/runner.js#L190 |
Please make sure to install Update web driver manager Run this command from your root Now start up a server with: Also make sure that your protractor.conf.js file has below line Now run your e2e tests on different browesers |
Currently I am working on some socket based multi-player games using angular. In order to perform an e2e test I need to have two browsers talk to each other as the games wont start till 2 people join.
I was wondering if this could be something that is added on top of protractor.
I kinda hacked up a proof of concept to allow me to test users joining and chatting on the game.
bobthekingofegypt@8ac849a
As a concept it appears to work ok, it allows you to write tests like
This change breaks certain things like saucelabs support and it's not very complete but it is meant as a conversation starter.
It is quite a niche use case but is this something you would consider supporting in protractor?
The text was updated successfully, but these errors were encountered: