Selenium ppt

35
SELENIUM

description

An overview of Selenium and a brief working of Selenium IDE

Transcript of Selenium ppt

  • 1. SELENIUM

2. INTRODUCTION Selenium is a suite of tools used for browserautomation A well organized tool to develop test cases or testsuites Jason Huggins introduced selenium in 2004 It is developed using java scripts It composed of 4 main componentsIDE, Remote Control, Web Driver and Grid A tool to test the web based applications 3. What it can do? Selenium can test in three regards1. Functional2. Regression and3. Load Testing 4. THE TECHNICAL CHALLENGES IN SELENIUM Selenium Supports only web based applications It doesnt support any non web based (Like Win 32, Java Applet, Java Swing,.Net Client Server etc) applications When you compare selenium with QTP, Silk Test, Test Partner and RFT, thereare many challenges in terms of maintainability of the test cases Since Selenium is a freeware tool, there is no direct support if one is in troublewith the support of applications There is no object repository concept in Selenium, so maintainability of theobjects is very high There are many challenges if one have to interact with Win 32 windows evenwhen you are working with Web based applications Bitmap comparison is not supported by Selenium Any reporting related capabilities, you need to depend on third party tools You need to learn any one of the native language like (.Net, Java, Perl, Python,PHP, Ruby) to work efficiently with the scripting side of selenium. 5. FLEXIBILITY IN SELENIUM Selenium testing suite is highly flexible. There are multiple ways to add functionality to Seleniumframework to customize test automation. As compared to other test automation tools, it is Seleniumsstrongest characteristic. Selenium Remote Control support for multipleprogramming and scripting languages allows the testautomation engineer to build any logic they need into theirautomated testing and to use a preferred programming orscripting language of ones choice. Also, the Selenium testing suite is an open source projectwhere code can be modified and enhancements can besubmitted for contribution 6. SELENIUM - IDE Also known as SIDE Helps the developer and tester in a easier way to drivethe browser in a work flow It is developed with java script It is an Add-on in Mozilla Firefox browser, hence idecan work only for FF browser It can export the recorded test cases to webdriver andwhich can runs in many languages like Perl, Php, Java,Ruby, C#, Phyton etc.. Functional testing tool 7. FEATURES - IDE Record or play back features Debugging step by step and breakpoints Page abstraction functionality User extension that expands the functionality of SIDE 8. ADVANTAGE - IDE Open source tool Easy to install Well organized in developing test cases Exports test cases to many languages and which can beused in RC or Web Driver Allows simple DOM- LEVEL testing at the same time it isused for traditional water fall model to modern Agilemethodology Records Click, typing and other actions to make testcases Auto complete for all common Selenium commands Debug and set breakpoints 9. DISADVANTAGE - IDE Dreary error diagnostics Tests only web applications IDE works with Mozilla Firefox browser only 10. SELENESE A HTML language to drive the elements in the browser There are three types1. Action2. Assertion3. AccessorsAction - is used to perform an action or interactionwith the elements. Eg: open, click, type etc.Assertion to verify or assert the expected value basedon optional or mandatoryAccessors To store a value in a variable 11. Assertion Assert If the expected value is matched if continuesthe next test steps. If not it aborts the test. Assert isused for the mandatory check.Note: While in a test suite it will abort the current testcase and continue the next test case. Verify If the expected value is matched if continuesthe next test steps. If not the test execution willcontinue with the remaining steps. Verify is used forthe optional check. 12. Accessors To store a value in a variablea. To get a value from an element and compare it with thedynamic variableb. To take logical decisions to execute the test stepsc. To execute the loops based on the value it returns 13. Basic Working of SIDESIDE tool componentsRecord and play back featureAssertionsMultiple windows and AjaxDebugging 14. Where to get the SIDE Visit http://docs.seleniumhq.org/ Download tab Selenium IDE version 2.5.0 You should have installed Mozilla FireFox browser Since its a add-on for firefox Once installed go to Tool Selenium IDE(or) In the toolbar you can find Selenium IDE icon 15. SELENIUM IDE TOOL 16. 1. SIDE components Base URL: All open command will be relative to the baseURL (full path). This is the URL that the test will start at. Speed Slider: This slider is used to fast or slow modeduring the play back. (Triangle with 3 lines): Run all the tests in the id (Triangle with 1 line): Run only single test (||): Pause a test that is currently running (bended down arrow): Step through the test once it haspaused Red button- This is the Record button. By default whenwe open the selenium IDE it will be enabled 17. Cont.. Command - It is a select box has a list of all thecommands that are needed to create the test. It is an autocomplete functionality or use the drop down. Target - the location of the element Value - where you place the value that needs to be change. Table view Will keep track all the commands, targetsand values. Source View You will be able to see the HTML that willstore the test Log will show what is happening during the test run. Reference Documentation on the command highlighted 18. 2. Record and Play back Open Mozilla Firefox browser and Selenium IDE By default the record mode is on Write the URL in the Base Url Now what ever you do in the browser those will berecorded in the SIDE Once done stop recording and playback it It will play you back the same action what u have doneduring recording. 19. 3. Assertion Assertion is a check point or verification point to verify The two types are ASSERT and VERIFY While recording when you right on any element youcould find it in the show all available commandassert and verify. While playback it is going to verify the select action The verified command will be glowing dark green incolor. 20. Pattern Matching The pattern matching is plays a vital role in when weuse verify and assert The three major types of pattern matching are1. GLOBBING2. EXACT3. REGULAR EXPRESSION Globbing is handled with ? and * - glob: Exact is used to match the exact word exact: Regular expression is used with the keyword regexp: 21. Examples While you verify or assert in the value specify thepattern matchEg: word id cool which is a dynamically changingelement like pool, mool and foolValue - glob: ?oolWhich accepts any alphabet in the ?s space Exact is the exact word matchEg:Value exact: coolWhich accepts only cool. 22. Regular expression Consider this example2011-05-02451In value - regexp:[0-9]{4}-[0-9]{2}-[0-9]{5,10}So, 2011 all numeric and have 4 char so [0-9]{4}If a text is there: hi this is SeleniumIn Value : [a-z]{2} for hi[A-Z][a-z]{7}SeleniumOr [A-Z].* Selenium* Will accept the remaining alphabets. 23. 4. Multiple window and AJAX1. As we test a page in the same way we can test all theelements on a another page When we click the link for multiple window it maytake time to load the page in the different window atthat time we need to tell selenium to wait using thecommand click and wait2. Ajax is going to load the action at the same page Selenium do not know when does it load? At this timewe need to use wait for the element 24. Multiple windows Open the IDE Launch http://theautomatedtester.co.uk/ Click on Chapter 1 Click on the element Click this to launch anotherwindow A small window will appear where you can even verifythe text. 25. Ajax Open the IDE Launch http://theautomatedtester.co.uk/ Click on Chapter 1 Click on the element Click this link to load a pagewith AJAX On the same page ajax action will be loaded and wecan verify the text 26. 5. Debugging It is not necessary to test the whole test cases We can debug the single or particular commandwhether it is working as expected Three types of debugging1. Double click on the command2. Right click on the command and select execute thiscommand or Click on the command press X3. Toggle breakpoint press B on the commandNote: while debugging make sure the browser is openedwith the URL you are testing 27. Accessors How to store value in a variable?1. Open the IDE and launch the site :http://book.theautomatedtester.co.uk/Chapter12. Right click on any text that you need to store in the text box availablein the page3. Select store Text4. A dialog box will appear and ask you to enter the name of the variable5. Enter a variable name eg: abc6. Now stop recording7. Click on the next blank step where the steps are recording8. Command: Type9. Target: storeinput //{which the id of the textbox}10. Value: ${abc}11. Now run the test12. You can view the selected text in the text box. 28. How it works? We are recording and playing it back fine but how does itworks or how does it verify the particular element in thepage? The selenium IDE is going to find the elements usingLocators The fire bug and fire path add-ons must be installed infirefox which will be helpful for this session. (F12) The different kinds of locators are Id Name CSS or Class name Link Xpath 29. ID A good developer will create the unique ID for eachelements in the page Id is mostly used and also easy to use to locate the element Example for user name and passwords id in gmail account Password Using locator in the fire bug you could get the above details 30. Name Name 31. CSS The syntax is CSS= cssSelector Example: Open IDE Open the site(http://book.theautomatedtester.co.uk/chapter2) Click on firefinder 32. Cont..

(two buttons Button with ID and Sibling Button areinside the div. Id is divontheleft and class is leftdiv) Now in the firefinder enter div.leftdiv input In selenium IDE, Target= (css=div.leftdiv input) Click on find which will highlight the respectivebutton 33. Link The easiest way to find the link In the target: link=(link) Example http://book.theautomatedtester.co.uk/chapter1 Here open http://book.theautomatedtester.co.uk Then in target to open the chapter 1 Type: link=Chapter 1Note: the same format should be given. We should notgive lower or upper as our wish.. 34. Xpath There are two types of X path 1. Complete or Absolute2. partial Most partial is preferred since tomorrow if there are any changesit will be difficult to go with absolute. You will know it why ? Let me differentiate it for the element SIGN IN example for absolute pathhtml/body/div[1]/div[2]/div[2]/form/input[16] Example for partial path.//*[@id='signIn']Note: If suppose any changes happens in any division it could notfind the exact path hence partial is mostly preferred. 35. THE END