Việc xác nhận (assertions) cho phép chúng ta xác minh trạng thái của một ứng dụng và so sánh với mong đợi. Nó được sử dụng trong 3 chế độ, viz – “assert”, “verify” and “waitfor”. Ví dụ: “xác minh nếu một item dạng dropdown đã được chọn”.
Dưới đây là danh sách các Selenium assertions thường xuyên được sử dụng.
Command/Syntax | Description |
waitForErrorOnNext (message) | Waits for error; used with the accessor assertErrorOnNext. |
verifySelected(selectLocator, optionLocator) | Verifies that the selected option of a drop-down satisfies the optionSpecifier. |
waitForSelected (selectLocator, optionLocator) | Waits for getting the option selected; used with the accessor assertSelected. |
waitForNotSelected (selectLocator, optionLocator) | Waits for not getting the option selected; used with accessor the assertSelected. |
verifyAlert (pattern) | Verifies the alert text; used the with accessor storeAlert. |
waitForAlert (pattern) | Waits for the alert; used with the accessor storeAlert. |
verifyAllButtons (pattern) | Verifies the button; used with the accessor storeAllButtons. |
waitForAllButtons (pattern) | Waits for the button to load; used with the accessor storeAllButtons. |
verifyAllLinks (pattern) | Verifies all links; used with the accessor storeAllLinks. |
waitForAllLinks (pattern) | Waits for all links; used with the accessor storeAllLinks. |
verifyAllWindowIds (pattern) | Verifies the window id; used with the accessor storeAllWindowIds. |
waitForAllWindowIds (pattern ) | Waits the window id; used with the accessor storeAllWindowIds. |
verifyAttribute(attributeLocator, pattern) | Verifies an attribute of an element; used with the accessor storeAttribute. |
waitForAttribute(attributeLocator, pattern) | Waits for an attribute of an element; used with accessor storeAttribute. |
verifyBodyText(pattern) | Verifies the body text; used with the accessor storeBodyText. |
waitForBodyText(pattern) | Waits for the body text; used with the accessor storeBodyText. |
waitForConfirmation(pattern) | Waits for confirmation; used with the accessor storeConfirmationPresent. |
Nguồn: tutorialspoint