Rookie selenium commands are often called Seleneseand have a series of commands to run test cases.
----// Actions
----// Actions
Actions describe what the user will do.
There are two forms of action: Action and actionandwait, action is executed immediately, and Actionandwait assumes that it takes a long time to get the action's response, while the open will automatically handle the wait time.
================= Example 1 ================================================
Operating instructions:
Open the Google home page, enter the "Selenium Environment Configuration" field and click the "Search" button.
Command Description:
Open
Open (URL)
- Open the URL in the browser , you can accept the relative and absolute path of two forms
- Note: The URL must be within the same security limits as the browser
Highlight (Locator)
- temporarily changes the background color of the specified element to yellow, which facilitates debugging.
Pause
Pause (millisenconds)
- pauses Selenium script execution based on specified time
- commonly used when debugging scripts or waiting for a server segment response
Type
Type (inputlocator, value)
- simulate the input process of the manual and enter values into the specified input
- also suitable for assigning values to check and radio boxes
Click
Click (elementlocator)
- Click Connect ,< Span style= "font-family: Arial" > buttons, check and radio box
- If you need to wait for a response after clicking, use "clickandwait"
- If it is necessary to go through javascriptalert or confirm dialog box to continue operation, you need to call verify or assert Selenium What do you expect to do with the dialog box?
GoBack ()
Analog Click on the browser's Back button
Close ()
Analog Click the browser Close button
=============== Example 2 =======================================
Operating instructions:
Open the Google search home page, select "More" in the top left option, select "Blog" in the drop-down list, then enter "Bug Master" in the Search field, click the Search button, then open my blog (via my URL )
Command Description:
In fact, the new command does not appear in this example, but there is a problem. In the results of the search, the two lines of red are the same and can open my blog.
Click on the character of the page to match, clicking on the link, but open the new window only the address bar; in the click, if the page changes, does not match to I think I entered the keyword, page script will fail.
Open jumps directly through the link, but loses the meaning of the previous search operation. ----- Of course, it's just a matter of presenting it as a question. In real-world projects, we may not be experiencing this situation.
With interest, the above example to verify, is the first example of understanding and strengthen it!
=============== Example 3 =======================================
This example is recorded in the Happy Web registration page, this is not a complete registration, because the last entry requires a verification code. So, even if the recording is complete, it will not play back properly, just to explain a few commands. (*^__^*) hehe ...
You may still find it not intuitive through the table above. Well, look at the following!?
I believe it is very clear that, according to the above explanation.
Operating instructions:
Open Happy Web registration page, fill in the email address, enter the password, repeat the password, enter the name, choose Gender (male and female) choose the year of birth, month, day, select permissions (who can visit my page)
Command Description:
Select
Select (Dropdownlocator, Optionspecifier)
- Select a drop-down menu option according to the Optionspecifier option selector
- If there are more than one selector, such as in wildcard mode, such as "f*b*", or if more than one option has the same text or value, the first match to the value will be selected
Strange command on this one, about the command target part (is id= ... , we can use the Firefox plugin Firebug tool, to view the page elements, the previous explanation, there is not much to say.
----// the command not submitted in the example
The following command I have not found a suitable example to do the demonstration, so, first listed, there is time to do the presentation.
- FireEvent
FireEvent (Elementlocatore,evenname)
Simulates the processing action of a page element event being activated
FireEvent |
TextField |
Focus |
FireEvent |
DropDown |
Blur |
- waitforcondition
waitforcondition (javascriptsnippet,time)
-waits for a certain amount of JavaScript code to return a true value within a limited time, and then stops waiting for
waitforcondit Ion |
var value= "/selenium.gettext (" "foo"); Value.match (/bar/); |
3000 |
- waitforvalue
waitforvalue (inputlocator, value)
-waits for an input ( such as hidden input) is given a value,
-will take turns to detect the value, so be aware that if the value has not been assigned to that input for a long time, it may cause blocking
waitforvalue |
Finishindication |
isfinished |
&NBSP; |
&NBSP; |
&NBSP; |
- Store,strorevalue
Store (Valuetostore, VariableName)
Save a value into the variable.
the value can be either combined from another variable or assigned to a variable by a JavaScript expression
Store |
Mr John Smith |
FullName |
Store |
$.{title} $.{firstname} $.{suname} |
FullName |
Store |
Javascript.{math.round (math.pi*100)/100} |
Pi |
Storevalue |
Inputlocator |
VariableName |
Saves the value in the specified input to a variable
Storevalue |
UserName |
Userid |
Type |
UserName |
$.{userid} |
- storetext, Storeattribute
Storetext (Elementlocator, VariableName)
Assigns the text value of the specified element to the variable
Storetext |
currentdate |
Expectedstartdate |
Verifyvalue |
StartDate |
$.{expectedstartdate} |
Storeattribute (. {}[email protected],variablename.{})
Assigns the value of the attribute of the specified element to the variable
storeattribute |
[email protected] |
classofinput1 |
verifyattribute |
[email protected] |
$.{CLASSOFINPUT1} |
- Choosecancel., answer.
Choosecancelonnextconfirmation ()
-When the next JavaScript pops up the Confirm dialog box, let Selenium select Cancel
-If you do not have the command, you encounter the Confirm dialog box selenium returns True by default, such as manually selecting the OK button
Choosecancelonnextconfirmation |
|
|
-If the command has already been run, the next time the Confirm dialog box appears, you will again select Cancel
Answeronnextprompt (answerstring)
-When the next JavaScript pops up the prompt prompt, give its anweerstring value and select OK
Answeronnextprompt |
Kangaroo |
|
-----Turn
Selenium IDE (iii) Selenium command