views:

27

answers:

2

I've used Selenium to do lots of UI testing from the browser. If you have a web service behind the Java jsp page i.e. in a servlet, you can test it from Selenium.

Can Selenium be used to test a B2B web service i.e. a web service called from a backend that has no browser UI component?

I have used SOAPUI to do this kind of testing in the past but our test department is trying to standardise on Selenium.

A: 

You can but I would not recommend it. If the page is returning XML, you won't be able to use the standard Selenium calls to verify what is happening as you won't have access to the DOM. If its returning plain text for JavaScript then you will struggle with verifying the output.

This is a definite case of using the right tool for the job and Selenium is not the right tool for testing web services. I would use soapUI or just use some http library to call the service URL and then verify the results.

If they are looking to standardise they need to standardise tools for their purpose. Selenium for UI, soapUI for webservices,XUnit Framework for unit and integration.

AutomatedTester
Are you sure you could not use XPath expressions to check results? There may be better tools, but the question was if it is possible.
Moritz Both
You can but it might not be fast and may be flaky but yes you can do it. It is a major anti-pattern but if it meets your needs do it.
AutomatedTester
Do you have an example of a Selenium script that calls a B2B web service? I can't quite visualise how to do this.
nzpcmad
A: 

You can, but it's really not the right tool for the job. It's like trying to hammer a nail into a piece of wood using a stapler instead of a hammer.

That said, probably the most appropriate way to create a page with all your input parameters which could do the call for you and echo the results back into a html element. If the service is meant for AJAX calls then this is probably the ideal solution for your service.

The correct approach would be to use a unit testing framework and create a test harness which you can push your parameters into, execute the service call and retrieve the results in a meaningful way for assertion.

Mike737