Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Try watir-- from mixed joys and sorrows to bright willows and flowers.

2025-03-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

As I said earlier, web testing based on recording and playback is troublesome and often brings less benefits than trouble. So find another way. After some research, I think that webdriver (that is, selenium 2.0) has a good future and is ready for trial. Webdriver supports multiple languages, and our project is based on java, which is said to be better integrated with the project with java. But considering that you are just getting started, it is necessary to get started quickly, and the lighter the environment, the better. So watir--Web Application Test In Ruby is adopted. My knowledge of ruby is limited to hearing the name, but there are many tutorials online, and rapid testing does not require much in-depth study of the language itself. Another advantage of using ruby is that it is an interpretive language that can be debugged in real time.

It is not difficult to install (it is actually easier than some examples on the Internet, because the version is higher, a lot of work does not need to be prepared)

1. Install ruby, the latest 2.1, I installed is 2.0. All the way through next. (devkit seems to be fine without pretending.)

2.gem update-- system (you don't have to upgrade, and your own version is enough)

3.gem install watir and gem install watir-webdriver (you can take a look at it in gem list, and save this step if it's already included)

4. If you need to test with ie and chrome, download these two drivers: address: ie: http://code.google.com/p/selenium/downloads/list chrome: http://chromedriver.storage.googleapis.com/index.html

(I need to say a few more words about the chrome driver-- because it took me more than ten hours to brainstorm. I found this address when I was checking for errors. Most of the theories on the Internet are http://code.google.com/p/chromedriver/downloads/list here. But the highest version found here is only 2.3. when the chrome version is over 30, it is not applicable. So after I failed the test with chrome, it took me a long time to find out that it was the driver version. The higher the driver version, the better. You have to find the driver corresponding to the chrome version in the address I gave above.)

Let's talk about the problems I found in my simple trial and the final solution.

The 1.chrome driver is one, so I won't repeat it.

two。 Most of the time we quickly start with some simple examples. Such as testing Baidu and google. Because the two pages seem very simple, a text input box and a search button. However, open the source code of Baidu and google home page, we find that the content of these pages is much more complex than shown, page elements are nested layer by layer, it is not easy to find an id and name. So it started to confuse me so much that it made me worry about webdriver.

For example, it's okay for me to use a script to execute in ie, but not for firefox. It makes me lose confidence in using watir for browser compatibility testing. If you have to re-debug the script to change the browser, it's not much different from doing it manually. Later, after careful debugging, it was found that it was the difference caused by the better fault tolerance of the ie driver. Specifically, the name attribute duplicate name of the element in the page is correctly identified in ie, while an error is reported in firefox. Just use the id attribute instead, so that the script is generic.

3. Yet weirder things continue to happen. There is no problem with the execution of a script one day and not the day after. Or changing the machine will not work. What's going on here? After investigation, it is found that the id and name of the elements in the home pages of Baidu and google change-I have not carefully verified whether they change according to the visit ip or the visit period. What a joke. Fortunately, this doesn't happen when testing your own project. So most of the online tutorials with Baidu, google home page as an example is not suitable, it is easy to adjust so that the novice confused.

In this way, it is also a reminder for our own development that the id and name of page elements are as unique and fixed as possible. After finding out the reason, I have some confidence in watir and am ready to use it officially in the project.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 237

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report