Selenium VS WatiJ

来源:互联网 发布:基于标记的分水岭算法 编辑:程序博客网 时间:2024/06/08 13:07

经过深入思考,觉得方向还是在测试,WEB自动化测试。开源的WEB测试工具和脚本语言是这个方向的两大武器。先比较一下两款工具。

原文:http://www.softwaretestingclub.com/profiles/blogs/selenium-vs-watij

Selenium VS WatiJ

My ultimate goal in the last week was to automate smoke tests. 70-80% of the tests involve message sending and reading from message queue (JMS) and the necessary message content string manipulations (parse, find, replace,etc.) only 20-30 % involve UI (i.e. testing cases when wrong message must be fixed manually). JAVA is a natural selection for managing JMS (JAVA message service). To make data transfer from messages to UI and back simpler I want a tool to interact with web UI using JAVA code. There were two natural choices: WatiJ and selenium. 

Choosing the tool
I know some books could tell you how to boild the right process to select a tool. I don't believe them. Let me share my story. Feel free to drop a comment if you think any my step was stupid - I'm not a guru in automation really...
1. Try WatiJ. Colleague of mine have been using WatiJ for quite a while so I chose to use it as I have a person to ask for help. I wasn't able to figure out how to even login.
2. I move to selenium where record-playback help me to prepare JUnit test for logging in without analysing DOM
3. I realize I have no idea how to call selenium methods from my existing code.Selenium generates unit tests not a plain JAVA code.
4. Selenium code shows me that I must select a frame and I can proceed
5. I have no idea how to make my watij click on a tab which is implemented as table cell (neither table tor cell have unique IDs)
6. I move back to selenium as it has no problems with the tab, it use on click unique reference to discover it.
7. I run into problem with selenium, but an hour of investigation shows me that selenium adds extra selenium.selectWindow() during capture, although it is enough to have selenium.selectFrame(). The most interesting fact is that test works from selenium IDE (with select Window), but don't work when exported as JUnit

Conclusions on automation
I has solved the problem and have automated 30% of some tests that take about 2 hours of manual execution . I've done it in a week, spending less than 50% of my time and learned both selenium and watiJ. I know automation guru would say it takes up to 5 times as much time to automate compared to execute, but it took more for me. Perhaps I'm just learning yet, 

Conclusions on tool selection
The problem mentioned in step #7 I only encountered when writing code for logging out current user and logging in a new one. That's something any pilot project would miss, I believe. 
More over I'm still open to switch back to WatiJ. Refeactoring tests from watj to selenim took me a few hours at most. Or maybe I will use both tools? I don't know. 
Why should I choose tools, when they come for free? I don't have to choose a single hammer or screwdriver, I have a couple of them, don't you? I only choose when I see a screw or nail. 

原创粉丝点击