0

Some high level (UI) smoke test scenarios should be automated for the web application made for audio/video/chat conference calls.

At least one to one(peer-to-peer) users should be used to simulate and to automate - i.e chatting between two users, that is - user #1 from browser Firefox send the message to user #2 from Chrome browser, and vice versa.

The question is - what is the basic structure of framework can be used for such specific approach, does it mean that for writing test scenarios two separate instances of WebDriver should be used, like fireFoxDriver and chromeDriver?

  • Do you need to use several WebDriver instances across several unit tests? Or it is enough to just have several WebDriver instances in one unit test? – Twaldigas Mar 24 '15 at 14:24
  • I would write a simple-as-possible coordination store, e.g., an XML file, that registered when each test launched and was ready for execution. When each side of the test is launched, they each register their readiness in file (concurrency issues aside) and begin polling the file for the other side of the test. When the other side checks in, each side of the test proceeds. You could use this approach for managing any other coordination issues that follow after as well. – Chris B. Behrens Mar 24 '15 at 15:33
0

I would do it on this way:

Create a class with methods that you use to create new WebDriver instances as easy as possible. E.g.:

WebDriver userOne = DriverBuilder.getUserOne();
WebDriver userTwo = DriverBuilder.getUserTwo();

With that you have two WebDriver instances and you can control each on them separate. You do not have to use different browsers. Both instances can be the Firefox browser.

If you need to work with WebDriver instances across several unit tests, create a class that act as a pool/collection. You put initialized WebDrivers into it and get them, when you need. E.g.:

// Unit Test 1
DriverPool.put(initializedDriver, "uniqueName");

// Unit Test 2
WebDriver chattingUser = DriverPool.get("uniqueName");

But you have to be careful. If you put a lot of instances into the pool, there are a lot of browsers open and maybe your grid system is not able to handle them all. So you have to be sure, that you delete instances that you do not need anymore. Maybe this is the most challenging part.

In addition: Try to keep everything that have to do with the initialization and handling of the WebDrivers outside your unit tests. Put this into @Before methods or somewhere else. It is important to not mess unit tests up. They have to be easy to read and concentrate on testing itself.

This is just a theoretical solution. I do not know if this will solve your problem, but my mind says it should. The same apply the code examples.

  • Using two WebDriver instances works fine. The next what I need is selenium grid for such approach, what means that probably there is need of two RemoteWebDriver instances in order to have the possibility to run in parallel test A in such combinations: 1. Chrome with Firefox; 2. IE with Safari. In any case there is need to have two WebDriver instances for two browsers - but how to apply for this purpose grid ? – user1829657 Mar 27 '15 at 8:33
  • @user1829657 I do not see any problem with that. You can have as many WebDriver instances as your Grid system provide. The parallel part will not be handled by Selenium / WebDriver itself. The testing framework and/or build management tool (like Maven) will take care of it. – Twaldigas Mar 27 '15 at 10:16
  • Could you please provide a simple code example of what should be in this case testng.xml and lets name it init() @BeforeTest method that is creating webdrivers instances. I'm not familiar exactly with the selenium grid, especially in my case when there is need of two browsers simultaneous interaction - I mean I can easily run one test( per one user) in parallel within one webdriver instance, but with two instances together with the grid - no idea how to implement such logic? – user1829657 Mar 27 '15 at 13:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.