Selenium (2)
-
Upload
onlinemindq -
Category
Education
-
view
218 -
download
4
description
Transcript of Selenium (2)
Case Selenium
www.Seleniumonlinetraining.info
1.Acceptance testing1.What you should test?
2.Robot Framework3.Selenium
1.Syntax2.Xpath3.Command types4.Common commands5.Terms
4.Features5.Demo6.Tips’n’tricks7.Selenium RS
www.Seleniumonlinetraining.info
• vs. unit testing• Acceptance testing = UI testing• Suunto requires us to write tests
o Good• Suunto requires
o use of Seleniumo use of Robot Framework
www.Seleniumonlinetraining.info
Test expected contentTest linksTest functionsTest dynamic elements…http://seleniumhq.org/docs/
06_test_design_considerations.html#what-to-test
www.Seleniumonlinetraining.info
• Environment to run Selenium tests• Automated• I know nothing of Robot Framework, but it must be cool
www.Seleniumonlinetraining.info
• Selenium is a suite of automated tool for testing web application front end – UI test framework
• Selenium emulates browser user• Selenium commands are like "write text "Panu" to input
which id is "name""• Selenium's language supports simple scripting (operators,
defining variables)• Selenium supports multiple methods to locate elements
• Element ID• Element name attribute• Xpath• DOM• CSS
www.Seleniumonlinetraining.info
• XML query language• Features
o Selecting nodes by path by predicates with wildcards
o Axeso Operators
o Examples: • //div[@id='cartable']/table/tbody/tr/td[1]• //input[@value='Jatka']• RTFM: http://www.w3schools.com/XPath/xpath_syntax.asp
www.Seleniumonlinetraining.info
Syntax
command target value
eg.
verifyTextPresent id=phone 0700123123
www.Seleniumonlinetraining.info
• Actions are commands that generally manipulate the state of the application. They do things like “click this link” and “select that option”. If an Action fails, or has an error, the execution of the current test is stopped.
• Accessors examine the state of the application and store the results in variables, e.g. “storeTitle”. They are also used to automatically generate Assertions.
• Assertions are like Accessors, but they verify that the state of the application conforms to what is expected. Examples include “make sure the page title is X” and “verify that this checkbox is checked”.
www.Seleniumonlinetraining.info
Test are divided to • Test suites• Test cases
Test suites are built from test cases.
Both test cases AND test suites should be parameterised.
www.Seleniumonlinetraining.info
open opens a page using a URL. click/clickAndWait performs a click operation, and optionally waits for a new page to load. verifyTitle/assertTitle verifies an expected page title. verifyTextPresent verifies expected text is somewhere on the page. verifyElementPresent verifies an expected UI element, as defined by its HTML tag, is present on the page. verifyText verifies expected text and it’s corresponding HTML tag are present on the page. verifyTable verifies a table’s expected contents. waitForPageToLoad pauses execution until an expected new page loads. Called automatically when clickAndWait is used. waitForElementPresent pauses execution until an expected UI element, as defined by its HTML tag, is present on the page.
www.Seleniumonlinetraining.info
Firefox extensionVery easy to get to know Selenium
and to play with itAlso supports recording and running
test cases / suiteshttp://seleniumhq.org/download/Features
Recording tests, running tests, test cases, test suites, breakpoints, pausing execution, export as code
www.Seleniumonlinetraining.info
B – set breakpointX – execute commandS – set starting point
Good for debugging!
www.Seleniumonlinetraining.info
Test Samuli’s application Transitions Adding cars, parameters
▪ Test constraints List cars
▪ Added cars are actually listened
www.Seleniumonlinetraining.info
• DON’t trust Selenium IDE or it’s default Xpath!• You might have to change HTML code a bit to make it
easier to test automatically, eg. Add id/name attributes• That’s completely OK!
• “AndWait” commands wait until whole page has been loaded• Very useful, but they don’t work with Ajax
• Difference between assert and verify• If asset fails => test stops• If verify fails => test continues
• echo command is good for debugging
www.Seleniumonlinetraining.info
Selenium IDE has a poor support for programming, it does NOT support condition statements iteration logging and reporting of test results error handling, particularly unexpected errors database testing test case grouping re-execution of failed tests test case dependency screenshot capture of test failures
Selenium RS supports adding programming logic to tests .NET supported => though I have no experience
www.Seleniumonlinetraining.info
http://seleniumhq.org/docs/index.html
http://code.google.com/p/robotframework/
www.Seleniumonlinetraining.info