- Install the selenium plugin on Firefox
First,entre the official website http://www.seleniumhq.org/download/
Click this link.
And click the installation button.
Finally, in the add-on, add selenium ide to the menu bar.
2. Learn to use SeleniumIDE to record scripts and export scripts
Click on the little label to open selenium ide.
Base url Fill in with the URL to test. When we use it, we should click the red button to recording firstly.
It can export scripts in various formats . We usually choose the Junit 4/WebDrive。
3. Write Selenium Java WebDriver program
The code in github URL is https://github.com/zjwjerome/lab2
The first method does not store data. Each cycle tests a use case. But the results can be seen at the end, and it is not easy to see which case is wrong.
The operation results shown in Figure:
We can only see a result in the end.
The second method first stores the data and then uses a parametric test.
Parametric test preparation process is as follows:
A. Specifying a special runtime for the parameterized test class with @RunWith annotation: Parameterized.class;
B. Declare several variables in the test class, which are used to store the expected values and test data and create a constructor for several parameters of the user;
C. Create a static test data feed (feed) method, the return type is Collection, and use @Parameter annotation to modify;
D. Write the test method (with @Test annotation).
The operation results shown in Figure:
It can test each pair of data. The wrong will prompt, and it will not stop running.