Selenium (2)

17
Case Selenium www.Seleniumonlinetraining.info

description

Course Description Within fast moving agile software development teams it becomes important to test user interfaces as they are being coded. Automated Testing techniques using Selenium 2 allow for test replay of important features as development progresses. Selenium IDE and Selenium Web Driver are important tools for any tester or developer to use in ensuring software quality and making changes with confidence. This interactive, hands-on workshop provides an understanding and advanced techniques in the use of Selenium 2 with hands on practice. The practice exercises are tailored to various skill levels and type of application being tested, from simple forms to complex web applications. Objectives: The class will teach participants to: Understand trade-offs of automated vs. manual testing. Record, edit and play back Selenium IDE tests against multiple types of web applications. Minimize test failure due to normal changes to code. Understanding of basic Selenium commands to get through common issue with web applications. Use of Eclipse to run tests individually and as a group to generate test failure reports. Learn how to help developers understand the importance of making applications more testable to improve usability. Topics: Overview of automated testing Selenium Suite Overview Selenium 2 Limitations Selenium IDE HTML Locator strategy and false test failure Firefox Firebug and reading HTML Selenium Web Driver setup Eclipse and JUnit (Don't Panic it's just code) Convert Selenium IDE tests into Selenium 2 Java WebDriver tests Working with unsupported commands from Selenium IDE Dealing with security and certificates Selenium Web Driver practice workshop Learn how to test in multiple browsers and generate metrics and reports Discussion of setting up Selenium Web Driver for continuous integration Bonus Features: Sample Selenium Web Driver code Scripts to run JUnit test suites on multiple browsers and generate reports and metrics List of web resources and blogs for reference Laminated CSS selector cheat sheet Laminated Selenium 2 command reference Courses Offered in Our Training Institute: 1)Msbi 2)Dotnet 3)SharePoint 2010 4)Testing TOOLs - QTP, QC , Load Runner, Selenium 5)SQL SERVER Visit for the course Details www.mindqonline.com Mail us for details: [email protected] Call me at: +91-9502991277.

Transcript of Selenium (2)

Page 1: Selenium (2)

Case Selenium

www.Seleniumonlinetraining.info

Page 2: Selenium (2)

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

Page 3: Selenium (2)

• 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

Page 4: Selenium (2)

Test expected contentTest linksTest functionsTest dynamic elements…http://seleniumhq.org/docs/

06_test_design_considerations.html#what-to-test

www.Seleniumonlinetraining.info

Page 5: Selenium (2)

• Environment to run Selenium tests• Automated• I know nothing of Robot Framework, but it must be cool

www.Seleniumonlinetraining.info

Page 6: Selenium (2)

• 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

Page 7: Selenium (2)

• 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

Page 8: Selenium (2)

Syntax

command                target                value

eg.

verifyTextPresent    id=phone        0700123123

www.Seleniumonlinetraining.info

Page 9: Selenium (2)

• 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

Page 10: Selenium (2)

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

Page 11: Selenium (2)

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

Page 12: Selenium (2)

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

Page 13: Selenium (2)

B – set breakpointX – execute commandS – set starting point

Good for debugging!

www.Seleniumonlinetraining.info

Page 14: Selenium (2)

Test Samuli’s application Transitions Adding cars, parameters

▪ Test constraints List cars

▪ Added cars are actually listened

www.Seleniumonlinetraining.info

Page 15: Selenium (2)

• 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

Page 16: Selenium (2)

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

Page 17: Selenium (2)

http://seleniumhq.org/docs/index.html

http://code.google.com/p/robotframework/

www.Seleniumonlinetraining.info