Selenium Summary of Usage methods

Source: Internet
Author: User


Basic Introduction:

The Selenium tool is an acceptance testing tool specifically written for Web applications.

The core of selenium: Browser bot, is written in JavaScript.

There are 4 types of Selenium tools: Selenium IDE, Selenium Control, Selenium Core

Here we mainly summarize the Selenium-ide tools

Selenium-ide is only available in the Firefox browser.

Selenium commands are divided into three categories:

Action (Action) , Auxiliary (accessors) and assertions (assertion) :

manipulating Action :

Simulates the user's interaction with a WEB application. Typically used to manipulate the state of an application.

such as clicking on the link, select the option to work in the way. If an action fails, or there is an error, the current test will stop executing.

common commands in operations are : open (Opens page)

Click (TAP)

Clickandwait (click and wait)

Type (text type)

Select (Choose drop-down menu)

Selectwindow (select Pop-up window)

Pause (wait for a specified time, in milliseconds, which is the time to sleep)

Setspeed (set execution speed.) Delay interval length in milliseconds. The default is no delay, which is 0)

SetTimeout (Specifies the wait time for the wait action to complete. The default is 30 seconds.

The actions that need to wait include open and waitfor)

GoBack (simulates the user clicking the "Back" button on their browser)

Close (simulates the user clicking the Close button on the pop-up form or the form's title bar)

The difference between click and clickandwait:

For example, compare the recording script:

Comand Target

Click Css=input[type=submit]//sentence one

Clickandwait CSS=INPUT[TYPE=SUBMIIT]//Sentence two

After turning into PHPUnit, the code is:

$this->click ("css=input[type=submit]"); This sentence corresponds to the above sentence one

$this->click ("css=input[type=submit]"); This sentence and the next sentence, corresponding to the above sentence two

$this->waitforpagetoload ("30000″");

The difference is: after clickandwait, there will be a default page wait time of 30 seconds, and click No wait time;

andwait This suffix tells us that the command will cause the browser to generate a request to the server, allowing selenium to wait for a new page to be loaded.

Auxiliary Accessors :

This is an auxiliary tool. Used to check the state of an application and store the result in a variable.

such as: Storeelementpresent (Locator,variablename)

Where parameters: Locator represents the element locator; variableName the variable name used to store the result.

The state to which the locator is located is stored in the variablename variable.

Returns False if the element appears to return true

Can be used together with assertions.

Assertion Assertion :

Verify that the state of your application is consistent with what you expect.

Common assertions include verifying the contents of a page, such as whether the title is x or the current position is correct, or verifying that the check box is checked.

assertions are used in three modes: Assert , verify , waitfor

When an Assert fails, the test terminates.

When the Verify fails, the test continues to execute and the error is recorded in the day display. This allows this single validation to pass. Make sure that the application is on the correct page.

WAITFOR is used to wait for certain conditions to become true. Tests that can be used for AJAX applications.

If the condition is true, they will execute successfully immediately. If the condition is not true, the test will fail and be paused. Until the current time-out is exceeded. Usually with settimeout time

assertions commonly used are :

Assertlocation (Judging is currently on the right page),

Asserttitle (check that the title of the current page is correct),

Assertvalue (Check the value of input, checkbox or radio, with a value of "on" inaction "off"),

assertselected (check if select is correct in the drop-down menu),

Assertselectedoptions (check if the options in the drop-down menu are correct),

Asserttext (checks the text of the specified element),

Asserttextpresent (checks if the specified text appears on the page currently displayed to the user),

Asserttextnotpresent (checks if the specified text does not appear on the page currently displayed to the user),

Assertattribute (checks the value of the property of the currently specified element),

Asserttable (check the value in a cell in the table),

Asserteditable (checks whether the specified input can be edited),

Assertnoteditable (checks whether the specified input cannot be edited),

Assertalert (check if there is an alert dialog box with the specified message),

Waitforelementpresent (waits for an element to be checked for existence.) Is true, it is executed. )

Selenium Summary of Usage methods

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.