how to combine Webdriver, Appium and soup in one framework - java

I need to put Web sites testing , Mobile testing and Webservice testing in single Framework. Means single framework will perform all these type of testing.
As the configuration is define in environment file (.property file ) the framework should get ready to perform relevant testing
Using environment:-
testNG, selenium - grid,
Window , Appium , Webdriver , etc
Can anyone please provide me guideline?

Integration of API testing in framework :
+Appium utility
+Selinium utility
-API
- RestAPIService using HTTPClient
- ResponseParser - ObjectMapper
- DataSource similar to UI framework
+TestClass
-Here you can call you Appium/Selenium/API methods
For Api integration you can create one RestService class in that you can create wrapper methods getRequest(url, header) , postRequest(url, header) , putRequest(url, header) and deleteRequest(url, header). For response parsing you can use available json parser. and data you can take from same source which you are using in UI automation.

You can use all the libraries and create a wrapper around it.
Create interfaces which uses the libraries and implement them in your class.
Since all that you mentioned are open source jars, it should not be a problem to integrate them.
You can check here! This is an open source framework and they have integrated Appium, Jersey client and Selenium. If you are facing specific issue, please reply I will try to reproduce it from my end :)

Related

How to Build a Data Driven Selenium WebDriver + Java + TestNG Framework

I'm planning to automate some website using Selenium WebDriver + Java + POM(Page Object Model) + TestNG.
I've all other WebPages common for the given website but for each transaction one WebPage which is almost like a form would be different.
So, I've following choices.
Have a Page Object Model (POM) Created for all static common pages and Start creating POMs for the pages which differs in each transaction.
Have a Page Object Model (POM) Created for all static common pages and using some external data source (XML, Excel etc) I can generate the tests for that perticular page.
I'm in favour of second approach here as I don't need to write code again for each new transaction just because there is one page is different?
Any thoughts? or anybody implemented something like this already?
Yes 2nd approach- 'Page Obj model' based is best to keep your code isolated and easily maintainable.
For your test data maintenance I'd suggest you using Cucumber based (BDD driven) framework.
It goes very well with automation FW (POM, Selenium, Java, TestNG/Junit and Maven based) projects.
By using cucumber you need not depend on any other source of test data, i.e. excel or xml, this can easily be maintaned with feature files of cucumber.
Also BDD gives you the main advantage of keeping 'BA-QA-DEV and Management' on same page.
If you dont want to use Cucumber/BDD, then you can use Test NG data provider feature with Excel to achieve better test data management.
If you want to learn Cucumber/BDD-> there are lots of very good video tutorials available online. One of my Fav is here-
https://www.youtube.com/playlist?list=PL6tu16kXT9PpteusHGISu_lHcV6MbBtA6
for web reading:
https://www.lambdatest.com/blog/automation-testing-with-selenium-cucumber-testng/
Happy Testing!
I have worked in similar kind of project. I would suggest to with #1. The reason is that might be possible in future you find difference in web pages, So common function will not be always applicable to each page.
So if you go with #2 as of now then its fine but you gonna end up by following #1 in such cases.
The above answers are mixing the Page object model with a data-driven framework.
Basically in data-driven framework, the data is read from an external file
Well if you want to build a simple pure data-driven framework then it should have
Independent tests
All tests should read data from JSON/XML/YAML/XLS... any source
Properties file having your locators and other settings
You should also create a base class which will have the common reusable functions which can be used in tests
You should make it in such a way that running on grid is easy and by just chaning external flag.. tests should run in GRID
Proper HTML reporting with screenshots, errors, failures should be done
Also watch this video
https://youtu.be/s-W8pw9GnWc

Automated Testing using ReadyAPI (SoapUI NG)

I'm just getting started with ReadyAPI(SoapUI NG) to do automated testing for our Spring based project. So using the ReadyAPI documentation I successfully tested REST URI calls using below steps:
Created a project: File > New Project > Create a Project using REST URI
It creates a project structure like below: REST Project > URI > createAccount < Request 1
In the Request window I added my parameters by using xml/json.
After Running the Request I'm getting my desired response.
I also checked Assertion that also giving desired results.
I did all this using ReadyAPI Documentation
My questions are below:
How to achieve Automated Testing using ReadyAPI(SoapUI NG)?
What features of ReadAPI are generally used? How to use them effectively?
What are the differences between SoapUI NG, LoadUI NG, SoapUI, ReadyAPI? (I thinks these are just different versions, not sure though)
Let me try to answer them to my best of abilities.
How to achieve Automated Testing using ReadyAPI(SoapUI NG)?
Ready API or SoapUI are the automation tools themselves. To manually
test the APIs, there are other tools like swagger. However if
you are planning to automate the flow of your whole project and
planning to use some sort of architecture/framework which will enable
you to do a lot more than just execute the tests at once then you can
try using tools like Jenkins.
What features of ReadAPI are generally used? How to use them
effectively?
One of the most talked about things in Ready API is Data Driven
Testing. If you follow this approach, then you may use test steps like
DataGen, DataSource, DataSink, PropertyTransfer, Groovy Assertions,
Groovy Script Step, JDBC Step. Those are the steps that are used
widely in Ready API Projects.
What are the differences between SoapUI NG, LoadUI NG, SoapUI,
ReadyAPI? (I thinks these are just different versions, not sure
though)
Ready API is a collection of different API testing solutions, like
Performance Testing(LoadUI), Security testing(Secure), Functional
testing (SoapUI). When you install Ready API, you install all the
solutions together. And then you can chose to buy licence for each of
those solutions separately.
Hope that answers your question.

