Selenium-Webdriver- java+TestNg Vs ruby - java

I have a automation suite in selenium-webdriver ruby::TestUnit. I found that in java, we can have TestNg, which provides many facilities. Is it worthwhile to change all my suite to java+TestNg? or Should I implement them myself in ruby? in particular, I am looking for these features.. data-driven, page object based , comprehensive reports

I highly recommend to try Capybara before you move on to Java:
https://github.com/jnicklas/capybara

Both has its own merits and demerits
Java selenium :help will be available online if you stuck up somewhere
more APIs will be available for any integration
Ruby Selenium :less help will be available online ,as users are quite smaller in numbers
Ruby gems are limited for any type of integration
Ruby is very simple and easy Language
If your project can be rated as medium or Low in terms of complexity ,I would prefer to use Ruby.

You can use Rspec(BDD tool) in place of Test NG (set up annotation, test flow/order, etc). You can also use page-object-gem to categorize each functional page into a class. Page-object-gem for Ruby is far more powerful than the page object model used in Java. This is an API that comes with 3-5 methods (.click, getAttribute, select the radio button, check/uncheck checkbox, etc) when you declare the element using a locator (whereas in Java, the developer has to code all of these methods themselves). I've moved my project from using selenium java to selenium/watir/rspec/page-object-gem, we cut down the lines of code by three folds. The team can accomplish a lot more stories in a sprint comparing before.

Related

AngularJs end-to-end testing using existing Selenium tests written in Java

Given a site with an existing extensive set of test cases written in Java using Selenium for a site, and this site is being re-written in AngularJs, how does one go about integrating the Selenium tests into the new app?
I have looked into Protractor, the new recommended end-to-end test runner that uses Selenium, however, this appears to suggest writing test in Javascript. This article goes into a little more detail about how to get this set up working, but again, the tests are written in Javascript.
As much as I would like to write the tests in Javascript, I would like to avoid a rewrite, so a means to get the existing ones integrated would be nice. Is there a configuration in Protractor that would enable this to happen?
I am afraid there is no good solution for you here. There are numerous obstacles in your way.
Protractor is written in JavaScript and is a wrapper around Selenium's WebDriverJS implementation. Given that WebDriverJS uses a very different API than the Java WebDriver (due to node's asynchronous nature), even if it is technically possible to get a node library to wrap a Java library, it would not work in this case.
Protractor and Selenium do not support the same API, so even if there were a Java based Protractor, you would find yourself doing a bit of retooling anyway.
If you are leveraging Angular then while the overall behavior of your page may be the same the underlying DOM structure, etc will not be. Either this or you are significantly failing to leverage Angular. Therefore unless you have a really good Page Object abstraction layer in place, you are going to have to rewrite your tests anyway. If you do have a good Page Object layer in place, you will need to rewrite that layer in any event.
In my opinion your best best are as follows:
If your specs themselves are written in a higher level spec language like Cucumber, then those , in theory at least, can be ported to javascript using cucumber-js and you can simply re-implement the underlying definitions (no small task) on top of protractor.
You could get really ambitious and port protractor to Java if it seems like that is less effort than rewriting your tests in javascript. You would then be at liberty to minimize issue #2 above but I still think #3 would lead you to conclude that porting your tests to javascript has the lower LOE.

Complex decision system modified by user - Java

