Bộ truy xuất (accessors) đánh giá tình trạng của ứng dụng và lưu trữ kết quả đó vào trong một biến được sử dụng cho việc xác minh. Ví dụ: “storeTitle”.
Dưới đây là một số bộ truy xuất Selenium được sử dụng rất thường xuyên.
Command / Syntax | Description |
assertErrorOnNext (message) | Pings Selenium to expect an error on the next command execution with an expected message. |
storeAllButtons (variableName) | Returns the IDs of all buttons on the page. |
storeAllFields (variableName) | Returns the IDs of all input fields on the page. |
storeAllLinks (variableName) | Returns the IDs of all links on the page. |
storeAllWindowIds (variableName) | Returns the IDs of all windows that the browser knows about in an array. |
storeAllWindowTitles (variableName) | Returns the names of all windows that the browser knows about in an array. |
storeAllWindowNames (variableName) | Returns the titles of all windows that the browser knows about in an array. |
storeAttribute (attributeLocator, variableName) | Gets the value of an element attribute. The value of the attribute may differ across browsers. |
storeBodyText (variableName) | Gets the entire text of the page. |
storeConfirmation (variableName) | Retrieves the message of a JavaScript confirmation dialog generated during the previous action. |
storeElementIndex (locator, variableName) | Get the relative index of an element to its parent (starting from 0). |
storeLocation (variableName) | Gets the absolute URL of the current page. |
storeSelectedIds (selectLocator,variableName) | Gets all element IDs for selected options in the specified select or multi-select element. |
storeSelectedIndex (selectLocator, variableName) | Gets index (option number, starting at 0) for selected option in the specified select element. |
storeSelectedLabel (selectLocator, variableName) | Gets label (visible text) for selected option in the specified select element.. |
storeSelectedValue (selectLocator,variableName) | Gets value (value attribute) for selected option in the specified select element. |
storeSelectOptions (selectLocator,variableName) | Gets all labels in the specified select drop-down. |
storeTable (tableCellAddress, variableName) | Gets the text from a cell of a table. The cellAddress syntax: tableLocator.row.column, where row and column start at 0. |
storeText (locator, variableName) | Gets the text of an element. This works for any element that contains text. |
storeTitle (variableName) | Gets the title of the current page. |
storeValue (locator,variableName) | Gets the (whitespace-trimmed) value of an input field. |
storeChecked (locator, variableName) | Gets whether a toggle-button (checkbox/radio) is checked. |
storeElementPresent (locator, variableName) | Verifies that the specified element is somewhere on the page. |
storeTextPresent (pattern, variableName) | Verifies that the specified text pattern appears somewhere on the rendered page shown to the user. |
storeVisible (locator, variableName) | Determines if the specified element is visible. |
Nguồn: tutorialspoint