Automatic fonctional tests can be created with the Selenium extension on the browser Firefox. Selenium tests are located in the folder tests/selenium
.
You can follow this tutorial to create a new test.
To let time to the jQuery to understand what's going on, add the pause
commande , exemple jquery wait for an ajax request to append the results the a form input.
Here is the basic command, it follow the same syntaxe has the selenium log : | command | param1 | param2 |
.
# STORE VARIABLE : store value in variable
# | store | value | variable_name |
| store | test@test.com | email |
# OPEN PAGE : append to the Base URL
# | open | url_segment | |
| open | /account/logout | |
# TYPE TEXT IN INPUT : change the value of the input
# | type | locator | value |
| type | name=email | ${email} |
# SEND KEYS : simulate keystroke events, like if you where really typing (trigger js event)
# | sendKeys | locator | value |
| sendKeys | //input[@name='new-message-name'] | Test 1 2 Test |
# CLICK AND WAIT : click on a element and wait for page load
# | clickAndWait | locator | |
| clickAndWait | //input[@value='Log in'] | |
# CLICK : click on a element
# | click | locator | |
| click | //form[@id='form-new-message']/div/input[@type='submit'] | |
# PAUSE : wait before passing to the next command (let time to the js to do ajax request)
# | pause | num_of_millisec | |
| pause | 3000 | |
# STORE ELEMENT PRESENCE : store if the element is present
# | storeElementPresent | locator | variable_name |
| storeElementPresent | //div[@id='new-message-error'][@class='alert alert-success'] | success |
# STORE TEXT : store the inside text value of an element
# | storeText | locator | variable_name |
| storeText | //div[@id='messages']/div/div[last()][@id] | new_message |
# ASSERT EVAL : gets the result of evaluating the js snippet
# | assertEval | js_code | expecting_value |
| assertEval | javascript{storedVars['last_message'] == storedVars['new_message'];} | false |
# VERIFY ELEMENT PRESENT : verify if an element is on the page
# | verifyElementPresent | locator | |
| verifyElementPresent | //div[@id='appointments'] | |
# ECHO : print value in the selenium log console
# | echo | value | |
| echo | The new message is ${new_message} | |