17. Using Thread.sleep(Millie Seconds) to pause the execution
Thread.sleep( ) statement belongs to Java's Thread concept.
This statement is used in Selenium Automation to pause the execution for the specified time.
Before understanding the below example you have to understand that 1 second = 1000 Millie seconds.
Example:
Thread.sleep(1000) -> This statement will pause the execution for 1000 Millie seconds (i.e. 1 second).
But if you want the execution to stop for 15 seconds then you have to write down the above statement as shown below:
Thread.sleep(15000) -> This statement will pause the execution for 15000 Millie seconds (i.e. 15 seconds).
Lets Implement This:
1. Start the Selenium RC Driver as explained in our previous Post#14
2. Open the URL using the Selenium RC command as explained in our previous Post#15
3. Maximize the browser window having the opened URL using the Selenium RC command as explained in our previous Post#16
4. Click here to watch the video before inserting the Thread.sleep(20000); statement in between the Open the URL and Maximize the window selenium commands
5. Insert the Thread.sleep(20000); statement between the Open the URL and Maximize the window selenium commands as shown below:
6. Observe that the above Thread.sleep( ) java statement is giving an error as shown below:
7. In order to resolve the error write throws Exception beside the method name which is holding the Thread.sleep( ) statement as shown below and ensure that the error got resolved:
8. Save and Run the code using JUnit and observe that the Test Browser opens the specified URL, gets paused for 20 seconds before maximizing the browser window as shown in the below video:
Click here to watch the video.
This is how the Thread.sleep( ) statement works. But do you really think the Thread.sleep( ) is required to pause for 20 seconds before maximizing the browser window. The Answer is No. We've to use Thread.sleep( ) where ever it is necessary. When to use the Thread.sleep( ) method will be explained in future posts but for now just understand how 'Thread.sleep( )' statement works.
Please comment below to feedback or ask questions.
Using getEval( ) to re-size the test browser window will be explained in the next post.
Subscribe to:
Post Comments (Atom)
Followers
Labels
- aaaa. 1. Introduction to Selenium RC (alias - Selenium 1)
- aaab. 2. Downloading the Selenium RC 1.0.3 and Selenium Standalone Server
- aaac. 3. Configure Projects in Eclipse IDE to work with Selenium RC
- aaad. 4. Configuring Selenium Standalone Server
- aaae. 5. Start the Selenium Standalone Server
- aaaf. 6. Create a JUnit Selenium RC Test using Selenium IDE
- aaag. 7. Ensure compatible Firefox Browser is installed
- aaah. 8. Run the Created Selenium RC Test
- aaai. 9. Introduction to JUnit
- aaai. 9. Using JUnit annotations in our Selenium RC Tests
- aaaj. 10. Eclipse IDE automatically adds package name into the newly created Java Class
- aaak. 11. Writing Selenium RC Test on our own
- aaal. 12. Implementing JUnit Annotations
- aaam. 13. Selenium Class and its Predefined Methods
- aaan. 14. 'start( )' - predefined method to start the Selenium Driver
- aaao. 15. 'open( )' - predefined method to open the specified URL
- aaap. 16. windowMaximize( ) - predefined method to maximize the test browser window
- aaaq. 17. Using Thread.sleep(Millie Seconds) to pause the execution
- aaar. 18. Using getEval( ) to re-size the browser window
- aaas. 19. close( ) - predefined method to close the Test Browser window
- aaat. 20. stop( ) - predefined method to close the Selenium RC Driver window
- aaau. 21. What are Locators ?
- aaav. 22. Different Types of Locators to identify UI elements
- aaaw. 23. Tools in Selenium to find out the locators
- aaax. 24. Locate UI elements by ID
- aaay. 25. Locate UI elements by Name
- aaaz. 26. Locate UI elements by Link
- aaba. 27. Locate UI elements by XPath
- aabb. 28. Locate UI elements by CSS
- aabc. 29. Finding locators for UI elements using the Selenium IDE's recording feature
- aabd. 30. click( ) - predefined method to click links and buttons
- aabe. 31. type( ) - predefined method to enter text
- aabf. 32. click( ) - predefined method to select a radio button
- aabg. 33. Using click( ) predefined method to select a check box
- aabh. 34. Using select( ) method to select a list item from the drop down list
- aabi. 35. Using open( ) method to navigate to the Home page of the provided Base URL
- aabj. 36. Using open( ) method to navigate to the Home page
- aabk. 37. Using open( ) method to navigate to the specific pages of the Base URL
- aabl. 38. Using isTextPresent( ) method to verify whether the text is present on the page
- aabm. 39. Using waitForPageToLoad( ) method
- aabn. 40. Using getHtmlSource( ) method
- aabo. 41. Using getTitle( ) method
- aabp. 42. Using getValue( ) method
- aabq. 43. Using *firefox for running Selenium RC Automation Tests on Firefox Browser
- aabr. 44. Using *googlechrome for running the Selenium RC Automation Tests on Google Chrome Browser
- aabs. 45. Using *iexplore for running the Selenium RC Automation tests on Internet Explorer Browser
- aabt. 46. Using *safari for Running our Tests on Safari Browser
- aabu. 47. View the source code generated by Selenium IDE in Selenium RC format
- aabv. 48. Renaming the Projects and its items using Eclipse IDE 'Refactor' option
- aabw. 49. Refactoring the Selenium Automation Code
- aabx. 50. Identifying few sample real time tests for implementing the Refactoring concept
- aaby. 51. Non-Refactored Selenium Automation code for the tests identified in previous post
- aabz. 52. Only one test should be written inside a test method
- aaca. 53. Using BeforeClass and AfterClass JUnit Annotations
- aacb. 54. Refactoring the Selenium Automation code to make it readable
- aacc. 55. Upgrading Selenium Standalone Server
- aacd. 56. HTML BASICS
- aace. 57. Introduction to XPath
- aacf. 58. Understanding the hierarchy of HTML Source
- aacg. 59. Parse the HTML Source using its hierarchy and find XPath path
- aach. 60. Different types of Nodes in HTML
- aaci. 61. Locate the Element Nodes using Relative XPath
- aacj. 62. XPath Functions
- aack. 63. last( ) - XPath Function
- aacl. 64. position( ) - XPath function
- aacm. 65. Contains( ) - XPath function
- aacn. 66. starts-with( ) XPath Function
- aaco. 67. Other XPath Functions
- aacp. 68. XPath Operators
- aacq. 69. Wild Cards usage in XPath
- aacr. 70. Using node( ) wild card in XPath Statements
- aacs. 71. Using * wild card in XPath Statements
- aact. 72. Using | to combine XPath Statements
- aacu. 73. XPath Optimization
- aacv. 74. XPath Optimization Strategy One - Use the id attribute if available for the element but not used in XPath Statement
- aacw. 75. XPath Optimization Strategy Two - Use the combination of attributes to make the XPath more specific
- aacx. 76. XPath Optimization Strategy Three - If there is really nothing to distinguish find the first unique element from its siblings and add the index value to it
- aacy. 77. XPath Optimization Strategy Four - Use Relative XPath Statements instead of Absolute XPath Statements
- aacz. 78. Practice XPath
- aada. 79. Easy and Regular way of finding XPath Statements for Elements
- aadb. 80. Typing the Text into Text box by Locating the Text Box field with XPath Statement
- aadc. 81. Using isChecked( ) predefined method to get the status of the radio buttons and check box options
- aadd. 82. Selecting values from the Drop down list by locating the Drop down field using XPath Statement
- aade. 83. Using getText( ) predefined method to retrieve the elements text
- aadf. 84. Clicking the Link by locating it Using XPath Statement
- aadg. 85. Clicking the Button by locating it using XPath statement
- aadh. 86. Introduction to CSS selectors
- aadi. 87. html CSS Selector for locating the whole web page
- aadj. 88. body CSS Selector for locating the body of the web page
- aadk. 89. Absolute CSS Selector path
- aadl. 90. Relative CSS Selector path
- aadm. 91. Using # to select an element with a specified id
- aadn. 92. Using [attribute='value'] to select an element containing the specified attribute
- aado. 93. Using dot in CSS path to select an element with a specified class
- aadp. 94. Using [attribute] to select all the element containing the specified attribute
- aadq. 95. Locating first child last child and nth child with CSS path
- aadr. 96. Locating different elements using a single CSS path
- aads. 97. Using * wild card in CSS selector
- aadt. 98. Using ^= $= and *= in CSS selector
- aadu. 99. Using Boolean Operators in CSS selector
- aadv. 100. CSS selector Optimization
- aadw. 101. CSS selector Optimization Strategy One - Use the id attribute if available for the element but not used
- aadx. 102. CSS selector Optimization Strategy Two - Use the combination of attributes to make the CSS selector statement more specific
- aady. 103. CSS selector Optimization Strategy Three - Use Relative CSS Statements instead of Absolute CSS Statements
- aadz. 104. Practice CSS Path
- aaea. 105. Easy and Regular way of finding CSS Path for Elements
- aaeb. 106. Typing the Text into Text box by Locating the Text Box field using CSS Path Statement
- aaec. 107. Using isChecked( ) predefined method to get the status of the radio buttons and check box options
- aaed. 108. Selecting values from the Drop down list by locating the Drop down field using CSS Path Statement
- aaee. 109. Using getText( ) predefined method to retrieve the elements text
- aaef. 110. Clicking the link by locating it using CSS Path Statement
- aaeg. 111. Clicking the Button by locating it using CSS Path statement
- aaeh. 112. Using type command - for entering text into a text box
- aaei. 113. Using type command - for entering text into a password field
- aaej. 114. Using type command - for entering single line text into a Text Area field
- aaek. 115. Using type command - for entering multiple lines of text into a Text Area field
- aael. 116. Using check command to select a checkbox option
- aaem. 117. Using uncheck command to deselect a checkbox option
- aaen. 118. Using click command to select a check box option
- aaeo. 119. Using click command to deselect a check box option
- aaep. 120. Using isChecked( ) method to get the status of the check box option
- aaeq. 121. Using click command to select a radio button
- aaer. 122. Using isChecked( ) method to get the status of the radio button
- aaerb. 122. Using isEditable( ) to find out whether a button is in enabled state or disabled state
- aaerc. 122. Using isEditable( ) command to verify whether the Text Box field is enabled or disabled
- aaes. 123. Using select command to select a list item from the drop down field
- aaet. 124. Using addSelection command to select multiple items from the multi-selection box
- aaeu. 125. Using removeSelection command to deselect selected items from the multi-selection box
- aaev. 126. Using removeAllSelections command to deselect every selected item from the multi-selection box
- aaew. 127. Using type command to browse a file
- aaex. 128. Using click command for clicking a button
- aaey. 129. Using click command for clicking a link
- aaez. 130. Using getValue method with text box field
- aafa. 131. Using getValue method with Password field
- aafb. 132. Using getValue method with Text Area field
- aafc. 133. Using getValue method with drop down field
- aafd. 134. Using isSomethingSelected command with drop down field
- aafe. 135. Using isSomethingSelected command with multi-select field
- aaff. 136. Using getSelectedValue command with drop down field
- aafg. 137. Using getSelectedId command with drop down field
- aafh. 138. Using getSelectedIndex command with drop down field
- aafi. 139. Using getSelectedLabel command with drop down field
- aafj. 140. Using getTitle Method
- aafk. 141. Using getText command
- aafl. 142. Using isTextPresent command
- aafm. 143. Using isElementPresent command
- aafn. 144. Using getXpathCount command
- aafo. 145. Using getBodyText command
- aafp. 146. Using getHTMLSource command
- aafq. 147. Using goBack command
- aafr. 148. Using highlight command
- aafs. 149. Introduction to Ant build tool
- aaft. 150. Installing Ant Tool
- aafu. 151. Introduction to TestNG
- aafv. 152. Installing TestNG in Eclipse IDE
- aafw. 153. Using TestNG Annotations in Selenium RC code
- aafx. 154. Non-Refactored Selenium Automation Code using TestNG framework
- aafy. 155. Only one test should be written inside a single test method
- aafz. 156. Using BeforeClass and AfterClass TestNG Annotations
- aaga. 157. Creating testng.xml configuration file and Running it using TestNG
- aagb. 158. Understanding the usage of verbose attribute in testng configuration file
- aagc. 159. Parameterization of test data
- aagd. 160. Parameterization with testng configuration file
- aage. 161. Create Properties text file
No comments:
Post a Comment