Selenium IDE - Các Lệnh Thường Gặp

Hướng dẫn sử dụng và các lệnh của công cụ kiểm thử giao diện, chức năng Selenium.
Post Reply
huongtran
Fresher Tester
Posts: 16
Joined: Thu 26 Jul, 2012 8:19 am
Contact:

Selenium IDE - Các Lệnh Thường Gặp

Post by huongtran »

Đây là tập hợp các lệnh thường gặp trong Selenium ide, hy vọng có thể giúp ích cho những ai đang tìm hiểu về Selenium như mình.

- Open: Open a URL. url – the URL to open; may be relative or absolute
- Assert: Title
Check the title of a web page.
the title to check
- Click and Wait: Click on a link and wait for the page to load
locator – an element locator
- Click: Click on a link in the page.
locator – an element locator
- Type: Type content into a entry box on the web page.
locator – an element locator
value – the value to type
- Wait: Wait for a number of seconds
time – time to wait in seconds
Capture Screenshot Capture a screenshot of the current page.
- Add Selection: Add a selection to the set of selected options in a multi-select element using an option locator.
locator – an element locator identifying a multi-select box
optionLocator – an option locator (a label by default)
- Alt Key Down: Press the alt key and hold it down until ALTKEYUP is called or a new page is loaded.
- Alt Key Up: Release the alt key.
Answer on Next Prompt
Return the specified answer string in response to the next JavaScript prompt. answer – the answer to give in response to the prompt pop-up
- Check: Check a toggle-button (checkbox/radio). locator – an element locator
- Click At: Clicks on a link, button, checkbox or radio button.
locator – an element locator
coordString – specifies the x,y position (i.e. – 10,20) of the mouse event relative to the element returned by the locator.
Close Simulates the user clicking the “close” button in the titlebar of a popup window or tab.
- Control Key Down: Press the control key and hold it down until doControlUp() is called or a new page is loaded.
- Control Key Up: Release the control key.
- Double Click: Double clicks on a link, button, checkbox or radio button.
locator – an element locator
- Double Click At: Doubleclicks on a link, button, checkbox or radio button.
locator – an element locator
coordString – specifies the x,y position (i.e. – 10,20) of the mouse event relative to the element returned by the locator.
- Drag and Drop: Drags an element a certain distance and then drops it.
locator – an element locator
movementsString – offset in pixels from the current location to which the element should be moved, e.g., “+70,-300″
- Drag and Drop to Object: Drags an element and drops it on another element.
locatorOfObjectToBeDragged – an element to be dragged
locatorOfDragDestinationObject – an element whose location (i.e., whose center-most pixel) will be the point where locatorOfObjectToBeDragged is dropped
- Get Alert: Retrieves the message of a JavaScript alert generated during the previous action, or fail if there were no alerts.
- Get Confirmation: Retrieves the message of a JavaScript confirmation dialog generated during the previous action.
- Get Prompt: Retrieves the message of a JavaScript question prompt dialog generated during the previous action.
- Go Back: Simulates the user clicking the “back” button on their browser.
Is Text Present Verifies that the specified text pattern appears somewhere on the rendered page shown to the user. the text that should appear on the page
- Key Down: Simulates a user pressing a key (without releasing it yet). locator – an element locator keySequence – Either be a string(“\” followed by the numeric keycode of the key to be pressed, normally the ASCII value of that key), or a single character. For example: “w”, “\119″.
- Key Press: Simulates a user pressing and releasing a key. locator – an element locator keySequence – Either be a string(“\” followed by the numeric keycode of the key to be pressed, normally the ASCII value of that key), or a single character. For example: “w”, “\119″.
- Key Up: Simulates a user releasing a key.
locator – an element locator
keySequence – Either be a string(“\” followed by the numeric keycode of the key to be pressed, normally the ASCII value of that key), or a single character. For example: “w”, “\119″.
- Mouse Down: Simulates a user pressing the mouse button (without releasing it yet) on the specified element. locator – an element locator
- Mouse Down At: Simulates a user pressing the mouse button (without releasing it yet) at the specified location.
locator – an element locator
coordString – specifies the x,y position (i.e. – 10,20) of the mouse event relative to the element returned by the locator.
- Mouse Move: Simulates a user pressing and moving the mouse button (without releasing it yet) on the specified element.
locator – an element locator
- Mouse Move At: Simulates a user pressing and moving the mouse button (without releasing it yet) on the specified element.
locator – an element locator
coordString – specifies the x,y position (i.e. – 10,20) of the mouse event relative to the element returned by the locator.
- Mouse Out: Simulates a user moving the mouse pointer away from the specified element.
locator – an element locator
- Mouse Over: Simulates a user hovering a mouse over the specified element.
locator – an element locator
- Mouse Up: Simulates the event that occurs when the user releases the mouse button (i.e., stops holding the button down) on the specified element. locator – an element locator
- Mouse Up At: Simulates the event that occurs when the user releases the mouse button (i.e., stops holding the button down) at the specified location.
locator – an element locator
coordString – specifies the x,y position (i.e. – 10,20) of the mouse event relative to the element returned by the locator.
- Open Window: Opens a popup window (if a window with that ID isn’t already open).
url – the URL to open, which can be blank windowID
– the JavaScript window ID of the window to select
- Refresh: Simulates the user clicking the “Refresh” button on their browser.
- Select: Select an option from a drop-down using an option locator. locator – an element locator identifying a multi-select box optionLocator – an option locator (a label by default)
- Shift Key Down: Press the shift key and hold it down until SHIFTKEYUP is called or a new page is loaded.
- Shift Key Up: Release the shift key.
- Submit: Submit the specified form.
formLocator – an element locator for the form you want to submit
- Type Keys: Simulates keystroke events on the specified element, as though you typed the value key-by-key.
locator – an element locator
value – the value to type
- Uncheck: Uncheck a toggle-button (checkbox/radio)
locator – an element locator

