I will start using JBehave Web to create tests for a web applications, I've been checking and I saw that Selenium now integrates WebDriver api besides the original one from Selenium.
My question is, which one should I use? The application needs to be tested on Firefox and Internet Explorer and has some Ajax functionalities (although nothing too complex)
Also any reference to some good tutorial or book would be greatly appreciated!
The old Selenium (1.0) API is not really being developed any more, it's all about WebDriver now in Selenium 2.0. I recommend it for future-proofing your code.
Use whichever you feel more comfortable with. The WebDriver API has only recently settled down in Selenium 2.0RC3, while the Selenium RC API hasn't been changed at all in at least a year. artbristol is right that the RC API (what he calls 1.0) isn't being developed further, but it's not going away any time soon either.
As to books, there are two very good ones. Both are great beginner’s books for Selenium and a great deal . Both are available in paperback and as e-books. And if you want to peek at them, both authors or their publishers offer partial downloads for free. The e-book prices are very reasonable, and the paperback prices are competitive.
David Burns’ Selenium 1.0 Testing Tools: Beginner’s Guide, free sample at https://www.packtpub.com/sites/default/files/0264OS-Chapter-6-First-Steps-with-Selenium-RC.pdf?utm_source=packtpub&utm_medium=free&utm_campaign=pdf
Alan Richardson’s Selenium Simplified - Automated Web Testing with Java and Selenium RC, free sample at https://docs.google.com/leaf?id=0B2l9DD6OObL9MGQ3NGU4ODYtZmJlYi00MGY1LWIwNDUtZmM2N2UxODU4OWNm&sort=name&layout=list&num=50).
As far as I know, since the two projects (selenium and webdriver) are merged, the underlying infrastructure is the same. So you shouldn't gain speed by using one API instead of another. You should use the API you like most.
My opinion is that the webdriver API is more convenient. It's much more convenient to use objects and not write procedural code. It shortens your xpaths and makes code easier and much more elegant. Plus, it's easier to write page objects when your working constantly with objects.
Related
I work in a small firm whose product is a relatively simple web-based software. For the last several years we have used Selenium IDE and it's record-and-play functionality. It has delivered 98% of what we need. However, now that Selenium IDE will no longer be working several months from now, we must find an alternative. We considered using Selenium WebDriver, but none of us no know programming and we just don't have the time to all learn it quickly enough to maintain our current testing. So, we are looking for something that has at minimum the following features...
Has record-and-play functionality (as opposed to programming)
Can support multiple web browsers (Firefox, Chrome, IE, Safari)
Can generate reports
Will continue to be supported for years to come
Has either a large user community or good company customer service
Database connect would be nice
Hopefully, we can import our existing Selenium IDE scripts, rather than rewrite them.
We are willing to pay if it's good.
There are literally dozens of options for software and I don't have a clear path to selecting one. Some promising software is...
- Katalon Recorder and Studio. It looks like an excellent replacement for Selenium IDE. But it has small community for help
- QTP - A colleague previously worked with this and recommends it. It looks like an excellent alternative for webdriver, as it allows record and play. But it is very expensive.
Any help is appreciated.
As per your feature requirement here are a couple of viable Selenium IDE alternatives :
Protractor :
Pros :
1. Simple installation. Only a couple of commands needed to install Selenium WebDriver and start testing.
2. Uses JavaScript which is easy to learn with limited programming background.
Cons :
1. Though flexible but still evolving. Setting up the project and the reporting plugins needs a bit of expertise.
2. Requires clear understanding of sync/async behavior.
Katalon Studio :
Pros :
1. No experience required for installation.
2. Unzip the package and ready to go.
3. No additional plug-ins are required.
4. The scripting interface allows an user to switch between the keyword-base table and the code editor.
Cons :
1.Though web automation and mobile automation is achievable API testing module needs more buildup.
Selenium Builder :
Pros :
1. Selenium Builder contains a lot of code from Selenium IDE and Webdriver.
2. The project is getting forked into a modern and a legacy version.
Cons :
1. As of version 40, Firefox requires all extensions to be signed and as it contains code from Selenium IDE and Webdriver it is getting rejected from signing.
2. Getting Selenium Builder into an acceptable state for signing means removing the existing code, which will remove support for Selenium 1.x and support for local playback of Selenium 2.x.
So it's a mix-bag situation and you can always pick one up and drop the other one at your disposal.
QTP I believe has now become UFT (Unified Functional Test) which does have a record option. Unfortunately what you lack in programming, you'll have to make up for in scripting knowledge (VBScript from what I worked with). It's not impossible but would probably take more effort to learn rather than implementing your own free version of Java/Selenium WebDriver. UFT is extremely expensive especially for a small firm which is a per license fee. If I remember right my last job had multiple licenses each $20k a piece.
I am interested in automating repetitive data entry in some forms for a website I frequent. So far the tools I've looked up that would provide support for this in a headless fashion could be Selenium WebDriver and Mechanize.
My question is, is there a fundamental technical difference in using once versus the other? Selenium is mostly used for testing. I've also noticed some folks use it for doing exactly what I'm looking for, and that's automating data entry. Testing becomes a second benefit in that case.
Is there reasons to not use Selenium for what I want to do over Mechanize? Does it not matter and both of these tools will work?
I'm not asking which is better, I'm asking which is the right tool for the job. Perhaps I'm not understanding the premise behind the purpose of each tool.
These are completely different tools that somewhat "cross" in the web-scraping, web automation, automated data extraction scope.
mechanize is a mature and widely-used tool for programmatic web-browsing with a lot of built-in features, like cookie handing, browser history, form submissions. The key thing to understand here is that mechanize.Browser is not a real browser, it cannot execute and understand javascript, it cannot send asynchronous requests often needed to form a web page.
This is where selenium comes into play - it is a browser automation tool which is also widely used in web-scraping. selenium usually becomes a "fall-back" tool - when someone cannot web-scrape a site with mechanize or RoboBrowser or MechanicalSoup (note - another alternatives) because of, for instance, it's javascript "heaviness", the choice is usually selenium. With selenium you can also go headless, automating PhantomJS browser, or having a virtual display. As a commonly mentioned drawback, performance is often mentioned - with selenium you are working with a target site as a real user in a web browser, which is loading additional files needed to form a page, making XHR requests, rendering etc.
And this itself does not mean you should use selenium everywhere - choose the tool wisely, choose it because it fits the problem better, not because you are more familiar with an instrument.
Also note that you should, first, consider using an API (if provided by the target website) instead of going down to web-scraping. And, if it comes to it, be a good web-scraping citizen:
How to be a good citizen when crawling web sites?
Web scraping etiquette
I am new to selenium web testing. Could you tell me how to learn it step by step, and what the technologies are that I need to study?
I suggest you download Selenium IDE or Se Builder, which are user interfaces for recording Selenium tests in-browser. Both let you record and then export tests to a bunch of different languages.
One important thing to note is that there's two Seleniums: original Selenium 1, where tests are comprised of a list of steps to execute in order, and Selenium 2 / Webdriver, which is an API for programming tests.
(Full disclosure: I'm the main developer on Se Builder, so I'm totally biased towards it. I do think it's probably less intimidating for a newcomer, but Selenium IDE is as of time of writing the more established and standard IDE. :) )
UPDATED: Additional resources listed below
The record and playback tools Zarkonnen called out are good starts. You also need to understand the fundamentals of Selenium itself. There's good information on writing tests in code on Selenium HQ's documentation pages.
Three things I think important to get correct from the start:
Learn about locators on pages, learn how to store them in one location (read up on the Page Object Pattern and be careful about record/playback tools which may not help you in that approach)
Learn how to deal with dynamic content (AJAX) with implicit and explicit waits
Learn about modular tests. Write small, reusable components.
If you're working in Ruby then I'd really recommend having a look at Cheezy's page_object gem.
Also, have a look at the various intro pages on the Google WebDriver project page.
Update: You should also consider having a look at Dave Haeffner's Elemental Selenium and his Selenium Guidebook. Both are great resources for real-world stuff people struggle with, not facile, shallow examples.
I've moved from SeleniumRC to WebDriver for nearly two years. But I have to say that I haven't felt there's any obvious advantages for webdriver over rc.
Now I have 200+ test cases with C# driver against a website. But when I run them thoroughly for regression testing, I usually get 150 passed and 50+ failed/errored. After running failed test cases for the second time, many of them passed, only few of them were proven to be issues with the testing code.
As I can see it, sometimes WebDriver is really performing slowly, while I never met with such a situation when I was using SeleniumRC before.
As a result, I started to doubt the necessity to move from rc to webdriver, because it took much more time for me to verify errors and failures than before.
So my question is, are there any advantages for webdriver over rc to make it worth it to move from rc to webdriver? If so, can you please kindly tell me? Also, tell me about the disadvantages.
Selenium RC injects Javascript into the page to drive the interactions. Webdriver interacts directly with the browser. Injecting additional Javascript has disadvantages, with the Selenium HQ site stating it rather well.
While Selenium was a tremendous tool, it wasn’t without its drawbacks.
Because of its Javascript based automation engine and the security
limitations browsers apply to Javascript, different things became
impossible to do. To make things “worst”, webapps became more and more
powerful over time, using all sorts of special features new browsers
provide and making this restrictions more and more painful.
http://seleniumhq.org/docs/01_introducing_selenium.html#selenium-history
Another way to think about it is that testing a page that has had more JS added, you're not really testing the original page; you're testing a modified page.
What #OCary said.
However, the new and more powerful WebDriver has some limitations, too. Because it is a work-in-progress, it's behaviour between different versions changes slightly from time to time. Also, not nearly all intended features have been implemented yet, it will take some more time to have it stable, bug-free and fully developed. For example: the SafariDriver has just landed, the window controls are missed, you can't download files in a convenient way etc.
But a healthy development on WebDriver is better than today's non-existant development on Selenium 1 (It just won't get any better.), right?
From my experience Selenium RC is the most stable and robust web testing framework I have used. I recently started evaluating WebDriver (aka Selenium 2) for the reason that everybody says it is the future of Selenium. So far I am not impressed. Simple things (like clicking a button) do not work consistently across different browsers and require different workarounds.
I realize that there are limitations in what you can do with JavaScript, but I would not want to sacrifice the stability of my tests to get over those limitations.
We are using Qtp as a testing tool, and currently planning to move to an open source testing tool. We have zeroed in on Watir and Selenium as two potential tools for this purpose. We have done some study of these two products and have liked Watir for its neat and powerful API and ease of use. We are only looking at testing on IE; hence cross-browser support provided by Selenium is probably not so important.
But, as my research on Watir progressed, there is one thing about Watir that is disturbing me a little. That is the losing momentum that I see about the product. Most of the articles, success stories and quotes are pretty old - say earlier to 2009. Hardly anything exciting being written about Watir in 2010. To add to this, I hear this story about Webdriver going to replace Watir. Though i couldn't find many articles on Watir-Webdriver, i saw this article on watir that is somewhat of a concern to me as it says watir is DEAD.
http://www.natontesting.com/2010/04/14/explaining-watir-selenium-and-webdriver/
We do not want to start with a product that is probably already dead, or dying.
Can any one please tell me what exactly is happening in Watir and what is the roadmap ahead?
Thanks,
Babitha
You can also check out the source code and it's history directly from GitHub https://github.com/bret/watir/commits/master/ to see if there's any activity.
But it's true that Watir had some longer period of inactivity in terms of releasing new versions http://rubygems.org/gems/watir/versions
As you can see then the time between 1.6.5 and 1.6.6 was almost a year. But nevertheless Watir is not dead nor planning to die. Also, you have got that right about Watir-Webdriver being Watir 2.0 in the future, but i'd not recommend it just yet for IE due to it's early alpha state and some pretty critical bugs. It's repo is here https://github.com/jarib/watir-webdriver
If you have any questions or problems related with Watir, don't be afraid to ask them in here or in Google groups at http://groups.google.com/group/watir-general
Watir is alive. Take a look at watir.com, you will find all information there. If you have further questions, ask.
In the same blog (that the page on natontesting.com mentions), Alister has discussed the impact of web driver on the future of WATIR.
He says:
If you’re a Watir user, it doesn’t really make that much difference. If you think of automated web testing as a car, Watir is the steering wheel and dashboard, which interact with the engine. Allowing Watir users to use WebDriver is like providing an additional engine choice, but keeping the steering wheel and dash the same.
Ultimately, I think that Watir will remain a very popular automated web testing tool, one that has been designed by testers for testers. I can see the usage of WatiN and Watij reducing as more developers move to Selenium 2.0/WebDriver which will offer the same functionality as Watir using a different API and multiple programming languages. If WebDriver can focus on the detail of controlling browsers, ultimately Watir will be a better tool as more effort can be spent on improving the Watir API, upgrading the steering wheel and dash, so to speak.
The point of that article is that both Selenium 2.0 and Watir 2.0 are incorporating Webdriver technology. Watir just put out a new release last month, Watir users are sharing tips everyday on the Watir General mailing list.
If I started a new framework today, I would be most likely to use Watir. I always keep an open mind, so I cannot guarantee what I would use. Maybe the project involves flex so I would try FunFX, or java developers want to be involved so I would consider webdriver with junit. But I would have no concern about using Watir into the future. I have used it for the past three years. I have known people who used it even before that. The community is too strong to die.
We used Watir for a while but ran into problems maintaining our Ruby environment. We're not a Ruby shop, so when we updated our version of Ruby and Watir stopped working we weren't fit to really understand why the breaks were occurring.
The lack of a good recorder was also a problem for us.
So we switched to Selenium, which has great recording capability and runs right in an NUnit test (we're onthe .Net platform), but Selenium doesn't execute successfully every single time. We had to write retry wrappers around the calls since they would work sometimes and not others.
Our quest to find something easily recordable that runs reliably continues. I've seen a lot on the forum about WebDriver and Sahi so I'll look into those. As long as we can spit out XML so we can integrate with CC, we're good.
As you already read, the WATIR community is alive and kicking! I just started the Automated Regression initiative at my company and one of the requirements was to utilize an open source tool (or a group of them). I came across WATIR and since its FOSS, Easy to use, and uses Ruby, I couldn't help but suggest the tool to Management.
Here's a tip (if you want it or not!):
WATIR is great stand-alone, but when bundled with CruiseControl (another FOSS tool that is a CI [Continuous Integration] Server), you can run your regression scripts all day long and get the xUnit reports from it (remember to utilize Ruby's built in Test Unit framework). Makes it real useful for the higher ups and your devs.
WATIR is alive and kicking and just recently came out with an update (1.67). The wiki is killer (http://wiki.openqa.org/display/WTR/) so go there first for your Q&As.
Have Fun with WATIR. Beats the pants outta silly old QTP any day of the week!
Hit me up if you have questions since this is still fresh in my head :)