A chapter in writing maintainable JavaScript today is devoted to Selenium automated testing of JavaScript. After understanding the strong Selenium, hands-on test of Firefox in the Selenium IDE, or quite to the force of the said, in this record.
What is the Selenium IDE?
Selenium IDE: A Firefox plugin that can record the user's basic operations and generate test cases. You can run these test cases to play back in the browser, and you can convert the test cases to automation scripts in other languages.
Once you understand the concept, let's start the magical Selenium IDE tour.
Install Selenium IDE1. Download: http://docs.seleniumhq.org/download/(well, looks like the wall, from here) 2. Install directly, or drag the Xpi file to Firefox to complete the installation. Restart Firefox, see the tool found already more Selenium IDE menu, prove that we have successfully installed ~
How to use? 1. Open the Selenium server interface and click on the IDE in the menu.
2. Click Recording to start recording events (if the status has already started recording, don't start Again)
3. In the interface, enter the user name, password, click the login button, log in successfully, click the Record button again to turn off recording 4. You can see that an event has been automatically generated.
Let's take a look at the meaning of the command here (probably understand the next OK, do not remember), it is easy to understand:
1) Open (URL)
- Open the URL in the browser, you can accept the relative and absolute path two forms
- Note: The URL must be within the same security limits as the browser
2) type (inputlocator, value)
- Simulate manual input process, enter value into specified input
- Also suitable for assigning values to check and radio boxes
3) Click (elementlocator)
- Click the Connect, button, check, and radio boxes
- If you need to wait for a response after clicking, use "Clickandwait"
- If you need to go through the JavaScript Alert or Confirm dialog box before you can continue, you need to call verify or assert to tell Selenium what you expect to do with the dialog box.
5. We find that the last item of Assertalert refers to the handling of alert, where we do not need to delete it. and save the test case as login. 6. Log out and adjust the speed to normal, click on Play current test case, you can find that the login is successful!
7. Finally, according to the same method (try, very simple) registered users are also automated registration, and saved as register, then you can quickly based on the name of test case automated testing.
A little idea:
Selenium IDE can only be used in Firefox, then other browsers will not be available. View the generated file Discovery format is HTML code, then whether the recorded events can be converted to other languages (such as Nodejs, Python), and then through the Web backend server processing, to generate the corresponding interface management, So you can specify a test case (pooled) to start in a browser (IE, chrome) and test it automatically? It's not too soon to be continued ...
Firefox automates dbackup testing with the Selenium IDE