- Select Frame: Selects a frame within the current window.
locator – an element locator identifying a frame or iframe
- Select Window: Selects a popup window; once a popup window has been selected, all commands go to that window. windowID – the JavaScript window ID of the window to select
- Window Focus: Gives focus to the currently selected window
- Store Alert: Stores the message of the most recent JavaScript alert.
- Cancel On Next: Simulate the user clicking Cancel to the next Confirmation.
- OK On Next: Undo the effect of calling ‘Cancel On Next’.
- Create Cookie: Create a new cookie whose path and domain are same with those of current page under test, unless you specified a path for this cookie explicitly. NameValuePair – name and value of the cookie in a format “name=value” optionsString – options for the cookie. Currently supported options include ‘path’ and ‘max_age’. the optionsString’s format is “path=/path/, max_age=60″. The order of options are irrelevant, the unit of the value of ‘max_age’ is second.
- Delete Cookie: Delete a named cookie with specified path. name – the name of the cookie to be deleted. path – the path property of the cookie to be deleted.
- Meta Key Down: Press the meta key and hold it down until ‘Meta Key Up’ command is called or a new page is loaded.
- Meta Key Up: Release the meta key.
- Pause:Wait for the specified amount of time (in milliseconds).
waitTime – the amount of time to sleep (in milliseconds).
- Set Cursor Position: Moves the text cursor to the specified position in the given input element or textarea. This method will fail if the specified element isn’t an input element or textarea. locator – an element locator pointing to an input element or textarea. position – the numerical position of the cursor in the field; position should be 0 to move the position to the beginning of the field. You can also set the cursor to -1 to move it to the end of the field.
- Set Mouse Speed: Configure the number of pixels between “mousemove” events during dragAndDrop commands (default=10). pixels – the number of pixels between “mousemove” events.
- Set Speed: Set execution speed (i.e., set the millisecond length of a delay which will follow each selenium operation). By default, there is no such delay, i.e., the delay is 0 milliseconds. value – the number of milliseconds to pause after operation.
- Wait For Frame To Load: Waits for a new frame to load. FrameAddress – FrameAddress from the server side. timeout – a timeout in milliseconds, after which this command will return with an error.
- Wait For Page To Load:
Waits for a new page to load. Timeout – a timeout in milliseconds, after which this command will return with an error.
- Wait For PopUp: Waits for a popup window to appear and load up.
windowID – the JavaScript window ID of the window that will appear. Timeout – a timeout in milliseconds, after which the action will return with an error.
- Assert Text Present: Asserts if the specified text IS NOT present on the page. The text that should appear on the page
- Assert Text Not Present: Asserts if the specified text IS present on the page. The text that should NOT appear on the page
- Verify Text Present: Verifies that the specified text IS present – if it is not, it is an error. The text that should appear on the page
- Verify Text Not Present: Verifies that the specified text IS NOT present – if it is, it is an error. The text that should NOT appear on the page
- Assert Value: Asserts that the value of the specified input field matches the pattern specified.
locator – an element locator pointing to an input element the text or pattern that should appear in the input field
- Assert Not Value: Asserts that the value of the specified input field DOES NOT match the pattern specified.
locator – an element locator pointing to an input element the text or pattern that should NOT appear in the input field
- Verify Value: Verifies that the value of the specified input field matches the pattern specified.
locator – an element locator pointing to an input element
the text or pattern that should appear in the input field
- Verify Not Value: Verifies that the value of the specified input field DOES NOT match the pattern specified.
locator – an element locator pointing to an input element
The text or pattern that should NOT appear in the input field
- Assert Checked: Asserts that the toggle-button is checked.
locator – an element locator pointing to a toggle-button.
- Assert Not Checked: Asserts that the toggle-button is NOT checked.
locator – an element locator pointing to a toggle-button.
- Verify Checked: Verifies that the toggle-button is checked.
locator – an element locator pointing to a toggle-button.
- Verify Not Checked: Verifies that the toggle-button is NOT checked.
locator – an element locator pointing to a toggle-button.
- Assert Tex: Asserts that the text is present at the specific locator.
locator – an element locator pointing to an element that contains text. The text or pattern that should appear
- Assert Not Text: Asserts that the text is NOT present at the specific locator.
locator – an element locator pointing to an element that contains text. the text or pattern that should NOT appear
- Verify Text: Verifies that the text is present at the specific locator.
locator – an element locator pointing to an element that contains text. the text or pattern that should appear
-Verify Not Text: Verifies that the text is NOT present at the specific locator.
locator – an element locator pointing to an element that contains text.
the text or pattern that should NOT appear
- Assert Alert: Asserts that the value of the alert matches the pattern specified.
the pattern that should appear as the alert
- Assert Alert Not Present: Asserts if an alert is not present
- Assert Alert Present: Asserts if an alert is present
- Store Alert Present:Returns if an alert was present or not.
a dummy variable – the value is NOT stored into it
- Verify Alert: Verifies that the value of the alert matches the pattern specified. the pattern that should appear as the alert
- Verify Alert Not Present: Verifies that an alert IS NOT present.
- Verify Alert Present: Verifies that an alert IS present.
- Wait For Alert: Waits for the alert matching the pattern to appear. the pattern that should appear as the alert
- Wait For Alert Not Present: Waits for an alert not present
- Wait For Alert Present: Waits for an alert to be present
- Assert Confirmation: Asserts that the value of the confirmation matches the pattern specified.
the pattern that should appear as the confirmation.
- Assert Confirmation Not Present: Asserts if a confirmation is NOT present.
- Assert ConfirmationPresent: Asserts if a confirmation is present.
- Store Confirmation: Stores the message from the most recent confirmation.
- Store Confirmation Present: Returns if an confirmation was present or not.
a dummy variable – the value is NOT stored into it
- Verify Confirmation: Verifies that the value of the confirmation matches the pattern specified.
the pattern that should appear as the confirmation.
- Verify Confirmation Not Present: Verifies if a confirmation is NOT present.
- Verify Confirmation Present: Verifies if a confirmation is present.
- Wait For Confirmation: Waits for the confirmation matching the pattern to appear. the pattern that should appear as the confirmation.
- Wait For Confirmation Not Present: Waits for a confirmation not to be present.
- Wait For Confirmation Present: Waits for a confirmation to be present.

Chúc mọi người vui vẻ
You do not have the required permissions to view the files attached to this post.



phuongnt1
Fresher Tester
Posts: 42
Joined: Fri 07 Jan, 2011 11:02 am
Contact:

Re: Selenium IDE - Các Lệnh Thường Gặp

Post by phuongnt1 »

Thanks ban huongtran,
có vẻ cũng khá nhiều lệnh . nếu ban huongtran hoặc bạn nào có ví dụ về phần mouseup, mousermove, mousedown thì xin chỉ giáo giúp ạ.
many thanks.



cd_bently
Jr. Tester
Posts: 83
Joined: Sat 12 Jul, 2014 9:40 pm
Contact:

Re: Selenium IDE - Các Lệnh Thường Gặp

Post by cd_bently »

các lệnh là như thế này nhưng mình phải sử dụng nó như thế nào ạ, em mới tập tành cái này nên chưa biết gì, ai giải thích giúp em với ạ.



Post Reply

Return to “Hướng Dẫn Sử Dụng Selenium”