Selenium 2 Webdriver test as service called using REST

I'm trying to understand where I need to look to implement such scenario:
What I have:
1. I have variety of testing scenarios implemented on Java with Selenium 2 Webdriver.
2. I'm running my test scenarios (suits) using TestNG (defined list of classes and methods in order in xml file), building using Maven.
3. All on my local machine and from my local machine
What I need:
1. I need to implement ability to call my test suites from external test framework. As result of this call - test execution should be started.
2. I need to send parameters to my Tests, so call should contain parameters that should be passed to my code.
3. I need to send "a message" to external framework when tests would be done (with info : success of failed)
I'm thinking to implement this collaboration between two frameworks using REST
My questions:
1. How architecture should look like? Should I run any server so my service would be available 24/7 for external framework? How to write such service?
2. Where to read about it?
3. Any examples of classes/methods that should be implemented to send parameters/ to get parameters?
thank you in advance for any ideas.

Is play! Framework 2.0 suitable for creating a REST API?

I have developed a REST API using Play! Framework 1.2.4, and I have a strong liking for the framework. The simplicity and the rapid development cycle helped me achieve this in a fraction of the time I would have taken had I gone the traditional Java EE route.
Now that I am exploring using Play! 2.0.3 for my next project. I see that while the framework has been enhanced and makes it even easier to develop web-apps, the same cannot be said about REST API's. My app will not have any HTML whatsoever - I will just respond with XML or JSON or whatever data exchange format I decide to use in future.
So, the question is:
Has anyone here used Play 2.0.x for exposing non-html pure REST API's?
More Details:
Here are some of the factors I feel make it more difficult to develop pure REST API's in Play 2.0.x compared to 1.2.x. Please correct my understanding if I am wrong.
Content Negotiation is harder
In play! 1.2.4, I content negotiation was build in to the framework. There were options to define right in the routes file what content-type a request expects.
GET /friends User.listFriends(format:'xml')
Then, in the controller,
public static void getFriends(){
render();
}
This would result in the views/xml/User/listFriends.xml template being rendered automatically. To add support for JSON tomorrow, all I needed to do was to add a views/json/User/listFriends.json template.
I do not see how this can be done in play! 2.0.x
Creating non-html templates is less intuitive
After some trial and error, I figured out that one can create, for example, a listFriends.scala.xml in the views folder in play! 2.0. Then, it needs to be invoked in the controller code as follows:
return ok(views.xml.listFriends.render());
However, Eclipse doesn't like this, because Eclipse does not know about the views.xml.listFriends since it is generated only after play compilation completes. Is there anything I'm missing here?
In Play (Scala) you can do something like this:
val myXMl = obtainXML();
return Ok(myXML).as("text/xml")
I'm not sure of the syntax in Java, but it would be equivalent: instead of creating a template, you generate the XML and then you send it to the user, setting the return type to "text/xml" (or json or whatever you need it to be).
As Pere Villega explained, but with the Java syntax:
String xml = getXMLAsString();
return ok(xml).as("text/xml");
The as() method is part of the Status class.
Or, an alternative is:
String xml = getXMLAsString();
response().setContentType("text/xml")
return ok(xml);

How to mock entire JAX-RPC communication session?

I have a legacy application, which is working with third-party web service through JAX-RPC. Now I need to unit-test the application by mocking certain XML RPC calls with test data. Actually, I need to replace Apache Axis, which is used by the application, by some other library that will be JAX-RPC compliant, but will return what I'm telling it to return. I'm pretty sure I'm not alone with such a problem... Are there any open source libraries for this purpose?
You can do it with Spring framework and EasyMock.
What's the best mock framework for Java?
I have had some success with WireMock. It's a Jetty server that you set up programmatically to respond to certain request patterns with content that you also specify. I have been able to set it up to respond to XML-RPC requests from my class. E.g.,
stubFor(post(urlEqualTo("/RPC2"))
.withRequestBody(containing("<methodName>...</methodName>"))
.willReturn(aResponse()
.withBody("<methodResponse>...</methodResponse>")));
For Mocking the calls to external services you can use EasyMock+Powermock or Mockito
you can do something like this
Easymock.expect(your function calling external Systems).andReturn(your required output)
hope this helps!
Good luck!

Categories

Resources