|
Answer» Let us consider a very simple application that has just a login PAGE in it, wherein submitting correct credentials leads to a successful welcome page and submitting incorrect credentials leads to an error page. Let us assume that the site looks somewhat like this: We will consider the following resource file for our TESTING: *** Settings ***Documentation A resource file with reusable keywords and variables....... The system specific keywords created here form our own... domain specific language. They utilize keywords provided... by the imported SeleniumLibrary.Library SeleniumLibrary*** Variables ***${SERVER} localhost:3000${BROWSER} Chrome${DELAY} 0${VALID USER} user${VALID PASSWORD} password${LOGIN URL} http://${SERVER}/${WELCOME URL} http://${SERVER}/welcome.html${ERROR URL} http://${SERVER}/error.html*** Keywords ***Open Browser To Login Page Open Browser ${LOGIN URL} ${BROWSER} Maximize Browser Window Set Selenium Speed ${DELAY} Login Page Should Be OpenLogin Page Should Be Open Title Should Be Login Page Go To Login Page Go To ${LOGIN URL} Login Page Should Be Open Input Username [Arguments] ${username} Input Text username_field ${username} Input Password [Arguments] ${password} Input Text password_field ${password} Submit Credentials CLICK Button login_button Welcome Page Should Be Open Location Should Be ${WELCOME URL} Title Should Be Welcome PageIn this file, we specify the browser to be USED, the URL to be accessed and all the necessary information required. Next, we declare a test suite named valid_login.robot which has a single test case in it. We input the correct credentials and check if the welcome page opens or not. *** Settings ***Documentation A test suite with a single test for valid login....... This test has a workflow that is created using keywords in... the imported resource file.Resource resource.robot*** Test Cases ***Valid Login Open Browser To Login Page Input Username demo Input Password mode Submit Credentials Welcome Page Should Be Open [Teardown] Close BrowserNext, we declare a test suite named invalid_login.robot which has several test cases in it. We input incorrect credentials and check if the error page opens or not. *** Settings ***Documentation A test suite containing tests related to invalid login....... These tests are data-driven by their nature. They use a single... keyword, specified with Test Template setting, that is called... with different arguments to cover different scenarios....... This suite also demonstrates using setups and teardowns in... different levels.Suite Setup Open Browser To Login PageSuite Teardown Close BrowserTest Setup Go To Login PageTest Template Login With Invalid Credentials Should FailResource resource.robot*** Test Cases *** USER NAME PASSWORDInvalid Username invalid ${VALID PASSWORD}Invalid Password ${VALID USER} invalidInvalid Username And Password invalid whateverEmpty Username ${EMPTY} ${VALID PASSWORD}Empty Password ${VALID USER} ${EMPTY}Empty Username And Password ${EMPTY} ${EMPTY}*** Keywords ***Login With Invalid Credentials Should Fail [Arguments] ${username} ${password} Input Username ${username} Input Password ${password} Submit Credentials Login Should Have FailedLogin Should Have Failed Location Should Be ${ERROR URL} Title Should Be Error PageConclusion:If you are appearing for an interview for a role that requires expertise in the robot framework, you can expect general questions based on automated testing as well. Do not worry, we got you covered. Useful Interview Resources: - AUTOMATION Testing
- API Testing
- Selenium WebDriver
- Cucumber
- Automation Testing Tools
- Python
|