I have a problem and I would like to ask for alternatives on my existing technologies since the programmed feature would be complex and would be given to users, so it should be as simple as it can be on front-end. I need java based technology.
What I need to do:
I am having a basic structure with lot of datas. These datas are mostly well written like Integers, Dates, Booleans etc, so things what can be compared easily.
I need to model decisions with batches of requirements which can be defined and altered by many sources like inner business processes and governmental laws.
So I am thinking to give a scripting ability to the users (most of them have university degrees, so some complexity is ok).
Let's see a simplified example.
Let A be a structure with the following.
A.budget - Integer
A.bankRelatedDebt - Integer
A.privateRelatedDebt - Integer
A.deadLine - Date
A.hasPermissionFromGovernment - Boolean
A.hasProblematicContracts - Boolean
I need rules to define to decide if the rule stands or falls, so I need boolean back.
Rule1: The budget is over 1 million EUR
Rule2: Has no problematic document or has a permission from government
Rule3: The deadline won't be in a month range.
Rule4: The overall debt (local + private) doesn't exceed 100.000 EUR
These rules could be hardcoded in other cases, but this has to be super-dynamic and based on given datas.
We have the options of drools and antlr I would need alternatives if you can mention. Or if you can mention technologies to avoid, that is helpful as well and welcomed, so I can avoid it.
For what it's worth. I would love to do such an expert system too, so bear with my ramblings. First some negative points as you asked what to avoid.
There are many pitfalls.
The "programming" is done by the users, there probably is no version control system for restoral, there maybe is no staging system but one is working in the production system. Think of extending a common library rule test wise. No unit tests?
Then there is the user acceptance. Especially there is a competitor, Excel programming, which you have to supercede. Generating reports with human electable text blocks, diagrams.
Your nunbered rules still lack some life: the system could assist with providing categories to select from: Rule1 - restriction on monetary resource. Nice would be to propose "would you also like to restrict on limitited resources? (a) Rule1, (b) ... .
Also what is the product? What are the advantages? What are the goals?
Reports, calculation scenarios (what-ifs, tolerances calculated through).
I certainly would first write a technical document along above lines, and than search the tools - as you seem to be doing. Drools is too basic. ANTLR for a DSL I find risky.
Tools
Data mining seems to be the keyword you are searching.
The JVM programming language Scala (not easily acquired), is productive for DSL, parsing.
Many functional languages are a bit easier and offer scripting too (Java scripting API).
What about a web project, maybe using jetty as embedded web server. So you may apply HTML and JavaScript. HTML5?
A rich client platform (eclipse or NetBeans) requires experience for rapid development. For nice graphics, maybe JavaFX (too early).
Develop a DSL for your needs using either Groovy or Scala.
We use CodeMirror to provide syntax highlighting in a web page.
Works great for us with Groovy.
I would vote against drools because I have terrible experiences, but some people like it.
I would propose a language already integrated in java: JavaScript. Why?
Is simple enough and has nice access to java beans: instead of
budget.getDealLine() you can use budget.deadLine
you have tons of places to check for information
you can add simple functions to make it more easy to use
But if you choose JavaScript, Python, Drools, ANTLR remember:
Users do not have version control systems like SVN/GIT, so it is up
to you make it happen.
Give them a tool (a webpage or whatever) that automatically save every version of every script they wrote.
Give them a way to test what they wrote without damaging anything.
Give them tools to rollback whatever changes they made.
Make as much static tests as possible once they commit the code before executing it.
Syntax highlighting will make them happier.
And remember: they will use the tool in ways you don't expect, and you will end up writing (or rewriting) most of the scripts. No university degree means you can trust them to understand what they are doing. (Not even CS!)
So if you can make the system less dynamic, would be in your benefit
It's like strategy pattern,all different rules are different algorithm apply to the Context(A),algorithm can be selected at runtime.
Add a filter chain design pattern to that,so that you can choose different algorithms(rules) at the same time.
Roolie is a very simple java rule engine that meight be helpful for you .As Roolie says:
Roolie is an extremely simple Java Rule Engine (Non-JSR 94) that uses rules you create in Java. Simply create your basic rules, implement the single "passes" method for each, then chain them together in an XML file to create more complex rules.
If you had the records in a database, you could select the matching ones with SQL syntax.
For example:
SELECT * FROM data
WHERE budget > 100000
AND privatCredits < 50000

What are the criterias in selecting language groovy vs Java?

What are the parameters considered in selecting groovy on grails framework or plain spring MVC based java application.
Considering a deals site www.deals2buy.com site which has
-rich content(images only) on the website
-reports for the admin
-normal CRUD operations
-heavy traffic on last days of the deals
Which language/technology would you choose for this kind of application?
Thanks in advance.
enthusiasts
My 2ct: if you need each single bit of performance I'd say go straight for Java. But of course given the fact that you can mix and match both, call one from another, you could work in Groovy and call Java for all that needs performance.
Groovy/Grails will give you faster turnaround, scaffolding, gorm, much less code and generally a lot of syntax sugar. And less speed.
Java has speed, and if comparing Java on one of the wide range of available containers to put your web app in, very good and mature management tools (which is good for production!).
But again since Groovy runs on JVM you should be able to develop in Groovy and deploy the app in a Java container and have your management tools (in this scenario Groovy != Grails).
So it will turn down to: how important it is to have good management tools? do you need all the speed you can get? which syntax do you feel more comfortable with? how much development productivity will the generators/gorm buy you (there is nothing you couldn't do in Java)? how do you plan to make your views: JSP, JSF, any other templating framework or prefer groovy templates?

summer experiment: GWT & python for a trading game- arch question

As a summer learning experiment, I'm thinking of coding up a web front end for a trading game i wrote in python, that generates share prices and random snippets of text.
I am sort of struggling with how this should work on the back-end though. I'd rather have my GWT client page interact with the python share price generator, than to try and re-code it in java. I suppose i could use an sqlite db, and then use jdbc to pick up the prices, but i was wondering if there is a better way, for me to be able to poll some python script either from my client page, or from the serverside java code ?
I found this python wrapper, but i'm not sure how i could use it though:
http://code.google.com/apis/visualization/documentation/dev/gviz_api_lib.html
Thanks.
Make no mistake, GWT is a Java technology. You could perhaps interoperate by using Jython to compile your Python code but your UI will basically need to be written in Java (wrappers are second class citizens here). The reason is that the RPC protocol is proprietary and even though GWT is open I believe the compiler that takes the Java source and creates the Javascript (including the RPC calls) isn't.
With Python you might be better off using an RIA Javascript framework like Yahoo UI (YUI), ExtJS, etc. Uki also looks interesting. To give you an example of Uki, here is google Wave layout in 100 lines of Javascript.
I second #cletus' recommendation to go for real javascript plus a JS framework (though as the framework I'd suggest any of jquery, dojo, or google closure -- sorted in order from low to high "formality" -- but I guess that's a question of taste).
If you want a Python-based GWT-like approach, try pyjamas -- but it's not as rich and mature as GWT, so, unless your browser-side needs are really very modest, JS + framework is just a better approach.
Yes you can. Using JSON, you can basically use whatever back-end language you want with GWT. See this page for more detail.
GWT is a powerful tool but nonetheless a complicated one. If you take the time to learn how to use it efficiently, you'll be rocking your way through building you front-end code. You'll also find the Google plugin for Eclipse to be quite a joy.

Reliable web application GUI testing

I'm currently using Selenium for testing our web application's interface. However, it isn't very reliable (it's hard to set a good waiting timeout, absolutely a nightmare to work with in any webpages involving frames) and lacks many features (popups/downloads).
I took a look at http://sikuli.csail.mit.edu/ and quite like it, but again, it isn't very reliable as in very often it fails to identify the correct buttons/links.
What is a good approach for testing web applications?
PS: I'm after the ones that would allow for testing even if the tester has ZERO knowledge about the internal of the codes (not even the method signatures).
Unfortunately, UI testing is not very reliable in general. Having to use XPath, because IDs aren't set on elements on the page. Having to use frames (I hate frames and glad its being deprecated in HTML5).
It's the nature of the beast unfortunately and a major issue I find with Selenium, which is my prefered UI testing tool for browsers, is that people start on the Selenium IDE which tries to record everything you do, but it can only do so much making tests unreliable.
Record/Replay tools should be called Record/Tweak/Replay, so that it can handle tests correctly.
Writing your tests for Selenium RC or WebDriver (these are currently being merged to create Selenium 2) allows you to handle the issues that you may see in Selenium IDE. It makes you write tests using programming languages like Java, Python, C# and many more. Since you can add conditionals to your tests.
The way that I have got less technical people to use Selenium is to create a DSL for them to use, so that it is a more natural language when writing tests.
Have a look at Sahi.
It does not need to wait for Ajax or page loads.
It does not use XPaths, using DOM relations (_near, _in) instead.
It traverses frames/iframes automatically
The recorder works for frames, iframes, and popup windows
It handles auto generated IDs well
The recorder and playback works on almost all browsers and operating systems.
It does not use special privileges to run tests.
Over the last year, Sahi has had seven public releases and the support is prompt on the forums.
Disclaimer: I am the author of Sahi.
Instead of using selenium.waitForPageToLoad("30000"); use like this
selenium.waitForPageToLoad(Timeout);
and don't forget to set the timeout using settimeout option
selenium.setTimeout(Timeout);
I too faced the same issues with the timeout. After setting the timeout, things worked well.

Categories