├── .gitignore ├── Ch1 └── simpleapp │ ├── log.html │ ├── output.xml │ ├── report.html │ ├── run.bat │ ├── run.sh │ └── testsuites │ └── Test_Case_1.txt ├── Ch2 ├── Variables │ ├── results │ │ ├── log.html │ │ ├── output.xml │ │ └── report.html │ ├── run.sh │ └── testsuites │ │ ├── 1__Basic_Variable_usage.txt │ │ ├── 2__External_Resource_file_usage.txt │ │ ├── resource_file.txt │ │ ├── variables.py │ │ └── variables.pyc ├── java_based_variables │ ├── results │ │ ├── log.html │ │ ├── output.xml │ │ └── report.html │ ├── run.sh │ └── testsuites │ │ ├── SimpleVariableFile.class │ │ ├── SimpleVariableFile.java │ │ └── Using_simple_variables.txt └── testrf │ ├── results │ ├── log.html │ ├── output.xml │ └── report.html │ ├── run.bat │ ├── run.sh │ └── testsuites │ ├── 1__first_test │ ├── 1__Test_Case_1.txt │ └── 2__Test_Case_2.txt │ └── 2__different_file_formats │ ├── 1__a_tsv_file_test.tsv │ ├── 2__a_tsv_file_test.txt │ ├── 3__pipe_separated_test.txt │ ├── 4__markup_formatted_test.html │ ├── 5__grid_table_formatted_test.txt │ └── 6__reST_file_format.txt ├── Ch3 ├── basic_iteration │ ├── results │ │ ├── log.html │ │ ├── output.xml │ │ └── report.html │ ├── run.sh │ └── testsuites │ │ ├── 1__A_simple_textfile.txt │ │ ├── 2__Basic_Loop.txt │ │ ├── 3__Ranges.txt │ │ └── 4__Continue_Or_Break.txt ├── behavior │ ├── results │ │ ├── log.html │ │ ├── output.xml │ │ └── report.html │ ├── run.sh │ └── testsuites │ │ ├── 1__run_browser_test.txt │ │ └── 2__run_browser_behavior_test.txt ├── collections │ ├── results │ │ ├── log.html │ │ ├── output.xml │ │ └── report.html │ ├── run.bat │ ├── run.sh │ └── testsuites │ │ ├── Collection_Example.txt │ │ ├── testfeeder.py │ │ └── testfeeder.pyc ├── dialogs │ ├── results │ │ ├── log.html │ │ ├── output.xml │ │ └── report.html │ ├── run.bat │ ├── run.sh │ └── testsuites │ │ └── dialog_test.txt ├── dynamic_iteration │ ├── results │ │ ├── log.html │ │ ├── output.xml │ │ └── report.html │ ├── run.bat │ ├── run.sh │ └── testsuites │ │ ├── Python_Variable_User.txt │ │ ├── dynamic_variables.py │ │ └── dynamic_variables.pyc ├── operating_system │ ├── results │ │ ├── log.html │ │ ├── output.xml │ │ └── report.html │ ├── run.bat │ ├── run.sh │ └── testsuites │ │ └── file_operations.txt ├── remotelib │ ├── results │ │ ├── log.html │ │ ├── output.xml │ │ └── report.html │ ├── run.sh │ ├── server │ │ ├── examplelibrary.py │ │ ├── examplelibrary.rb │ │ ├── robotremoteserver.py │ │ ├── robotremoteserver.pyc │ │ └── robotremoteserver.rb │ └── testsuites │ │ └── remote_client_test.txt ├── screenshots │ ├── results │ │ ├── log.html │ │ ├── output.xml │ │ ├── report.html │ │ └── screenpic.jpg │ ├── run.bat │ ├── run.sh │ └── testsuites │ │ └── screenshot_example.txt ├── strings │ ├── results │ │ ├── log.html │ │ ├── output.xml │ │ └── report.html │ ├── run.bat │ ├── run.sh │ └── testsuites │ │ └── string_manipulation.txt ├── telnet │ ├── results │ │ ├── log.html │ │ ├── output.xml │ │ └── report.html │ ├── run.bat │ ├── run.sh │ └── testsuites │ │ └── telnet_test.txt └── templates │ ├── results │ ├── log.html │ ├── output.xml │ └── report.html │ ├── run.sh │ └── testsuites │ └── repeat_actions_for_all.txt ├── Ch4 ├── SwingTest │ ├── libraries │ │ ├── SwingApp.jar │ │ └── swinglibrary-1.6.0.jar │ ├── results │ │ ├── log.html │ │ ├── output.xml │ │ └── report.html │ ├── run.sh │ ├── src │ │ └── SwingApp │ │ │ ├── .classpath │ │ │ ├── .project │ │ │ ├── .settings │ │ │ └── org.eclipse.jdt.core.prefs │ │ │ ├── bin │ │ │ └── org │ │ │ │ └── sumitbisht │ │ │ │ └── sampleapp │ │ │ │ ├── SampleApp$1.class │ │ │ │ ├── SampleApp$2$1.class │ │ │ │ ├── SampleApp$2.class │ │ │ │ ├── SampleApp$3$1.class │ │ │ │ ├── SampleApp$3.class │ │ │ │ └── SampleApp.class │ │ │ └── src │ │ │ └── org │ │ │ └── sumitbisht │ │ │ └── sampleapp │ │ │ └── SampleApp.java │ └── testsuites │ │ └── swing_application_test.txt ├── reference-test-original │ ├── TestToRun.txt │ ├── jybottest.bat │ ├── results │ │ ├── log.html │ │ ├── output.xml │ │ ├── report.html │ │ └── results │ │ │ ├── log.html │ │ │ ├── output.xml │ │ │ └── report.html │ ├── sikuli-script.jar │ ├── testlib │ │ ├── 2ndcase1staction$py.class │ │ ├── 2ndcase1staction.py │ │ ├── TestAction1$py.class │ │ ├── TestAction1.py │ │ ├── anotheraction$py.class │ │ ├── anotheraction.py │ │ ├── common$py.class │ │ ├── common.py │ │ ├── logger$py.class │ │ ├── logger.py │ │ ├── sikuliwrapper$py.class │ │ └── sikuliwrapper.py │ ├── testsuite │ │ └── TestSuite1.txt │ └── xat.exe ├── reference-test-working-as-desired │ ├── Copy of jybottest.bat │ ├── TestToRun.txt │ ├── jybottest.bat │ ├── results │ │ ├── log.html │ │ ├── output.xml │ │ └── report.html │ ├── testlib │ │ ├── 2ndcase1staction$py.class │ │ ├── 2ndcase1staction.py │ │ ├── TestAction1$py.class │ │ ├── TestAction1.py │ │ ├── anotheraction$py.class │ │ ├── anotheraction.py │ │ ├── common$py.class │ │ ├── common.py │ │ ├── logger$py.class │ │ ├── logger.py │ │ ├── sikuliwrapper$py.class │ │ └── sikuliwrapper.py │ ├── testsuite │ │ └── parent │ │ │ ├── FirstSuite.txt │ │ │ ├── hhh │ │ │ └── ThirdSuite.txt │ │ │ └── kane │ │ │ └── SecondSuite.txt │ └── xat.exe └── seleniumTest │ ├── results │ ├── log.html │ ├── output.xml │ ├── report.html │ └── selenium-screenshot-1.png │ ├── run.sh │ ├── src │ └── flaskApp │ │ ├── hello.py │ │ └── templates │ │ ├── layout.html │ │ ├── login.html │ │ └── secure.html │ └── testsuites │ └── login_test.txt ├── LICENSE └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | #Ignore the text editor backups 2 | *.txt~ 3 | *.swp 4 | *~ 5 | -------------------------------------------------------------------------------- /Ch1/simpleapp/output.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Logs the given message with the given level. 8 | 9 | this is a basic test 10 | 11 | this is a basic test 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | Critical Tests 32 | All Tests 33 | 34 | 35 | 36 | 37 | Testsuites 38 | Testsuites.Test Case 1 39 | 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /Ch1/simpleapp/run.bat: -------------------------------------------------------------------------------- 1 | pybot testsuites -------------------------------------------------------------------------------- /Ch1/simpleapp/run.sh: -------------------------------------------------------------------------------- 1 | pybot testsuites -------------------------------------------------------------------------------- /Ch1/simpleapp/testsuites/Test_Case_1.txt: -------------------------------------------------------------------------------- 1 | ***Test Cases*** 2 | 3 | First Test Action log this is a basic test 4 | -------------------------------------------------------------------------------- /Ch2/Variables/results/output.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Logs the given message with the given level. 8 | 9 | ${VARIABLE} 10 | 11 | This is a simple string variable 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | Logs the given message with the given level. 22 | 23 | @{STRINGS}[0] 24 | 25 | a 26 | 27 | 28 | 29 | Logs the given message with the given level. 30 | 31 | this is @{STRINGS}[0] @{STRINGS}[1]. 32 | 33 | this is a collection. 34 | 35 | 36 | 37 | Logs the given message with the given level. 38 | 39 | @{STRINGS}[2] 40 | 41 | of 42 | 43 | 44 | 45 | Logs the given message with the given level. 46 | 47 | @{STRINGS}[3] 48 | 49 | strings 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | Logs the given message with the given level. 60 | 61 | Marks Obtained: ${MARKS} 62 | 63 | Marks Obtained: 65.5 64 | 65 | 66 | 67 | Logs the given message with the given level. 68 | 69 | some days like ${days[0]} are different than ${days[-1]} 70 | 71 | some days like Monday are different than Sunday 72 | 73 | 74 | 75 | Logs the given message with the given level. 76 | 77 | Copyleft, ${details['pub']} 78 | 79 | Copyleft, 2013 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | Test User 98 | 99 | 100 | Logs the given message with the given level. 101 | 102 | Welcome to the customized Test by robot framework, ${username}! 103 | 104 | Welcome to the customized Test by robot framework, Test User! 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 12 113 | 15 114 | 115 | 116 | Logs the given message with the given level. 117 | 118 | Performing some operation over ${arg1} and ${arg2} 119 | 120 | Performing some operation over 12 and 15 121 | 122 | 123 | 124 | 125 | 126 | Logs the given message with the given level. 127 | 128 | User specific keywords used 129 | 130 | User specific keywords used 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | Critical Tests 151 | All Tests 152 | 153 | 154 | 155 | 156 | Testsuites 157 | Testsuites.Basic Variable usage 158 | Testsuites.External Resource file usage 159 | 160 | 161 | 162 | 163 | 164 | -------------------------------------------------------------------------------- /Ch2/Variables/run.sh: -------------------------------------------------------------------------------- 1 | pybot -o results/output -l results/log -r results/report testsuites 2 | -------------------------------------------------------------------------------- /Ch2/Variables/testsuites/1__Basic_Variable_usage.txt: -------------------------------------------------------------------------------- 1 | *** Setting *** 2 | Variables variables.py 3 | *** Variables *** 4 | ${VARIABLE} This is a simple string variable 5 | @{STRINGS} a collection of strings 6 | *** Test Cases *** 7 | 8 | A Simple usage of variables Log ${VARIABLE} 9 | 10 | More complex task Log @{STRINGS}[0] 11 | log this is @{STRINGS}[0] @{STRINGS}[1]. 12 | log @{STRINGS}[2] 13 | log @{STRINGS}[3] 14 | 15 | Use variables from external file Log Marks Obtained: ${MARKS} 16 | log some days like ${days[0]} are different than ${days[-1]} 17 | log Copyleft, ${details['pub']} 18 | -------------------------------------------------------------------------------- /Ch2/Variables/testsuites/2__External_Resource_file_usage.txt: -------------------------------------------------------------------------------- 1 | *** Setting *** 2 | Resource resource_file.txt 3 | 4 | *** Test Cases *** 5 | User Resource Welcome Test User 6 | Perform operation 12 15 7 | Log User specific keywords used -------------------------------------------------------------------------------- /Ch2/Variables/testsuites/resource_file.txt: -------------------------------------------------------------------------------- 1 | *** Setting *** 2 | Documentation this resource file can be be used by tests to use the custom keywords defined here. 3 | 4 | *** Variable *** 5 | 6 | *** Keyword *** 7 | Welcome [Arguments] ${username} 8 | Log Welcome to the customized Test by robot framework, ${username}! 9 | Perform operation [Arguments] ${arg1} ${arg2} 10 | Log Performing some operation over ${arg1} and ${arg2} 11 | -------------------------------------------------------------------------------- /Ch2/Variables/testsuites/variables.py: -------------------------------------------------------------------------------- 1 | # This file contains variable definitions 2 | Weather = [ "London", "Cloudy", 25] 3 | humidity = 75 4 | MARKS = 65.5 5 | DAYS = ["Monday", "Wednesday", "Friday", "Sunday"] 6 | details = {'genre':'open-source','type':'test automation', 'pub':2013} -------------------------------------------------------------------------------- /Ch2/Variables/testsuites/variables.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SumitBisht/RobotFrameworkTestAutomation/21d8e9feda5a5aa1a369f35ecb01706c3c8153a4/Ch2/Variables/testsuites/variables.pyc -------------------------------------------------------------------------------- /Ch2/java_based_variables/results/output.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Logs the given message with the given level. 8 | 9 | Picking up a constant value worth ${CONSTVAL 10 | 11 | Picking up a constant value worth ${CONSTVAL 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | Logs the given message with the given level. 22 | 23 | for a first time writer, ${Publisher} is a good start. 24 | 25 | for a first time writer, Packt is a good start. 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | Logs the given message with the given level. 36 | 37 | The array contents are ${marks[0]}, ${marks[1]}, ${marks[2]} and ${marks[3]} 38 | 39 | The array contents are 12, 15, 11 and 8 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | Logs the given message with the given level. 50 | 51 | and... I forgot on more thing, which is ${marks[4]} 52 | 53 | and... I forgot on more thing, which is 16 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | Logs the given message with the given level. 64 | 65 | ${name} is really good! 66 | 67 | Robot Framework is really good! 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | Critical Tests 88 | All Tests 89 | 90 | 91 | 92 | 93 | Testsuites 94 | Testsuites.Using simple variables 95 | 96 | 97 | 98 | 99 | 100 | -------------------------------------------------------------------------------- /Ch2/java_based_variables/run.sh: -------------------------------------------------------------------------------- 1 | jybot -o results/output -l results/log -r results/report testsuites 2 | -------------------------------------------------------------------------------- /Ch2/java_based_variables/testsuites/SimpleVariableFile.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SumitBisht/RobotFrameworkTestAutomation/21d8e9feda5a5aa1a369f35ecb01706c3c8153a4/Ch2/java_based_variables/testsuites/SimpleVariableFile.class -------------------------------------------------------------------------------- /Ch2/java_based_variables/testsuites/SimpleVariableFile.java: -------------------------------------------------------------------------------- 1 | 2 | public class SimpleVariableFile{ 3 | 4 | /** 5 | * Required due to robot framework initialization requirements. 6 | * this is essential in presence of non empty constructors only! 7 | **/ 8 | public SimpleVariableFile(){ 9 | } 10 | 11 | public static final int CONSTVAL = 12; 12 | public final String Publisher = "Packt"; 13 | public Integer[] marks = new Integer[]{12, 15, 11, 8, 16}; 14 | public String name = "Robot Framework"; 15 | 16 | } 17 | -------------------------------------------------------------------------------- /Ch2/java_based_variables/testsuites/Using_simple_variables.txt: -------------------------------------------------------------------------------- 1 | *** Setting *** 2 | Variables ./SimpleVariableFile.java 3 | 4 | *** Test Cases *** 5 | Test about getting constant Log Picking up a constant value worth ${CONSTVAL 6 | 7 | Test non final writer Log for a first time writer, ${Publisher} is a good start. 8 | 9 | Test entire variable array Log The array contents are ${marks[0]}, ${marks[1]}, ${marks[2]} and ${marks[3]} 10 | 11 | Test some value Log and... I forgot on more thing, which is ${marks[4]} 12 | 13 | Test simple public variables Log ${name} is really good! -------------------------------------------------------------------------------- /Ch2/testrf/results/output.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Fails if `item1` does not contain `item2` one or more times. 9 | 10 | Hello world 11 | world 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | Fails if `item1` contains `item2` one or more times. 23 | 24 | this is the nation 25 | rule 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | Runs the given keyword with the given arguments, if `condition` is true. 45 | 46 | '${char}' == 'c' 47 | Exit For Loop 48 | 49 | 50 | 51 | 52 | Logs the given message with the given level. 53 | 54 | This is the logged message 55 | 56 | This is the logged message 57 | 58 | 59 | 60 | Fails if `item1` does not contain `item2` one or more times. 61 | 62 | baby 63 | ${char} 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | Runs the given keyword with the given arguments, if `condition` is true. 75 | 76 | '${char}' == 'c' 77 | Exit For Loop 78 | 79 | 80 | 81 | 82 | Logs the given message with the given level. 83 | 84 | This is the logged message 85 | 86 | This is the logged message 87 | 88 | 89 | 90 | Fails if `item1` does not contain `item2` one or more times. 91 | 92 | baby 93 | ${char} 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | Runs the given keyword with the given arguments, if `condition` is true. 105 | 106 | '${char}' == 'c' 107 | Exit For Loop 108 | 109 | 110 | Immediately stops executing the enclosing for loop. 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | Logs the given message with the given level. 135 | 136 | this is a dumb drill 137 | 138 | this is a dumb drill 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | Logs the given message with the given level. 161 | 162 | This is a sample log from a tsv file 163 | 164 | This is a sample log from a tsv file 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | Logs the given message with the given level. 175 | 176 | ${MESSAGE} 177 | 178 | [u'Hello World!'] 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | Logs the given message with the given level. 195 | 196 | This is a sample log from a tsv file 197 | 198 | This is a sample log from a tsv file 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | Logs the given message with the given level. 209 | 210 | ${MESSAGE} 211 | 212 | [u'Hello World!'] 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | Fails if `item1` does not contain `item2` one or more times. 229 | 230 | The Times Of India 231 | India 232 | 233 | 234 | 235 | 236 | Fails if `item1` does not contain `item2` one or more times. 237 | 238 | The Times Of India 239 | Of India 240 | 241 | 242 | 243 | 244 | Fails if `item1` does not contain `item2` one or more times. 245 | 246 | The Times Of India 247 | Times 248 | 249 | 250 | 251 | 252 | Fails if `item1` does not contain `item2` one or more times. 253 | 254 | The Times Of India 255 | mes 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | Fails if `item1` does not contain `item2` one or more times. 273 | 274 | The Times Of India 275 | India 276 | 277 | 278 | 279 | 280 | Fails if `item1` does not contain `item2` one or more times. 281 | 282 | The Times Of India 283 | Of India 284 | 285 | 286 | 287 | 288 | Fails if `item1` does not contain `item2` one or more times. 289 | 290 | The Times Of India 291 | Times 292 | 293 | 294 | 295 | 296 | Fails if `item1` contains `item2` one or more times. 297 | 298 | The Times Of India 299 | nothing 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | 318 | 319 | 320 | 321 | 322 | 323 | 324 | 325 | Critical Tests 326 | All Tests 327 | 328 | 329 | 330 | 331 | Testsuites 332 | Testsuites.First Test 333 | Testsuites.First Test.Test Case 1 334 | Testsuites.First Test.Test Case 2 335 | Testsuites.Different File Formats 336 | Testsuites.Different File Formats.A Tsv File Test 337 | Testsuites.Different File Formats.A Tsv File Test 338 | Testsuites.Different File Formats.Pipe Separated Test 339 | Testsuites.Different File Formats.Markup Formatted Test 340 | 341 | 342 | 343 | 344 | 345 | -------------------------------------------------------------------------------- /Ch2/testrf/run.bat: -------------------------------------------------------------------------------- 1 | pybot -o results/output -l results/log -r results/report testsuites -------------------------------------------------------------------------------- /Ch2/testrf/run.sh: -------------------------------------------------------------------------------- 1 | pybot -o results/output -l results/log -r results/report testsuites -------------------------------------------------------------------------------- /Ch2/testrf/testsuites/1__first_test/1__Test_Case_1.txt: -------------------------------------------------------------------------------- 1 | ***Variables*** 2 | @{chars} = a b c d 3 | #@{list}= Set Variable ${ 1, 2, 3, 4} 4 | 5 | ***Test Cases*** 6 | Case present Should Contain Hello world world 7 | 8 | Case not present Should Not Contain this is the nation rule 9 | 10 | Case repeated 11 | :FOR ${char} in @{chars} 12 | \ Run Keyword If '${char}' == 'c' Exit For Loop 13 | # \ Sleep 1s 14 | \ Log This is the logged message 15 | \ Should Contain baby ${char} 16 | -------------------------------------------------------------------------------- /Ch2/testrf/testsuites/1__first_test/2__Test_Case_2.txt: -------------------------------------------------------------------------------- 1 | 2 | ***Test Cases*** 3 | Printing some values log this is a dumb drill -------------------------------------------------------------------------------- /Ch2/testrf/testsuites/2__different_file_formats/1__a_tsv_file_test.tsv: -------------------------------------------------------------------------------- 1 | *Setting* *Value* *Value* *Value* 2 | Library OperatingSystem 3 | 4 | *Variable* *Value* *Value* *Value* 5 | @{MESSAGE} Hello World! 6 | 7 | *Test Case* *Action* *Value* *Value* 8 | the hulk Test Log This is a sample log from a tsv file 9 | another case Log ${MESSAGE} 10 | -------------------------------------------------------------------------------- /Ch2/testrf/testsuites/2__different_file_formats/2__a_tsv_file_test.txt: -------------------------------------------------------------------------------- 1 | *Setting* *Value* *Value* *Value* 2 | Library OperatingSystem 3 | 4 | *Variable* *Value* *Value* *Value* 5 | @{MESSAGE} Hello World! 6 | 7 | *Test Case* 8 | the hulk Test Log This is a sample log from a tsv file 9 | another case Log ${MESSAGE} 10 | -------------------------------------------------------------------------------- /Ch2/testrf/testsuites/2__different_file_formats/3__pipe_separated_test.txt: -------------------------------------------------------------------------------- 1 | ***Test Cases*** 2 | 3 | | Checking if the substring is fine | Should contain | The Times Of India | India | 4 | | | Should contain | The Times Of India | Of India | 5 | | | Should contain | The Times Of India | Times | 6 | | | Should contain | The Times Of India | mes | 7 | -------------------------------------------------------------------------------- /Ch2/testrf/testsuites/2__different_file_formats/4__markup_formatted_test.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | A simple robot framework test created in html 4 | 5 | 6 |

Note that the other content is just another markup and will be safely ignored by the test parser.

7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 |
Test CaseActionArgumentArgument
Checking if the substring is fineShould containThe Times Of IndiaIndia
Should containThe Times Of IndiaOf India
Should containThe Times Of IndiaTimes
Should not containThe Times Of Indianothing
37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 |
Other dataActionArgumentArgument
FailThis test is not ready yet
47 | 48 | -------------------------------------------------------------------------------- /Ch2/testrf/testsuites/2__different_file_formats/5__grid_table_formatted_test.txt: -------------------------------------------------------------------------------- 1 | +-----------+-------------------+---------------+------------+------------+ 2 | | Test Case | Action | Argument | Argument | Argument | 3 | +===========+===================+===============+============+============+ 4 | | Example | [Documentation] | Documentation | for this | test case. | 5 | +-----------+-------------------+---------------+------------+------------+ 6 | | | ... | This can get | quite | long... | 7 | +-----------+-------------------+---------------+------------+------------+ 8 | | | [Tags] | t-1 | t-2 | t-3 | 9 | +-----------+-------------------+---------------+------------+------------+ 10 | | | ... | t-4 | t-5 | | 11 | +-----------+-------------------+---------------+------------+------------+ 12 | | | Do X | one | two | three | 13 | +-----------+-------------------+---------------+------------+------------+ 14 | | | ... | four | five | six | 15 | +-----------+-------------------+---------------+------------+------------+ 16 | | | ${var} = | Get X | 1 | 2 | 17 | +-----------+-------------------+---------------+------------+------------+ 18 | | | ... | 3 | 4 | 5 | 19 | +-----------+-------------------+---------------+------------+------------+ 20 | | | ... | 6 | | | 21 | +-----------+-------------------+---------------+------------+------------+ 22 | | | LOG | It is now ok | ${var} | | 23 | +-----------+-------------------+---------------+------------+------------+ 24 | -------------------------------------------------------------------------------- /Ch2/testrf/testsuites/2__different_file_formats/6__reST_file_format.txt: -------------------------------------------------------------------------------- 1 | ============ ================ ======= ======= 2 | Variable Value Value Value 3 | ============ ================ ======= ======= 4 | ${Existing} 15.46 5 | ============ ================ ======= ======= 6 | 7 | ============= =============== ================ ========== 8 | Test Case Action Argument Argument 9 | ============= =============== ================ ========== 10 | Custom check [Documentation] custom checks 11 | \ Log Starting checks 12 | \ 13 | Another Test Should Be Equal ${Existing} 15.45 14 | ============= =============== ================ ========== 15 | -------------------------------------------------------------------------------- /Ch3/basic_iteration/run.sh: -------------------------------------------------------------------------------- 1 | pybot -o results/output -l results/log -r results/report testsuites -------------------------------------------------------------------------------- /Ch3/basic_iteration/testsuites/1__A_simple_textfile.txt: -------------------------------------------------------------------------------- 1 | ***Test Cases*** 2 | Test a normal case LOG Yay, IT works! 3 | #Try repeating in simple whitespace text file :FOR ${VAR} IN Car Bus Train 4 | # LOG I am driving a ${VAR} 5 | -------------------------------------------------------------------------------- /Ch3/basic_iteration/testsuites/2__Basic_Loop.txt: -------------------------------------------------------------------------------- 1 | | *Variables* | 2 | | @{animals} | cat | horse | turtle | bat | lion | monkey | dog | snake | fish | elephant | 3 | 4 | | *Test Cases* | *Action* | *Argument* | 5 | | Iterate over Arguments | :FOR | ${val} | IN | sedan | convertible | compact | pickup 6 | | | | Log | I am driving a ${val} | 7 | | Process a list | LOG | Processing a list of animals | 8 | | | :FOR | ${animal} | IN | @{animals} | 9 | | | | Log | Animal selected: ${animal} | 10 | | | Log | ended the iteration over a collection of values | 11 | -------------------------------------------------------------------------------- /Ch3/basic_iteration/testsuites/3__Ranges.txt: -------------------------------------------------------------------------------- 1 | | *Test Cases* | *Action* | *Argument* | 2 | | Upto a value | 3 | | | :FOR | ${val} | IN RANGE | 10 | 4 | | | | LOG | loop executing with ${val} | 5 | 6 | | start and end values | 7 | | | :FOR | ${val} | IN RANGE | 6 | 12 | 8 | | | | LOG | now running with ${val} | 9 | 10 | | loop with step of 3 per iteration | 11 | | | :FOR | ${val} | IN RANGE | 10 | 20 | 3 | 12 | | | | LOG | Running with ${val} and skipping 3 values | -------------------------------------------------------------------------------- /Ch3/basic_iteration/testsuites/4__Continue_Or_Break.txt: -------------------------------------------------------------------------------- 1 | | *Test Cases* | *Action* | *Argument* | 2 | | break loop after going past 10 | 3 | | | :FOR | ${val} | IN RANGE | 8 | 15 | 4 | | | | Run Keyword If | ${val} > 10 | Exit For Loop 5 | | | | LOG | Proceeding with ${val} | 6 | | | LOG | Continuing further with the test now that the loop has exited 7 | | another way to break | 8 | | | :FOR | ${var} | IN RANGE | 0 | 10 | 9 | | | | Exit for loop if | ${var} == 2 | 10 | | | | LOG | Running loop with ${var} | 11 | | | LOG | Outside the for loop contents | 12 | | do not process even numbers | 13 | | | :FOR | ${val} | IN RANGE | 0 | 10 | 14 | | | | Run Keyword If | ${val}%2 == 0 | Continue For Loop 15 | | | | LOG | Proceeding with ${val} | 16 | | | LOG | Continuing further with the test now that the loop has exited 17 | | another way to continue | 18 | | | :FOR | ${var} | IN RANGE | 0 | 10 | 19 | | | | Continue for loop if | ${var} > 2 | 20 | | | | LOG | Running loop with ${var} | 21 | | | LOG | Outside the for loop contents | -------------------------------------------------------------------------------- /Ch3/behavior/results/output.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Starts a new process on background. 8 | 9 | firefox 10 | google.com 11 | 12 | Starting process: 13 | ['firefox', 'google.com'] 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | Starts a new process on background. 34 | 35 | ${progname} 36 | ${website} 37 | 38 | Starting process: 39 | ['firefox', 'google.com'] 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | Critical Tests 62 | All Tests 63 | 64 | 65 | 66 | 67 | Testsuites 68 | Testsuites.Run Browser Test 69 | Testsuites.Run Browser Behavior Test 70 | 71 | 72 | 73 | 74 | 75 | -------------------------------------------------------------------------------- /Ch3/behavior/run.sh: -------------------------------------------------------------------------------- 1 | pybot -o results/output -l results/log -r results/report testsuites -------------------------------------------------------------------------------- /Ch3/behavior/testsuites/1__run_browser_test.txt: -------------------------------------------------------------------------------- 1 | ***Setting*** 2 | Library Process 3 | ***Test Cases*** 4 | Open browser to view some website Start Process firefox google.com 5 | -------------------------------------------------------------------------------- /Ch3/behavior/testsuites/2__run_browser_behavior_test.txt: -------------------------------------------------------------------------------- 1 | *** Setting *** 2 | Library Process 3 | 4 | *** Keyword *** 5 | Provide the ${website} homepage on ${progname} browser Start Process ${progname} ${website} 6 | 7 | *** Test Cases *** 8 | Open google page Provide the google.com homepage on firefox browser 9 | -------------------------------------------------------------------------------- /Ch3/collections/results/output.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Verifies that the given item is not empty. 8 | 9 | ${DAYS} 10 | 11 | Length is 4 12 | 13 | 14 | 15 | Fails if `item1` does not contain `item2` one or more times. 16 | 17 | ${DAYS} 18 | Wednesday 19 | 20 | 21 | 22 | 23 | Fails if `item1` contains `item2` one or more times. 24 | 25 | ${DAYS} 26 | Saturday 27 | 28 | 29 | 30 | 31 | Adds `values` to the end of `list`. 32 | 33 | ${DAYS} 34 | Saturday 35 | 36 | 37 | 38 | 39 | Fails if `item1` does not contain `item2` one or more times. 40 | 41 | ${DAYS} 42 | Saturday 43 | 44 | 45 | 46 | 47 | Returns a list containing given items. 48 | 49 | Monday 50 | Wednesday 51 | Friday 52 | Sunday 53 | Saturday 54 | 55 | ${constructed_days} = [u'Monday', u'Wednesday', u'Friday', u'Sunday', u'Saturday'] 56 | 57 | 58 | 59 | Fails if given lists are unequal. 60 | 61 | ${DAYS} 62 | ${constructed_days} 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | Verifies that the given item is not empty. 74 | 75 | ${details} 76 | 77 | Length is 3 78 | 79 | 80 | 81 | Fails if `key` is not found from `dictionary`. 82 | 83 | ${details} 84 | genre 85 | 86 | 87 | 88 | 89 | Fails if `value` is not found from `dictionary`. 90 | 91 | ${details} 92 | open-source 93 | 94 | 95 | 96 | 97 | Removes the given `keys` from the `dictionary`. 98 | 99 | ${details} 100 | genre 101 | 102 | Removed item with key 'genre' and value 'open-source' 103 | 104 | 105 | 106 | Fails if `key` is found from `dictionary`. 107 | 108 | ${details} 109 | genre 110 | 111 | 112 | 113 | 114 | Fails if `value` is found from `dictionary`. 115 | 116 | ${details} 117 | open-source 118 | 119 | 120 | 121 | 122 | Verifies that the length of the given item is correct. 123 | 124 | ${details} 125 | 2 126 | 127 | Length is 2 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | Critical Tests 148 | All Tests 149 | 150 | 151 | 152 | 153 | Testsuites 154 | Testsuites.Collection Example 155 | 156 | 157 | 158 | 159 | 160 | -------------------------------------------------------------------------------- /Ch3/collections/run.bat: -------------------------------------------------------------------------------- 1 | pybot -o results/output -l results/log -r results/report testsuites -------------------------------------------------------------------------------- /Ch3/collections/run.sh: -------------------------------------------------------------------------------- 1 | pybot -o results/output -l results/log -r results/report testsuites -------------------------------------------------------------------------------- /Ch3/collections/testsuites/Collection_Example.txt: -------------------------------------------------------------------------------- 1 | *** Setting *** 2 | Library Collections 3 | Variables testfeeder.py 4 | *** Test Cases *** 5 | Verify lists structure Should not be empty ${DAYS} 6 | Should contain ${DAYS} Wednesday 7 | Should not contain ${DAYS} Saturday 8 | Append to List ${DAYS} Saturday 9 | Should contain ${DAYS} Saturday 10 | ${constructed_days} Create List Monday Wednesday Friday Sunday Saturday 11 | Lists should be equal ${DAYS} ${constructed_days} 12 | 13 | Verify dictionary info Should not be empty ${details} 14 | Dictionary should contain key ${details} genre 15 | Dictionary should contain value ${details} open-source 16 | #Dictionary Should Contain Item ${details} genre open-source 17 | Remove From Dictionary ${details} genre 18 | Dictionary should not contain key ${details} genre 19 | Dictionary should not contain value ${details} open-source 20 | Length Should Be ${details} 2 -------------------------------------------------------------------------------- /Ch3/collections/testsuites/testfeeder.py: -------------------------------------------------------------------------------- 1 | DAYS = ["Monday", "Wednesday", "Friday", "Sunday"] 2 | details = {'genre':'open-source','type':'test automation', 'pub':2013} -------------------------------------------------------------------------------- /Ch3/collections/testsuites/testfeeder.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SumitBisht/RobotFrameworkTestAutomation/21d8e9feda5a5aa1a369f35ecb01706c3c8153a4/Ch3/collections/testsuites/testfeeder.pyc -------------------------------------------------------------------------------- /Ch3/dialogs/results/output.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Logs the given message with the given level. 8 | 9 | Starting test execution 10 | 11 | Starting test execution 12 | 13 | 14 | 15 | Pauses test execution until user sets the keyword status. 16 | 17 | Perform manual operation and continue 18 | 19 | 20 | 21 | 22 | Logs the given message with the given level. 23 | 24 | Continue test execution 25 | 26 | Continue test execution 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | Pauses test execution and asks user to input a value. 37 | 38 | Enter first value 39 | Ravishing Red 40 | 41 | ${selection1} = Ravishing Red 42 | 43 | 44 | 45 | Pauses test execution and asks user to input a value. 46 | 47 | Enter second value 48 | Sparkling Silver 49 | 50 | ${selection2} = Sparkling Silver 51 | 52 | 53 | 54 | Pauses test execution and asks user to input a value. 55 | 56 | Enter third value 57 | Glorious Gold 58 | 59 | ${selection3} = Glorious Gold 60 | 61 | 62 | 63 | Pauses test execution and asks user to input a value. 64 | 65 | Enter fourth value 66 | Whitest White 67 | 68 | ${selection4} = Whitest White 69 | 70 | 71 | 72 | Pauses test execution until user clicks `Ok` button. 73 | 74 | Test execution paused, click OK to continue 75 | 76 | 77 | 78 | 79 | Pauses test execution and asks user to select a value. 80 | 81 | Enter the color to use, cancel to exit. 82 | ${selection1} 83 | ${selection2} 84 | ${selection3} 85 | ${selection4} 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | Critical Tests 107 | All Tests 108 | 109 | 110 | 111 | 112 | Testsuites 113 | Testsuites.Dialog Test 114 | 115 | 116 | 117 | 118 | 119 | -------------------------------------------------------------------------------- /Ch3/dialogs/run.bat: -------------------------------------------------------------------------------- 1 | pybot -o results/output -l results/log -r results/report testsuites -------------------------------------------------------------------------------- /Ch3/dialogs/run.sh: -------------------------------------------------------------------------------- 1 | pybot -o results/output -l results/log -r results/report testsuites -------------------------------------------------------------------------------- /Ch3/dialogs/testsuites/dialog_test.txt: -------------------------------------------------------------------------------- 1 | *** Setting *** 2 | Library Dialogs 3 | *** Test Cases *** 4 | 5 | Use manual entry to continue 6 | Log Starting test execution 7 | Execute Manual Step Perform manual operation and continue 8 | Log Continue test execution 9 | 10 | Obtain user input 11 | ${selection1}= Get Value from user Enter first value Ravishing Red 12 | ${selection2}= Get Value from user Enter second value Sparkling Silver 13 | ${selection3}= Get Value from user Enter third value Glorious Gold 14 | ${selection4}= Get Value from user Enter fourth value Whitest White 15 | Pause Execution Test execution paused, click OK to continue 16 | Get Selection from user Enter the color to use, cancel to exit. ${selection1} ${selection2} ${selection3} ${selection4} -------------------------------------------------------------------------------- /Ch3/dynamic_iteration/results/output.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Fails unless the given variable exists within the current scope. 8 | 9 | @{var} 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | Fails if the given variable exists within the current scope. 21 | 22 | ${val} 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | Logs the given message with the given level. 40 | 41 | finished iteration 42 | 43 | finished iteration 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | Critical Tests 64 | All Tests 65 | 66 | 67 | 68 | 69 | Testsuites 70 | Testsuites.Python Variable User 71 | 72 | 73 | 74 | 75 | 76 | -------------------------------------------------------------------------------- /Ch3/dynamic_iteration/run.bat: -------------------------------------------------------------------------------- 1 | pybot -o results/output -l results/log -r results/report testsuites -------------------------------------------------------------------------------- /Ch3/dynamic_iteration/run.sh: -------------------------------------------------------------------------------- 1 | pybot -o results/output -l results/log -r results/report testsuites -------------------------------------------------------------------------------- /Ch3/dynamic_iteration/testsuites/Python_Variable_User.txt: -------------------------------------------------------------------------------- 1 | | *Setting* | *Value* | 2 | | Variables | ./dynamic_variables.py | 3 | | *Test Cases* | *Action* | *Argument* | 4 | | List should exist | Variable Should Exist | @{var} | 5 | | Variable not declared should not be there | Variable Should Not Exist | ${val} | 6 | | Iterate over Dynamic variables | :FOR | ${val} | IN | @{var} | 7 | | | | Log | ${val} | 8 | | | Log | finished iteration | -------------------------------------------------------------------------------- /Ch3/dynamic_iteration/testsuites/dynamic_variables.py: -------------------------------------------------------------------------------- 1 | import time 2 | 3 | var = [] 4 | while(time.time()%10 <8): 5 | var.append(int(time.time()%10)) 6 | time.sleep(1) 7 | -------------------------------------------------------------------------------- /Ch3/dynamic_iteration/testsuites/dynamic_variables.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SumitBisht/RobotFrameworkTestAutomation/21d8e9feda5a5aa1a369f35ecb01706c3c8153a4/Ch3/dynamic_iteration/testsuites/dynamic_variables.pyc -------------------------------------------------------------------------------- /Ch3/operating_system/results/output.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Fails if the given path points to an existing file. 8 | 9 | ../custom_file 10 | 11 | File '<a href="file://E:\repo\RobotFrameworkTestAutomation\Ch3\custom_file">E:\repo\RobotFrameworkTestAutomation\Ch3\custom_file</a>' does not exist 12 | 13 | 14 | 15 | Creates a file with the given content and encoding. 16 | 17 | ../custom_file 18 | This file is created with robot framework test. 19 | 20 | Created file '<a href="file://E:\repo\RobotFrameworkTestAutomation\Ch3\custom_file">E:\repo\RobotFrameworkTestAutomation\Ch3\custom_file</a>' 21 | 22 | 23 | 24 | Fails unless the given `path` points to an existing file. 25 | 26 | ../custom_file 27 | 28 | File '<a href="file://E:\repo\RobotFrameworkTestAutomation\Ch3\custom_file">E:\repo\RobotFrameworkTestAutomation\Ch3\custom_file</a>' exists 29 | 30 | 31 | 32 | Returns the contents of a specified file. 33 | 34 | ../custom_file 35 | 36 | Getting file '<a href="file://E:\repo\RobotFrameworkTestAutomation\Ch3\custom_file">E:\repo\RobotFrameworkTestAutomation\Ch3\custom_file</a>' 37 | ${contents} = This file is created with robot framework test. 38 | 39 | 40 | 41 | Logs the given message with the given level. 42 | 43 | ${contents} 44 | 45 | This file is created with robot framework test. 46 | 47 | 48 | 49 | Removes a file with the given path. 50 | 51 | ../custom_file 52 | 53 | Removed file '<a href="file://E:\repo\RobotFrameworkTestAutomation\Ch3\custom_file">E:\repo\RobotFrameworkTestAutomation\Ch3\custom_file</a>' 54 | 55 | 56 | 57 | Fails if the given path points to an existing file. 58 | 59 | ../custom_file 60 | 61 | File '<a href="file://E:\repo\RobotFrameworkTestAutomation\Ch3\custom_file">E:\repo\RobotFrameworkTestAutomation\Ch3\custom_file</a>' does not exist 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | Runs the given command in the system and returns the output. 72 | 73 | ls -l 74 | 75 | Running command 'ls -l 2>&1' 76 | ${results} = total 2 77 | drwxr-xr-x 2 laitkor Administrators 0 Sep 26 11:55 results 78 | -rwxr-xr-x 1 laitkor Administrators 67 Sep 26 09:51 run.bat 79 | -rw-r--r-- 1 laitkor Administrators 67 Sep 26 09:51 run.sh 80 | drwxr-xr-x 2 ... 81 | 82 | 83 | 84 | Logs the given message with the given level. 85 | 86 | ${results} 87 | 88 | total 2 89 | drwxr-xr-x 2 laitkor Administrators 0 Sep 26 11:55 results 90 | -rwxr-xr-x 1 laitkor Administrators 67 Sep 26 09:51 run.bat 91 | -rw-r--r-- 1 laitkor Administrators 67 Sep 26 09:51 run.sh 92 | drwxr-xr-x 2 laitkor Administrators 0 Sep 26 12:01 testsuites 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | Sets an environment variable to a specified value. 103 | 104 | Drink 105 | Mineral Water 106 | 107 | Environment variable 'Drink' set to value 'Mineral Water' 108 | 109 | 110 | 111 | Returns the value of an environment variable with the given name. 112 | 113 | Drink 114 | 115 | ${drink} = Mineral Water 116 | 117 | 118 | 119 | Logs the given message with the given level. 120 | 121 | I like drinking ${drink} 122 | 123 | I like drinking Mineral Water 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | Critical Tests 144 | All Tests 145 | 146 | 147 | 148 | 149 | Testsuites 150 | Testsuites.File Operations 151 | 152 | 153 | 154 | 155 | 156 | -------------------------------------------------------------------------------- /Ch3/operating_system/run.bat: -------------------------------------------------------------------------------- 1 | pybot -o results/output -l results/log -r results/report testsuites -------------------------------------------------------------------------------- /Ch3/operating_system/run.sh: -------------------------------------------------------------------------------- 1 | pybot -o results/output -l results/log -r results/report testsuites -------------------------------------------------------------------------------- /Ch3/operating_system/testsuites/file_operations.txt: -------------------------------------------------------------------------------- 1 | *** Setting *** 2 | Library OperatingSystem 3 | *** Test Cases *** 4 | File Operations 5 | File should not exist ../custom_file 6 | Create File ../custom_file This file is created with robot framework test. 7 | File should exist ../custom_file 8 | ${contents} Get File ../custom_file 9 | LOG ${contents} 10 | Remove File ../custom_file 11 | File should not exist ../custom_file 12 | 13 | Call some process 14 | ${results}= Run ls -l 15 | LOG ${results} 16 | 17 | Environment Variables 18 | Set Environment Variable Drink Mineral Water 19 | ${drink} Get Environment Variable Drink 20 | LOG I like drinking ${drink} 21 | -------------------------------------------------------------------------------- /Ch3/remotelib/results/output.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Logs the given message with the given level. 8 | 9 | Checking the string values 10 | 11 | Checking the string values 12 | 13 | 14 | 15 | 16 | 17 | packt 18 | packt 19 | 20 | Comparing 'packt' to 'packt' 21 | 22 | 23 | The variables declared on another robotframework server can be used. 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | Critical Tests 41 | All Tests 42 | 43 | 44 | 45 | 46 | Testsuites 47 | Testsuites.Remote Client Test 48 | 49 | 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /Ch3/remotelib/run.sh: -------------------------------------------------------------------------------- 1 | pybot -o results/output -l results/log -r results/report testsuites 2 | -------------------------------------------------------------------------------- /Ch3/remotelib/server/examplelibrary.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import os 4 | import sys 5 | 6 | class ExampleRemoteLibrary: 7 | def strings_should_be_equal(self, str1, str2): 8 | print "Comparing '%s' to '%s'" % (str1, str2) 9 | if str1 != str2: 10 | raise AssertionError("Given strings are not equal") 11 | else: 12 | return "Given strings are equal" 13 | 14 | 15 | if __name__ == '__main__': 16 | from robotremoteserver import RobotRemoteServer 17 | RobotRemoteServer(ExampleRemoteLibrary(), *sys.argv[1:]) 18 | -------------------------------------------------------------------------------- /Ch3/remotelib/server/examplelibrary.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | class ExampleRemoteLibrary 4 | 5 | def strings_should_be_equal(str1, str2) 6 | puts "Comparing '#{str1}' to '#{str2}'" 7 | if str1 != str2 8 | raise RuntimeError, "Given strings are not equal" 9 | else 10 | return "Given strings are equal" 11 | end 12 | end 13 | end 14 | 15 | if __FILE__ == $0 16 | require "./robotremoteserver" 17 | RobotRemoteServer.new(ExampleRemoteLibrary.new, *ARGV) 18 | end 19 | -------------------------------------------------------------------------------- /Ch3/remotelib/server/robotremoteserver.py: -------------------------------------------------------------------------------- 1 | # Copyright 2008-2013 Nokia Siemens Networks Oyj 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | import sys 16 | import inspect 17 | import traceback 18 | from StringIO import StringIO 19 | from SimpleXMLRPCServer import SimpleXMLRPCServer 20 | try: 21 | import signal 22 | except ImportError: 23 | signal = None 24 | 25 | 26 | class RobotRemoteServer(SimpleXMLRPCServer): 27 | allow_reuse_address = True 28 | 29 | def __init__(self, library, host='localhost', port=8270, allow_stop=True): 30 | SimpleXMLRPCServer.__init__(self, (host, int(port)), logRequests=False) 31 | self._library = library 32 | self._allow_stop = allow_stop 33 | self._register_functions() 34 | self._register_signal_handlers() 35 | self._log('Robot Framework remote server starting at %s:%s' 36 | % (host, port)) 37 | self.serve_forever() 38 | 39 | def _register_functions(self): 40 | self.register_function(self.get_keyword_names) 41 | self.register_function(self.run_keyword) 42 | self.register_function(self.get_keyword_arguments) 43 | self.register_function(self.get_keyword_documentation) 44 | self.register_function(self.stop_remote_server) 45 | 46 | def _register_signal_handlers(self): 47 | def stop_with_signal(signum, frame): 48 | self._allow_stop = True 49 | self.stop_remote_server() 50 | if hasattr(signal, 'SIGHUP'): 51 | signal.signal(signal.SIGHUP, stop_with_signal) 52 | if hasattr(signal, 'SIGINT'): 53 | signal.signal(signal.SIGINT, stop_with_signal) 54 | 55 | def serve_forever(self): 56 | self._shutdown = False 57 | while not self._shutdown: 58 | self.handle_request() 59 | 60 | def stop_remote_server(self): 61 | prefix = 'Robot Framework remote server at %s:%s ' % self.server_address 62 | if self._allow_stop: 63 | self._log(prefix + 'stopping') 64 | self._shutdown = True 65 | else: 66 | self._log(prefix + 'does not allow stopping', 'WARN') 67 | return True 68 | 69 | def get_keyword_names(self): 70 | get_kw_names = getattr(self._library, 'get_keyword_names', None) or \ 71 | getattr(self._library, 'getKeywordNames', None) 72 | if inspect.isroutine(get_kw_names): 73 | names = get_kw_names() 74 | else: 75 | names = [attr for attr in dir(self._library) if attr[0] != '_' 76 | and inspect.isroutine(getattr(self._library, attr))] 77 | return names + ['stop_remote_server'] 78 | 79 | def run_keyword(self, name, args): 80 | result = {'status': 'PASS', 'return': '', 'output': '', 81 | 'error': '', 'traceback': ''} 82 | self._intercept_stdout() 83 | try: 84 | return_value = self._get_keyword(name)(*args) 85 | except: 86 | result['status'] = 'FAIL' 87 | result['error'], result['traceback'] = self._get_error_details() 88 | else: 89 | result['return'] = self._handle_return_value(return_value) 90 | result['output'] = self._restore_stdout() 91 | return result 92 | 93 | def get_keyword_arguments(self, name): 94 | kw = self._get_keyword(name) 95 | if not kw: 96 | return [] 97 | return self._arguments_from_kw(kw) 98 | 99 | def _arguments_from_kw(self, kw): 100 | args, varargs, _, defaults = inspect.getargspec(kw) 101 | if inspect.ismethod(kw): 102 | args = args[1:] # drop 'self' 103 | if defaults: 104 | args, names = args[:-len(defaults)], args[-len(defaults):] 105 | args += ['%s=%s' % (n, d) for n, d in zip(names, defaults)] 106 | if varargs: 107 | args.append('*%s' % varargs) 108 | return args 109 | 110 | def get_keyword_documentation(self, name): 111 | if name == '__intro__': 112 | return inspect.getdoc(self._library) or '' 113 | if name == '__init__' and inspect.ismodule(self._library): 114 | return '' 115 | return inspect.getdoc(self._get_keyword(name)) or '' 116 | 117 | def _get_keyword(self, name): 118 | if name == 'stop_remote_server': 119 | return self.stop_remote_server 120 | kw = getattr(self._library, name, None) 121 | if inspect.isroutine(kw): 122 | return kw 123 | return None 124 | 125 | def _get_error_details(self): 126 | exc_type, exc_value, exc_tb = sys.exc_info() 127 | if exc_type in (SystemExit, KeyboardInterrupt): 128 | self._restore_stdout() 129 | raise 130 | return (self._get_error_message(exc_type, exc_value), 131 | self._get_error_traceback(exc_tb)) 132 | 133 | def _get_error_message(self, exc_type, exc_value): 134 | name = exc_type.__name__ 135 | message = str(exc_value) 136 | if not message: 137 | return name 138 | if name in ('AssertionError', 'RuntimeError', 'Exception'): 139 | return message 140 | return '%s: %s' % (name, message) 141 | 142 | def _get_error_traceback(self, exc_tb): 143 | # Latest entry originates from this class so it can be removed 144 | entries = traceback.extract_tb(exc_tb)[1:] 145 | trace = ''.join(traceback.format_list(entries)) 146 | return 'Traceback (most recent call last):\n' + trace 147 | 148 | def _handle_return_value(self, ret): 149 | if isinstance(ret, (basestring, int, long, float)): 150 | return ret 151 | if isinstance(ret, (tuple, list)): 152 | return [self._handle_return_value(item) for item in ret] 153 | if isinstance(ret, dict): 154 | return dict([(self._str(key), self._handle_return_value(value)) 155 | for key, value in ret.items()]) 156 | return self._str(ret) 157 | 158 | def _str(self, item): 159 | if item is None: 160 | return '' 161 | return str(item) 162 | 163 | def _intercept_stdout(self): 164 | # TODO: What about stderr? 165 | sys.stdout = StringIO() 166 | 167 | def _restore_stdout(self): 168 | output = sys.stdout.getvalue() 169 | sys.stdout.close() 170 | sys.stdout = sys.__stdout__ 171 | return output 172 | 173 | def _log(self, msg, level=None): 174 | if level: 175 | msg = '*%s* %s' % (level.upper(), msg) 176 | print msg 177 | -------------------------------------------------------------------------------- /Ch3/remotelib/server/robotremoteserver.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SumitBisht/RobotFrameworkTestAutomation/21d8e9feda5a5aa1a369f35ecb01706c3c8153a4/Ch3/remotelib/server/robotremoteserver.pyc -------------------------------------------------------------------------------- /Ch3/remotelib/server/robotremoteserver.rb: -------------------------------------------------------------------------------- 1 | # Copyright 2008-2009 Nokia Siemens Networks Oyj 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | 16 | require 'xmlrpc/server' 17 | require 'xmlrpc/utils' 18 | require 'stringio' 19 | 20 | 21 | class RobotRemoteServer < XMLRPC::Server 22 | 23 | def initialize(library, host='localhost', port=8270) 24 | @library = library 25 | super(port, host) # TODO: Disable logging to stdout 26 | add_handler('get_keyword_names') { get_keyword_names } 27 | add_handler('run_keyword') { |name,args| run_keyword(name, args) } 28 | add_handler('get_keyword_arguments') { |name| get_keyword_arguments(name) } 29 | add_handler('get_keyword_documentation') { |name| get_keyword_documentation(name) } 30 | add_handler('stop_remote_server') { shutdown } 31 | puts "Robot Framework remote library started at #{host}:#{port}" 32 | serve 33 | end 34 | 35 | def get_keyword_names 36 | # Implicit methods can't be used as keywords 37 | @library.methods - Object.new.methods 38 | end 39 | 40 | def run_keyword(name, args) 41 | intercept_stdout() 42 | result = {:status=>'PASS', :return=>'', :output=>'', 43 | :error=>'', :traceback=>''} 44 | begin 45 | return_value = @library.send(name, *args) 46 | result[:return] = handle_return_value(return_value) 47 | rescue Exception => exception 48 | result[:status] = 'FAIL' 49 | result[:error] = exception.message 50 | result[:traceback] = "Traceback:\n" + exception.backtrace.join("\n") 51 | end 52 | result[:output] = restore_stdout 53 | return result 54 | end 55 | 56 | def get_keyword_arguments(name) 57 | # This algorithm doesn't return correct number of maximum arguments when 58 | # args have default values. It seems that there's no easy way to get that 59 | # information in Ruby, see e.g. http://www.ruby-forum.com/topic/147614. 60 | # Additionally, it would be much better to return real argument names 61 | # because that information could be used to create library documentation. 62 | arity = @library.method(name).arity 63 | if arity >= 0 64 | return ['arg'] * arity 65 | else 66 | return ['arg'] * (arity.abs - 1) + ['*args'] 67 | end 68 | end 69 | 70 | def get_keyword_documentation(name) 71 | # Is there a way to implement this? Would mainly allow creating a library 72 | # documentation, but if real argument names are not got that's probably 73 | # not so relevant. 74 | '' 75 | end 76 | 77 | private 78 | 79 | def handle_return_value(ret) 80 | if [String, Integer, Fixnum, Float, TrueClass, FalseClass].include?(ret.class) 81 | return ret 82 | elsif ret.class == Array 83 | return ret.collect { |item| handle_return_value(item) } 84 | elsif ret.class == Hash 85 | new_ret = {} 86 | ret.each_pair { |key,value| 87 | new_ret[key.to_s] = handle_return_value(value) 88 | } 89 | return new_ret 90 | else 91 | return ret.to_s 92 | end 93 | end 94 | 95 | def intercept_stdout 96 | $original_stdout = $stdout.dup 97 | @output = '' 98 | $stdout = StringIO.new(@output) 99 | end 100 | 101 | def restore_stdout 102 | $save_for_close = $stdout 103 | $stdout = $original_stdout 104 | $save_for_close.close 105 | return @output 106 | end 107 | 108 | end 109 | -------------------------------------------------------------------------------- /Ch3/remotelib/testsuites/remote_client_test.txt: -------------------------------------------------------------------------------- 1 | *** Setting *** 2 | Library Remote http://localhost:8270 3 | 4 | *** Test Cases *** 5 | 6 | Display [Documentation] The variables declared on another robotframework server can be used. 7 | 8 | Log Checking the string values 9 | strings_should_be_equal packt packt 10 | -------------------------------------------------------------------------------- /Ch3/screenshots/results/output.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Pauses the test executed for the given time. 8 | 9 | 5 10 | 11 | Slept 5 seconds 12 | 13 | 14 | 15 | Takes a screenshot in JPEG format and embeds it into the log file. 16 | 17 | screenpic.jpg 18 | width=500 px 19 | 20 | <a href="screenpic.jpg"><img src="screenpic.jpg" width="500 px"></a> 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | Critical Tests 41 | All Tests 42 | 43 | 44 | 45 | 46 | Testsuites 47 | Testsuites.Screenshot Example 48 | 49 | 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /Ch3/screenshots/results/screenpic.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SumitBisht/RobotFrameworkTestAutomation/21d8e9feda5a5aa1a369f35ecb01706c3c8153a4/Ch3/screenshots/results/screenpic.jpg -------------------------------------------------------------------------------- /Ch3/screenshots/run.bat: -------------------------------------------------------------------------------- 1 | pybot -o results/output -l results/log -r results/report testsuites -------------------------------------------------------------------------------- /Ch3/screenshots/run.sh: -------------------------------------------------------------------------------- 1 | pybot -o results/output -l results/log -r results/report testsuites -------------------------------------------------------------------------------- /Ch3/screenshots/testsuites/screenshot_example.txt: -------------------------------------------------------------------------------- 1 | *** Setting *** 2 | Library Screenshot 3 | *** Test Cases *** 4 | test some screenshots 5 | Sleep 5 6 | Take Screenshot screenpic.jpg width=500 px -------------------------------------------------------------------------------- /Ch3/strings/results/output.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Verifies that the length of the given item is correct. 8 | 9 | Packt 10 | 5 11 | 12 | Length is 5 13 | 14 | 15 | 16 | Verifies that the given item is not empty. 17 | 18 | something 19 | 20 | Length is 9 21 | 22 | 23 | 24 | Fails if the given objects are unequal. 25 | 26 | equal4all 27 | equal4all 28 | 29 | Argument types are: 30 | <type 'unicode'> 31 | <type 'unicode'> 32 | 33 | 34 | 35 | Fails if the given objects are equal. 36 | 37 | Byt4lot 38 | byt4lot 39 | 40 | Argument types are: 41 | <type 'unicode'> 42 | <type 'unicode'> 43 | 44 | 45 | 46 | Fails if `item1` contains `item2` one or more times. 47 | 48 | Robot Framework Test Automation 49 | test 50 | 51 | 52 | 53 | 54 | Fails if `item1` does not contain `item2` one or more times. 55 | 56 | Robot Framework Test Automation 57 | est 58 | 59 | 60 | 61 | 62 | Fails if the string `str1` does not end with the string `str2`. 63 | 64 | Packed Publication 65 | Publication 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | Generates a string with a desired `length` from the given `chars`. 77 | 78 | 6 79 | 80 | ${pin} = G9tOCq 81 | 82 | 83 | 84 | Logs the given message with the given level. 85 | 86 | The generated pin is '${pin}' 87 | 88 | The generated pin is 'G9tOCq' 89 | 90 | 91 | 92 | Returns contents of the `string` after the last occurrence of `marker`. 93 | 94 | Robot Framework Test Automation 95 | Framework 96 | 97 | ${subject} = Test Automation 98 | 99 | 100 | 101 | Logs the given message with the given level. 102 | 103 | The book deals with${subject} 104 | 105 | The book deals with Test Automation 106 | 107 | 108 | 109 | Fails if the given `item` is not a string. 110 | 111 | this is a string 112 | 113 | 114 | 115 | 116 | Fails if the given `item` is a string. 117 | 118 | 24.0 119 | 120 | '24.0' is a string. 121 | 122 | 123 | 124 | 125 | 126 | '24.0' is a string. 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | Critical Tests 141 | All Tests 142 | 143 | 144 | 145 | 146 | Testsuites 147 | Testsuites.String Manipulation 148 | 149 | 150 | 151 | 152 | 153 | -------------------------------------------------------------------------------- /Ch3/strings/run.bat: -------------------------------------------------------------------------------- 1 | pybot -o results/output -l results/log -r results/report testsuites -------------------------------------------------------------------------------- /Ch3/strings/run.sh: -------------------------------------------------------------------------------- 1 | pybot -o results/output -l results/log -r results/report testsuites -------------------------------------------------------------------------------- /Ch3/strings/testsuites/string_manipulation.txt: -------------------------------------------------------------------------------- 1 | *** Setting *** 2 | Library String 3 | *** Test Cases *** 4 | Test builtin keywords first 5 | Length should be Packt 5 6 | Should not be empty something 7 | Should be equal equal4all equal4all 8 | Should not be equal Byt4lot byt4lot 9 | Should not contain Robot Framework Test Automation test 10 | Should contain Robot Framework Test Automation est 11 | Should end with Packed Publication Publication 12 | 13 | Test String library keywords 14 | ${pin}= Generate Random String 6 15 | Log The generated pin is '${pin}' 16 | ${subject} Fetch from right Robot Framework Test Automation Framework 17 | Log The book deals with${subject} 18 | Should be string this is a string 19 | -------------------------------------------------------------------------------- /Ch3/telnet/results/output.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Closes all open connections and empties the connection cache. 8 | 9 | 10 | 11 | 12 | 13 | Opens a new Telnet connection to the given host and port. 14 | 15 | 127.0.0.1 16 | prompt=test 17 | 18 | Opening connection to 127.0.0.1:23 with prompt: test 19 | 20 | 21 | 22 | Logs in to the Telnet server with the given user information. 23 | 24 | test 25 | test 26 | login_prompt=login: 27 | password_prompt=password: 28 | 29 | Welcome to Microsoft Telnet Service 30 | 31 | login: test 32 | password: 33 | 34 | *=============================================================== 35 | Microsoft Telnet Server. 36 | *=============================================================== 37 | C:\Users\test 38 | 39 | 40 | 41 | Executes the given `command` and reads, logs, and returns everything until the prompt. 42 | 43 | ls -l 44 | 45 | >ls -l 46 | total 1369 47 | drwxr-xr-x 5 test 48 | ${details} = total 1369 49 | drwxr-xr-x 5 test 50 | 51 | 52 | 53 | Logs the given message with the given level. 54 | 55 | ${details} 56 | 57 | total 1369 58 | drwxr-xr-x 5 test 59 | 60 | 61 | 62 | Reads output until the prompt is encountered. 63 | 64 | 65 | Administrators 0 Sep 26 16:14 AppData 66 | drwxr-xr-x 0 test 67 | ${output} = Administrators 0 Sep 26 16:14 AppData 68 | drwxr-xr-x 0 test 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | Critical Tests 89 | All Tests 90 | 91 | 92 | 93 | 94 | Testsuites 95 | Testsuites.Telnet Test 96 | 97 | 98 | 99 | 100 | 101 | -------------------------------------------------------------------------------- /Ch3/telnet/run.bat: -------------------------------------------------------------------------------- 1 | pybot -o results/output -l results/log -r results/report testsuites -------------------------------------------------------------------------------- /Ch3/telnet/run.sh: -------------------------------------------------------------------------------- 1 | pybot -o results/output -l results/log -r results/report testsuites -------------------------------------------------------------------------------- /Ch3/telnet/testsuites/telnet_test.txt: -------------------------------------------------------------------------------- 1 | *** Setting *** 2 | Library Telnet 3 | *** Test Cases *** 4 | Do a telnet session 5 | Close all connections 6 | Open Connection 127.0.0.1 prompt=test 7 | Login test test login_prompt=login: password_prompt=password: 8 | ${details} Execute Command ls -l 9 | log ${details} 10 | ${output} Read Until Prompt 11 | Close Connection -------------------------------------------------------------------------------- /Ch3/templates/results/output.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Logs the given message with the given level. 8 | 9 | sumit 10 | 11 | sumit 12 | 13 | 14 | 15 | Logs the given message with the given level. 16 | 17 | gaurav 18 | 19 | gaurav 20 | 21 | 22 | 23 | Logs the given message with the given level. 24 | 25 | rahul 26 | 27 | rahul 28 | 29 | 30 | 31 | Logs the given message with the given level. 32 | 33 | ram 34 | 35 | ram 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | Critical Tests 56 | All Tests 57 | 58 | 59 | 60 | 61 | Testsuites 62 | Testsuites.Repeat Actions For All 63 | 64 | 65 | 66 | 67 | 68 | -------------------------------------------------------------------------------- /Ch3/templates/run.sh: -------------------------------------------------------------------------------- 1 | pybot -o results/output -l results/log -r results/report testsuites -------------------------------------------------------------------------------- /Ch3/templates/testsuites/repeat_actions_for_all.txt: -------------------------------------------------------------------------------- 1 | *** Setting *** 2 | 3 | *** Test Cases *** 4 | 5 | Templated test case [Template] Log 6 | sumit 7 | gaurav 8 | rahul 9 | ram -------------------------------------------------------------------------------- /Ch4/SwingTest/libraries/SwingApp.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SumitBisht/RobotFrameworkTestAutomation/21d8e9feda5a5aa1a369f35ecb01706c3c8153a4/Ch4/SwingTest/libraries/SwingApp.jar -------------------------------------------------------------------------------- /Ch4/SwingTest/libraries/swinglibrary-1.6.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SumitBisht/RobotFrameworkTestAutomation/21d8e9feda5a5aa1a369f35ecb01706c3c8153a4/Ch4/SwingTest/libraries/swinglibrary-1.6.0.jar -------------------------------------------------------------------------------- /Ch4/SwingTest/results/output.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Alias for `Launch Application` keyword 8 | 9 | org.sumitbisht.sampleapp.SampleApp 10 | 11 | 12 | 13 | 14 | Logs the given message with the given level. 15 | 16 | Started the application 17 | 18 | Started the application 19 | 20 | 21 | 22 | Selects a window as current context and sets focus to it. 23 | 24 | Todo List 25 | 26 | 27 | 28 | 29 | Fails if button is disabled 30 | 31 | Add Todo item 32 | 33 | 34 | 35 | 36 | Pauses the test executed for the given time. 37 | 38 | 2 39 | 40 | Slept 2 seconds 41 | 42 | 43 | 44 | Logs the given message with the given level. 45 | 46 | Performing the actual actions now 47 | 48 | Performing the actual actions now 49 | 50 | 51 | 52 | Types text into a text component (e.g. text field, password field, text area). 53 | 54 | description 55 | Get this swing application tested. 56 | 57 | 58 | 59 | 60 | Uses current context to search for a button and when found, pushes it. 61 | 62 | Add Todo item 63 | 64 | 65 | 66 | 67 | Pauses the test executed for the given time. 68 | 69 | 2 70 | 71 | Slept 2 seconds 72 | 73 | 74 | 75 | Returns the number of items contained in list. 76 | 77 | todolist 78 | 79 | ${itemCount} = 1 80 | 81 | 82 | 83 | Fails if objects are unequal after converting them to integers. 84 | 85 | 1 86 | ${itemCount} 87 | 88 | Argument types are: 89 | <type 'unicode'> 90 | <type 'int'> 91 | 92 | 93 | 94 | Logs the given message with the given level. 95 | 96 | Now performing more operations on the todolist 97 | 98 | Now performing more operations on the todolist 99 | 100 | 101 | 102 | Clears contents of text component (e.g. text field, password field, text area). 103 | 104 | description 105 | 106 | 107 | 108 | 109 | Types text into a text component (e.g. text field, password field, text area). 110 | 111 | description 112 | Learn Acceptance Test Driven Development 113 | 114 | 115 | 116 | 117 | Uses current context to search for a button and when found, pushes it. 118 | 119 | Add Todo item 120 | 121 | 122 | 123 | 124 | Returns the number of items contained in list. 125 | 126 | todolist 127 | 128 | ${itemCount} = 2 129 | 130 | 131 | 132 | Fails if objects are unequal after converting them to integers. 133 | 134 | 2 135 | ${itemCount} 136 | 137 | Argument types are: 138 | <type 'unicode'> 139 | <type 'int'> 140 | 141 | 142 | 143 | Fails if value not in list. 144 | 145 | todolist 146 | Get this swing application tested. 147 | 148 | 149 | 150 | 151 | Fails if value not in list. 152 | 153 | todolist 154 | Learn Acceptance Test Driven Development 155 | 156 | 157 | 158 | 159 | Pauses the test executed for the given time. 160 | 161 | 2 162 | 163 | Slept 2 seconds 164 | 165 | 166 | 167 | Logs the given message with the given level. 168 | 169 | Now testing the delete operation 170 | 171 | Now testing the delete operation 172 | 173 | 174 | 175 | Uses current context to search for a button and when found, pushes it. 176 | 177 | Delete 178 | 179 | 180 | 181 | 182 | Logs the given message with the given level. 183 | 184 | Delete button shall not work on an unselected list 185 | 186 | Delete button shall not work on an unselected list 187 | 188 | 189 | 190 | Returns the number of items contained in list. 191 | 192 | todolist 193 | 194 | ${itemCount} = 2 195 | 196 | 197 | 198 | Fails if objects are unequal after converting them to integers. 199 | 200 | 2 201 | ${itemCount} 202 | 203 | Argument types are: 204 | <type 'unicode'> 205 | <type 'int'> 206 | 207 | 208 | 209 | Fails if value not in list. 210 | 211 | todolist 212 | Learn Acceptance Test Driven Development 213 | 214 | 215 | 216 | 217 | Selects an item from the list. 218 | 219 | todolist 220 | Learn Acceptance Test Driven Development 221 | 222 | 223 | 224 | 225 | Uses current context to search for a button and when found, pushes it. 226 | 227 | Delete 228 | 229 | 230 | 231 | 232 | Returns the number of items contained in list. 233 | 234 | todolist 235 | 236 | ${itemCount} = 1 237 | 238 | 239 | 240 | Fails if objects are unequal after converting them to integers. 241 | 242 | 1 243 | ${itemCount} 244 | 245 | Argument types are: 246 | <type 'unicode'> 247 | <type 'int'> 248 | 249 | 250 | 251 | Fails if value is in list. 252 | 253 | todolist 254 | Learn Acceptance Test Driven Development 255 | 256 | 257 | 258 | 259 | Selects an item from the list. 260 | 261 | todolist 262 | 0 263 | 264 | 265 | 266 | 267 | Uses current context to search for a button and when found, pushes it. 268 | 269 | Delete 270 | 271 | 272 | 273 | 274 | Logs the given message with the given level. 275 | 276 | Succesfully deleted the last item 277 | 278 | Succesfully deleted the last item 279 | 280 | 281 | 282 | Pauses the test executed for the given time. 283 | 284 | 2 285 | 286 | Slept 2 seconds 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | Critical Tests 307 | All Tests 308 | 309 | 310 | 311 | 312 | Testsuites 313 | Testsuites.Swing Application Test 314 | 315 | 316 | 317 | 318 | 319 | -------------------------------------------------------------------------------- /Ch4/SwingTest/run.sh: -------------------------------------------------------------------------------- 1 | CLASSPATH=libraries/swinglibrary-1.6.0.jar:libraries/SwingApp.jar jybot -o results/output -l results/log -r results/report testsuites -------------------------------------------------------------------------------- /Ch4/SwingTest/src/SwingApp/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /Ch4/SwingTest/src/SwingApp/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | SwingApp 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | 15 | org.eclipse.jdt.core.javanature 16 | 17 | 18 | -------------------------------------------------------------------------------- /Ch4/SwingTest/src/SwingApp/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled 3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 4 | org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve 5 | org.eclipse.jdt.core.compiler.compliance=1.7 6 | org.eclipse.jdt.core.compiler.debug.lineNumber=generate 7 | org.eclipse.jdt.core.compiler.debug.localVariable=generate 8 | org.eclipse.jdt.core.compiler.debug.sourceFile=generate 9 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error 10 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error 11 | org.eclipse.jdt.core.compiler.source=1.7 12 | -------------------------------------------------------------------------------- /Ch4/SwingTest/src/SwingApp/bin/org/sumitbisht/sampleapp/SampleApp$1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SumitBisht/RobotFrameworkTestAutomation/21d8e9feda5a5aa1a369f35ecb01706c3c8153a4/Ch4/SwingTest/src/SwingApp/bin/org/sumitbisht/sampleapp/SampleApp$1.class -------------------------------------------------------------------------------- /Ch4/SwingTest/src/SwingApp/bin/org/sumitbisht/sampleapp/SampleApp$2$1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SumitBisht/RobotFrameworkTestAutomation/21d8e9feda5a5aa1a369f35ecb01706c3c8153a4/Ch4/SwingTest/src/SwingApp/bin/org/sumitbisht/sampleapp/SampleApp$2$1.class -------------------------------------------------------------------------------- /Ch4/SwingTest/src/SwingApp/bin/org/sumitbisht/sampleapp/SampleApp$2.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SumitBisht/RobotFrameworkTestAutomation/21d8e9feda5a5aa1a369f35ecb01706c3c8153a4/Ch4/SwingTest/src/SwingApp/bin/org/sumitbisht/sampleapp/SampleApp$2.class -------------------------------------------------------------------------------- /Ch4/SwingTest/src/SwingApp/bin/org/sumitbisht/sampleapp/SampleApp$3$1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SumitBisht/RobotFrameworkTestAutomation/21d8e9feda5a5aa1a369f35ecb01706c3c8153a4/Ch4/SwingTest/src/SwingApp/bin/org/sumitbisht/sampleapp/SampleApp$3$1.class -------------------------------------------------------------------------------- /Ch4/SwingTest/src/SwingApp/bin/org/sumitbisht/sampleapp/SampleApp$3.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SumitBisht/RobotFrameworkTestAutomation/21d8e9feda5a5aa1a369f35ecb01706c3c8153a4/Ch4/SwingTest/src/SwingApp/bin/org/sumitbisht/sampleapp/SampleApp$3.class -------------------------------------------------------------------------------- /Ch4/SwingTest/src/SwingApp/bin/org/sumitbisht/sampleapp/SampleApp.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SumitBisht/RobotFrameworkTestAutomation/21d8e9feda5a5aa1a369f35ecb01706c3c8153a4/Ch4/SwingTest/src/SwingApp/bin/org/sumitbisht/sampleapp/SampleApp.class -------------------------------------------------------------------------------- /Ch4/SwingTest/src/SwingApp/src/org/sumitbisht/sampleapp/SampleApp.java: -------------------------------------------------------------------------------- 1 | package org.sumitbisht.sampleapp; 2 | import java.awt.BorderLayout; 3 | import java.awt.Container; 4 | import java.awt.Dimension; 5 | import java.awt.event.ActionEvent; 6 | import java.awt.event.ActionListener; 7 | import java.util.ArrayList; 8 | import java.util.List; 9 | 10 | import javax.swing.BoxLayout; 11 | import javax.swing.JButton; 12 | import javax.swing.JFrame; 13 | import javax.swing.JLabel; 14 | import javax.swing.JList; 15 | import javax.swing.JPanel; 16 | import javax.swing.JTextField; 17 | import javax.swing.SwingUtilities; 18 | 19 | public class SampleApp { 20 | private JPanel panel; 21 | private JFrame frame; 22 | private JList todoItemsList; 23 | private boolean introduceBugs; 24 | private List todoItems = new ArrayList(); 25 | 26 | public SampleApp(boolean introduceBugs) { 27 | this.introduceBugs = introduceBugs; 28 | createFrame(); 29 | createMainPanel(); 30 | addComponentsToMainPanel(); 31 | addMainPanelToFrame(); 32 | } 33 | 34 | public void display() { 35 | SwingUtilities.invokeLater(new Runnable() { 36 | public void run() { 37 | frame.pack(); 38 | frame.setVisible(true); 39 | } 40 | }); 41 | } 42 | 43 | private void createFrame() { 44 | frame = new JFrame("Todo List"); 45 | frame.setPreferredSize(new Dimension(300, 300)); 46 | frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 47 | } 48 | 49 | private void addMainPanelToFrame() { 50 | Container contentPane = frame.getContentPane(); 51 | contentPane.setLayout(new BorderLayout()); 52 | contentPane.add(panel, BorderLayout.CENTER); 53 | } 54 | 55 | private void createMainPanel() { 56 | panel = new JPanel(); 57 | panel.setName("Main Panel"); 58 | panel.setLayout(new BorderLayout()); 59 | } 60 | 61 | private void addComponentsToMainPanel() { 62 | createUsernameInput(); 63 | createUsersList(); 64 | } 65 | 66 | private void createUsernameInput() { 67 | JPanel topPanel = new JPanel(); 68 | topPanel.setLayout(new BoxLayout(topPanel, BoxLayout.X_AXIS)); 69 | topPanel.add(new JLabel("Description: ")); 70 | final JTextField textField = usernameField(); 71 | topPanel.add(textField); 72 | topPanel.add(submitButton(textField)); 73 | panel.add(topPanel, BorderLayout.NORTH); 74 | } 75 | 76 | private JButton submitButton(final JTextField textField) { 77 | @SuppressWarnings("serial") 78 | final JButton submitButton = new JButton("Add Todo item") {{ 79 | addActionListener(new ActionListener() { 80 | public void actionPerformed(ActionEvent event) { 81 | todoItems.add(textField.getText()); 82 | updateTodoItems(); 83 | } 84 | }); 85 | }}; 86 | submitButton.setName("add"); 87 | return submitButton; 88 | } 89 | 90 | private void updateTodoItems() { 91 | todoItemsList.setListData(todoItems.toArray()); 92 | } 93 | 94 | private JTextField usernameField() { 95 | final JTextField textField = new JTextField(); 96 | textField.setName("description"); 97 | return textField; 98 | } 99 | 100 | private void createUsersList() { 101 | JPanel usersPanel = usersPanel(); 102 | usersPanel.add(usersList(), BorderLayout.CENTER); 103 | usersPanel.add(deleteButton(), BorderLayout.SOUTH); 104 | panel.add(usersPanel, BorderLayout.CENTER); 105 | } 106 | 107 | private JList usersList() { 108 | todoItemsList = new JList(); 109 | todoItemsList.setName("todolist"); 110 | updateTodoItems(); 111 | return todoItemsList; 112 | } 113 | 114 | private JPanel usersPanel() { 115 | JPanel listPane = new JPanel(); 116 | listPane.setLayout(new BorderLayout()); 117 | listPane.add(new JLabel("Todo items:"), BorderLayout.NORTH); 118 | return listPane; 119 | } 120 | 121 | private JPanel deleteButton() { 122 | JPanel deleteButtonPane = new JPanel(); 123 | deleteButtonPane.setLayout(new BorderLayout()); 124 | @SuppressWarnings("serial") 125 | final JButton deleteButton = new JButton("Delete") {{ 126 | addActionListener(new ActionListener() { 127 | public void actionPerformed(ActionEvent arg0) { 128 | removeTodoItem(); 129 | } 130 | }); 131 | }}; 132 | deleteButton.setName("delete"); 133 | deleteButtonPane.add(deleteButton, BorderLayout.EAST); 134 | return deleteButtonPane; 135 | } 136 | 137 | private void removeTodoItem() { 138 | Object possibleSelection = todoItemsList.getSelectedValue(); 139 | if (introduceBugs || possibleSelection != null) { 140 | todoItems.remove(possibleSelection.toString()); 141 | updateTodoItems(); 142 | } 143 | } 144 | 145 | /** 146 | * @param args Optional argument, if supplied with a string true, 147 | * then runs the version of application containing bugs 148 | */ 149 | public static void main(String[] args) { 150 | if(args.length>0 && args[0].equalsIgnoreCase("true")) 151 | new SampleApp(true).display(); 152 | new SampleApp(false).display(); 153 | } 154 | 155 | } 156 | -------------------------------------------------------------------------------- /Ch4/SwingTest/testsuites/swing_application_test.txt: -------------------------------------------------------------------------------- 1 | ***Settings*** 2 | Library SwingLibrary 3 | 4 | ***Test Case*** 5 | Start test Start Application org.sumitbisht.sampleapp.SampleApp 6 | Log Started the application 7 | Select Window Todo List 8 | Button Should Be Enabled Add Todo item 9 | Sleep 2 10 | Log Performing the actual actions now 11 | Type Into Text Field description Get this swing application tested. 12 | Push Button Add Todo item 13 | Sleep 2 14 | ${itemCount}= Get List Item Count todolist 15 | Should Be Equal As Integers 1 ${itemCount} 16 | Log Now performing more operations on the todolist 17 | Clear Text Field description 18 | Type Into Text Field description Learn Acceptance Test Driven Development 19 | Push Button Add Todo item 20 | ${itemCount}= Get List Item Count todolist 21 | Should Be Equal As Integers 2 ${itemCount} 22 | List Should Contain todolist Get this swing application tested. 23 | List Should Contain todolist Learn Acceptance Test Driven Development 24 | Sleep 2 25 | Log Now testing the delete operation 26 | Push Button Delete 27 | Log Delete button shall not work on an unselected list 28 | ${itemCount}= Get List Item Count todolist 29 | Should Be Equal As Integers 2 ${itemCount} 30 | List Should Contain todolist Learn Acceptance Test Driven Development 31 | Select From List todolist Learn Acceptance Test Driven Development 32 | Push Button Delete 33 | ${itemCount}= Get List Item Count todolist 34 | Should Be Equal As Integers 1 ${itemCount} 35 | List Should Not Contain todolist Learn Acceptance Test Driven Development 36 | Select From List todolist 0 37 | Push Button Delete 38 | Log Succesfully deleted the last item 39 | Sleep 2 -------------------------------------------------------------------------------- /Ch4/reference-test-original/TestToRun.txt: -------------------------------------------------------------------------------- 1 | 2 | C:\Documents and Settings\sumitb\Desktop\reference-test\testsuite\TestSuite1.txt -------------------------------------------------------------------------------- /Ch4/reference-test-original/jybottest.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | %~d0 4 | cd %~d0%~p0 5 | 6 | set sikuli_jar=%sikuli_home%sikuli-script.jar 7 | set CLASSPATH=%sikuli_jar% 8 | set JYTHONPATH=%sikuli_jar%/Lib 9 | 10 | call jybot --pythonpath=TestLib ^ 11 | --outputdir=results ^ 12 | --loglevel=TRACE ^ 13 | --output "%~d0%~p0results\output.xml" ^ 14 | --log "%~d0%~p0results\log.html" ^ 15 | --report "%~d0%~p0results\report.html" ^ 16 | testsuite 17 | -------------------------------------------------------------------------------- /Ch4/reference-test-original/results/output.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | Arguments: [ ] 11 | [log] TYPE "this is a reference test example" 12 | Return: None 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | Arguments: [ ] 26 | [log] TYPE "case changed" 27 | Return: None 28 | 29 | 30 | 31 | 32 | 33 | 34 | Arguments: [ ] 35 | [log] TYPE "5 " 36 | [log] TYPE "4 " 37 | [log] TYPE "3 " 38 | [log] TYPE "2 " 39 | [log] TYPE "1 " 40 | [log] TYPE "0 " 41 | [log] TYPE " boom" 42 | Return: None 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | Critical Tests 63 | All Tests 64 | 65 | 66 | 67 | 68 | Testsuite 69 | Testsuite.TestSuite1 70 | 71 | 72 | 73 | 74 | 75 | -------------------------------------------------------------------------------- /Ch4/reference-test-original/results/results/output.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | No keyword with name 'TestAction1.Execute' found. 11 | 12 | 13 | 14 | 15 | 16 | No keyword with name 'TestAction1.Execute' found. 17 | 18 | 19 | 20 | 21 | 22 | 23 | No keyword with name '2ndcase1staction.Execute' found. 24 | 25 | 26 | 27 | 28 | 29 | No keyword with name '2ndcase1staction.Execute' found. 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | Critical Tests 44 | All Tests 45 | 46 | 47 | 48 | 49 | Testsuite 50 | Testsuite.TestSuite1 51 | 52 | 53 | 54 | Error in file 'C:\Documents and Settings\sumit\Desktop\sikuli\28\RF RnD\reference-test-original\testsuite\TestSuite1.txt': Importing test library 'TestAction1.XTest' failed: ImportError: No module named sikuli 55 | Traceback (most recent call last): 56 | File "C:\Documents and Settings\sumit\Desktop\sikuli\28\RF RnD\reference-test-original\TestLib\TestAction1.py", line 2, in <module> 57 | from sikuliwrapper import * 58 | File "C:\Documents and Settings\sumit\Desktop\sikuli\28\RF RnD\reference-test-original\TestLib\sikuliwrapper.py", line 2, in <module> 59 | from logger import * 60 | File "C:\Documents and Settings\sumit\Desktop\sikuli\28\RF RnD\reference-test-original\TestLib\logger.py", line 5, in <module> 61 | from sikuli.Sikuli import * 62 | PYTHONPATH: 63 | C:\Documents and Settings\sumit\Desktop\sikuli\28\RF RnD\reference-test-original\TestLib 64 | C:\jython2.5.2\Lib\site-packages\robot\libraries 65 | C:\jython2.5.2\Lib\site-packages 66 | C:\Program Files\Sikuli X\Lib 67 | C:\jython2.5.2\Lib 68 | __classpath__ 69 | __pyclasspath__/ 70 | . 71 | C:\Documents and Settings\sumit\Desktop\sikuli\28\RF RnD\reference-test-original 72 | CLASSPATH: 73 | C:\jython2.5.2\jython.jar 74 | C:\Program Files\Sikuli X\sikuli-script.jar 75 | C:\Program Files\Sikuli X\\Lib 76 | Error in file 'C:\Documents and Settings\sumit\Desktop\sikuli\28\RF RnD\reference-test-original\testsuite\TestSuite1.txt': Importing test library '2ndcase1staction.XTest' failed: ImportError: No module named sikuli 77 | Traceback (most recent call last): 78 | File "C:\Documents and Settings\sumit\Desktop\sikuli\28\RF RnD\reference-test-original\TestLib\2ndcase1staction.py", line 2, in <module> 79 | from sikuliwrapper import * 80 | File "C:\Documents and Settings\sumit\Desktop\sikuli\28\RF RnD\reference-test-original\TestLib\sikuliwrapper.py", line 2, in <module> 81 | from logger import * 82 | File "C:\Documents and Settings\sumit\Desktop\sikuli\28\RF RnD\reference-test-original\TestLib\logger.py", line 5, in <module> 83 | from sikuli.Sikuli import * 84 | PYTHONPATH: 85 | C:\Documents and Settings\sumit\Desktop\sikuli\28\RF RnD\reference-test-original\TestLib 86 | C:\jython2.5.2\Lib\site-packages\robot\libraries 87 | C:\jython2.5.2\Lib\site-packages 88 | C:\Program Files\Sikuli X\Lib 89 | C:\jython2.5.2\Lib 90 | __classpath__ 91 | __pyclasspath__/ 92 | . 93 | C:\Documents and Settings\sumit\Desktop\sikuli\28\RF RnD\reference-test-original 94 | CLASSPATH: 95 | C:\jython2.5.2\jython.jar 96 | C:\Program Files\Sikuli X\sikuli-script.jar 97 | C:\Program Files\Sikuli X\\Lib 98 | Error in file 'C:\Documents and Settings\sumit\Desktop\sikuli\28\RF RnD\reference-test-original\testsuite\TestSuite1.txt': Importing test library 'anotheraction.XTest' failed: ImportError: No module named sikuli 99 | Traceback (most recent call last): 100 | File "C:\Documents and Settings\sumit\Desktop\sikuli\28\RF RnD\reference-test-original\TestLib\anotheraction.py", line 2, in <module> 101 | from sikuliwrapper import * 102 | File "C:\Documents and Settings\sumit\Desktop\sikuli\28\RF RnD\reference-test-original\TestLib\sikuliwrapper.py", line 2, in <module> 103 | from logger import * 104 | File "C:\Documents and Settings\sumit\Desktop\sikuli\28\RF RnD\reference-test-original\TestLib\logger.py", line 5, in <module> 105 | from sikuli.Sikuli import * 106 | PYTHONPATH: 107 | C:\Documents and Settings\sumit\Desktop\sikuli\28\RF RnD\reference-test-original\TestLib 108 | C:\jython2.5.2\Lib\site-packages\robot\libraries 109 | C:\jython2.5.2\Lib\site-packages 110 | C:\Program Files\Sikuli X\Lib 111 | C:\jython2.5.2\Lib 112 | __classpath__ 113 | __pyclasspath__/ 114 | . 115 | C:\Documents and Settings\sumit\Desktop\sikuli\28\RF RnD\reference-test-original 116 | CLASSPATH: 117 | C:\jython2.5.2\jython.jar 118 | C:\Program Files\Sikuli X\sikuli-script.jar 119 | C:\Program Files\Sikuli X\\Lib 120 | 121 | 122 | -------------------------------------------------------------------------------- /Ch4/reference-test-original/sikuli-script.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SumitBisht/RobotFrameworkTestAutomation/21d8e9feda5a5aa1a369f35ecb01706c3c8153a4/Ch4/reference-test-original/sikuli-script.jar -------------------------------------------------------------------------------- /Ch4/reference-test-original/testlib/2ndcase1staction$py.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SumitBisht/RobotFrameworkTestAutomation/21d8e9feda5a5aa1a369f35ecb01706c3c8153a4/Ch4/reference-test-original/testlib/2ndcase1staction$py.class -------------------------------------------------------------------------------- /Ch4/reference-test-original/testlib/2ndcase1staction.py: -------------------------------------------------------------------------------- 1 | from __future__ import with_statement 2 | from sikuliwrapper import * 3 | 4 | #add custom image library 5 | addImagePath(common.cfgImageLibrary) 6 | Settings.MinSimilarity = common.imageMinSimilarity 7 | 8 | class XTest(BaseLogger): 9 | 10 | ROBOT_LIBRARY_SCOPE = 'TEST SUITE' 11 | 12 | def __init__(self): 13 | None 14 | #self.appCoordinates = (0, 0, 1024, 768) 15 | 16 | def Execute(self, *args): 17 | keyDown(Key.ENTER) 18 | keyUp(Key.ENTER) 19 | wait(1.156) 20 | type("case changed") 21 | wait(0.907) 22 | None 23 | -------------------------------------------------------------------------------- /Ch4/reference-test-original/testlib/TestAction1$py.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SumitBisht/RobotFrameworkTestAutomation/21d8e9feda5a5aa1a369f35ecb01706c3c8153a4/Ch4/reference-test-original/testlib/TestAction1$py.class -------------------------------------------------------------------------------- /Ch4/reference-test-original/testlib/TestAction1.py: -------------------------------------------------------------------------------- 1 | from __future__ import with_statement 2 | from sikuliwrapper import * 3 | 4 | #add custom image library 5 | addImagePath(common.cfgImageLibrary) 6 | Settings.MinSimilarity = common.imageMinSimilarity 7 | 8 | class XTest(BaseLogger): 9 | 10 | ROBOT_LIBRARY_SCOPE = 'TEST SUITE' 11 | 12 | def __init__(self): 13 | None 14 | #self.appCoordinates = (0, 0, 1024, 768) 15 | 16 | def Execute(self, *args): 17 | type("this is a reference test example") 18 | wait(0.485) 19 | None 20 | -------------------------------------------------------------------------------- /Ch4/reference-test-original/testlib/anotheraction$py.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SumitBisht/RobotFrameworkTestAutomation/21d8e9feda5a5aa1a369f35ecb01706c3c8153a4/Ch4/reference-test-original/testlib/anotheraction$py.class -------------------------------------------------------------------------------- /Ch4/reference-test-original/testlib/anotheraction.py: -------------------------------------------------------------------------------- 1 | from __future__ import with_statement 2 | from sikuliwrapper import * 3 | 4 | #add custom image library 5 | addImagePath(common.cfgImageLibrary) 6 | Settings.MinSimilarity = common.imageMinSimilarity 7 | 8 | class XTest(BaseLogger): 9 | 10 | ROBOT_LIBRARY_SCOPE = 'TEST SUITE' 11 | 12 | def __init__(self): 13 | None 14 | #self.appCoordinates = (0, 0, 1024, 768) 15 | 16 | def Execute(self, *args): 17 | keyDown(Key.ENTER) 18 | keyUp(Key.ENTER) 19 | type("5 ") 20 | wait(0.547) 21 | type("4 ") 22 | wait(0.391) 23 | type("3 ") 24 | wait(0.368) 25 | type("2 ") 26 | wait(0.368) 27 | type("1 ") 28 | wait(0.357) 29 | type("0 ") 30 | wait(1) 31 | type(" boom") 32 | wait(0.546) 33 | None 34 | -------------------------------------------------------------------------------- /Ch4/reference-test-original/testlib/common$py.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SumitBisht/RobotFrameworkTestAutomation/21d8e9feda5a5aa1a369f35ecb01706c3c8153a4/Ch4/reference-test-original/testlib/common$py.class -------------------------------------------------------------------------------- /Ch4/reference-test-original/testlib/common.py: -------------------------------------------------------------------------------- 1 | # Global variables, can be moved to config file 2 | cfgImageLibrary = "images" # image search directory 3 | cfgLoggingLevel = "debug" # logging level, possible values 'debug', 'info' 4 | imageMinSimilarity = 0.80 5 | 6 | # Custom Exception for verification failures 7 | class VerificationFailed(Exception): 8 | def __init__(self, value): 9 | self.value = value 10 | def __str__(self): 11 | return self.value -------------------------------------------------------------------------------- /Ch4/reference-test-original/testlib/logger$py.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SumitBisht/RobotFrameworkTestAutomation/21d8e9feda5a5aa1a369f35ecb01706c3c8153a4/Ch4/reference-test-original/testlib/logger$py.class -------------------------------------------------------------------------------- /Ch4/reference-test-original/testlib/logger.py: -------------------------------------------------------------------------------- 1 | import logging 2 | import datetime 3 | import shutil 4 | import common 5 | from sikuli.Sikuli import * 6 | 7 | # hack to properly handle WARNING log level 8 | logging.addLevelName(logging.WARNING, 'WARN') 9 | # add HTML log level 10 | HTML = logging.INFO + 5 11 | logging.addLevelName(HTML, 'HTML') 12 | 13 | class RobotHandler(logging.Handler): 14 | def __init__(self): 15 | logging.Handler.__init__(self, level=logging.DEBUG) 16 | 17 | def emit(self, record): 18 | print self.format(record) 19 | 20 | def format(self, record): 21 | if not self.formatter: 22 | # add default formatter 23 | self.formatter = logging.Formatter('*%(levelname)s* %(message)s') 24 | return self.formatter.format(record) 25 | 26 | class RobotLogger(logging.Logger): 27 | def __init__(self, name='robot', level=logging.INFO): 28 | if common.cfgLoggingLevel.lower() == 'debug': 29 | level = logging.DEBUG 30 | logging.Logger.__init__(self, name, level) 31 | self.addHandler(RobotHandler()) 32 | 33 | def _get_unique_name(self, prefix="", suffix=""): 34 | now = datetime.datetime.now() 35 | return prefix + now.strftime('%Y-%m-%d_%H-%M-%S') + suffix 36 | 37 | def screenshot(self, msg="", folder="results/screenshots/", region=(0,0,1440,900)): 38 | name = self._get_unique_name(suffix=".png") 39 | img_src = capture(*region) 40 | shutil.copy(img_src, folder + name) 41 | self.html_img(msg, folder + name) 42 | 43 | def passed(self, msg, *args, **kwargs): 44 | self.info('PASS: ' + msg, *args, **kwargs) 45 | 46 | if self.isEnabledFor(logging.DEBUG) and len(getLastFoundImages()) != 0: 47 | # source image 48 | self.html_img("Source Image", common.cfgImageLibrary + '/' + getLastFoundImage()) 49 | # matched image 50 | last_match = SCREEN.getLastMatch() 51 | region = (last_match.getX(), last_match.getY(), last_match.getW(), last_match.getH()) 52 | self.screenshot(msg="Best Matches", folder='results/matches/', region=region) 53 | # score of match 54 | self.info("Matched with score: %s" % last_match.getScore()) 55 | 56 | def failed(self, msg, *args, **kwargs): 57 | if self.isEnabledFor(logging.DEBUG): 58 | if len(getLastFoundImages()) != 0: 59 | # source image 60 | self.html_img("Source Image", common.cfgImageLibrary + '/' + getLastFoundImage()) 61 | # screenshot 62 | self.screenshot() 63 | raise common.VerificationFailed(msg) 64 | 65 | def html(self, msg, *args, **kwargs): 66 | self.log(HTML, msg, *args, **kwargs) 67 | 68 | def html_img(self, msg, image): 69 | self.html('%s ' % (msg, image)) 70 | 71 | class BaseLogger(object): 72 | """ Base class for logging support """ 73 | log = RobotLogger() 74 | 75 | #============= Modification to RootLogger ===============# 76 | # Use class RobotLogger instead of RootLogger as it support 77 | # additional methods: passed(), failed() 78 | 79 | # setup log level for RootLogger 80 | #logging.basicConfig(level=logging.INFO) 81 | # remove default StreamHandler 82 | #logging.getLogger('').removeHandler(logging.getLogger('').handlers[0]) 83 | # add RobotHandler to the RootLogger 84 | #logging.getLogger('').addHandler(RobotHandler()) 85 | #========================================================# 86 | 87 | # =============================================== # 88 | # Helper functions methods # 89 | # =============================================== # 90 | 91 | # functions for accessing lastly searched images and region 92 | _lastFoundImages = [] 93 | _lastFoundRegion = None 94 | # flag for checking whether last image was already poped 95 | # to prevent appearence old images in log file 96 | _is_new_image = 0 97 | 98 | def getLastFoundImages(): 99 | return _lastFoundImages 100 | def getLastFoundImage(): 101 | _is_new_image = 0 102 | return _lastFoundImages.pop() 103 | def getLastFoundRegion(): 104 | reg = _lastFoundRegion 105 | _lastFoundRegion = None 106 | return reg 107 | def addFoundImage(img, reg=None): 108 | _lastFoundImages.append(img) 109 | _lastFoundRegion = reg 110 | _is_new_image = 1 111 | 112 | # return filename from pattern's target object 113 | def getFilename(target): 114 | try: 115 | filename = target.getFilename() 116 | except: 117 | filename = target 118 | return filename 119 | 120 | -------------------------------------------------------------------------------- /Ch4/reference-test-original/testlib/sikuliwrapper$py.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SumitBisht/RobotFrameworkTestAutomation/21d8e9feda5a5aa1a369f35ecb01706c3c8153a4/Ch4/reference-test-original/testlib/sikuliwrapper$py.class -------------------------------------------------------------------------------- /Ch4/reference-test-original/testlib/sikuliwrapper.py: -------------------------------------------------------------------------------- 1 | import common 2 | from logger import * 3 | from sikuli.Sikuli import Region as SikuliRegion 4 | from sikuli.Sikuli import Screen as SikuliScreen 5 | 6 | log = RobotLogger() 7 | class VerifyException(RuntimeError): 8 | ROBOT_CONTINUE_ON_FAILURE = True 9 | # TODO: appropriately provide for setShowActions(True) 10 | # NOTE: following commented to resolve problem 'in slow mode - start menu item click fails' 11 | ## enable slow motion if debug log level enabled 12 | ## (cfgLoggingLevel is set in file common.py) 13 | #if common.cfgLoggingLevel.lower() == 'debug': 14 | # setShowActions(True) 15 | 16 | # =============================================== # 17 | # Overwritten sikuli methods # 18 | # =============================================== # 19 | 20 | # function for calling native sikuli methods 21 | def sikuli_method(name, *args, **kwargs): 22 | return sys.modules['sikuli.Sikuli'].__dict__[name](*args, **kwargs) 23 | 24 | # overwritten Screen.exists method 25 | def exists(target, timeout=0): 26 | addFoundImage(getFilename(target)) 27 | return sikuli_method('exists', target, float(timeout)) 28 | 29 | ''' 30 | The verify method acts as a semantic wrapper over the exists method. 31 | On a failure, the log is generated while specifying the non-existence of images to be verified, 32 | but no error is reported and the tests run uninterrupted. 33 | ''' 34 | def verify(target, timeout=0): 35 | addFoundImage(getFilename(target)) 36 | result = sikuli_method('exists', target, float(timeout)) 37 | if not result: 38 | log.html_img("verify: Find failed", "images/"+getFilename(target)) 39 | sik_scrn = SikuliScreen() 40 | log.screenshot(msg="Source Image", region=(sik_scrn.getX(), sik_scrn.getY(), sik_scrn.getW(), sik_scrn.getH())) 41 | raise VerifyException('Find failed for image ' + getFilename(target)) 42 | return result 43 | #The overwritten click method 44 | def click(target, modifiers=0): 45 | try: 46 | return sikuli_method('click', target, modifiers) 47 | except FindFailed, e: 48 | log.html_img("click: Find failed", "images/"+getFilename(target)) 49 | sik_scrn = SikuliScreen() 50 | log.screenshot(msg="Screen", region=(sik_scrn.getX(), sik_scrn.getY(), sik_scrn.getW(), sik_scrn.getH())) 51 | raise e 52 | 53 | def doubleClick(target, modifiers=0): 54 | try: 55 | return sikuli_method('doubleClick', target, modifiers) 56 | except FindFailed, e: 57 | log.html_img("doubleClick: Find failed", "images/"+getFilename(target)) 58 | sik_scrn = SikuliScreen() 59 | log.screenshot(msg="Screen", region=(sik_scrn.getX(), sik_scrn.getY(), sik_scrn.getW(), sik_scrn.getH())) 60 | raise e 61 | 62 | def rightClick(target, modifiers=0): 63 | try: 64 | return sikuli_method('rightClick', target, modifiers) 65 | except FindFailed, e: 66 | log.html_img("rightClick: Find failed", "images/"+getFilename(target)) 67 | sik_scrn = SikuliScreen() 68 | log.screenshot(msg="Screen", region=(sik_scrn.getX(), sik_scrn.getY(), sik_scrn.getW(), sik_scrn.getH())) 69 | raise e 70 | 71 | def wait(target, timeout=4): 72 | try: 73 | return sikuli_method('wait', target, float(timeout)) 74 | except FindFailed, e: 75 | log.html_img("wait: Find failed", "images/"+getFilename(target)) 76 | sik_scrn = SikuliScreen() 77 | log.screenshot(msg="Screen", region=(sik_scrn.getX(), sik_scrn.getY(), sik_scrn.getW(), sik_scrn.getH())) 78 | raise e 79 | 80 | 81 | # =============================================== # 82 | # Overwritten sikuli classes # 83 | # =============================================== # 84 | 85 | # overwriten Sikuli Region class 86 | class Region(SikuliRegion, BaseLogger): 87 | 88 | def click(self, target, modifiers=0): 89 | try: 90 | return SikuliRegion.click(self, target, modifiers) 91 | except FindFailed, e: 92 | self.log.html_img("region.click: Find failed", "images/" + getFilename(target)) 93 | self.log.screenshot(msg="Region", region=(self.getX(), self.getY(), self.getW(), self.getH())) 94 | raise e 95 | 96 | def doubleClick(self, target, modifiers=0): 97 | try: 98 | return SikuliRegion.doubleClick(self, target, modifiers) 99 | except FindFailed, e: 100 | self.log.html_img("region.doubleClick: Find failed", "images/" + getFilename(target)) 101 | self.log.screenshot(msg="Region", region=(self.getX(), self.getY(), self.getW(), self.getH())) 102 | raise e 103 | def exists(self, target, timeout=None): 104 | img = getFilename(target) 105 | reg = (self.getX(), self.getY(), self.getW(), self.getH()) 106 | addFoundImage(img, reg) 107 | return SikuliRegion.exists(self, target, timeout) 108 | 109 | def verify(self, target, timeout=None): 110 | img = getFilename(target) 111 | reg = (self.getX(), self.getY(), self.getW(), self.getH()) 112 | addFoundImage(img, reg) 113 | return SikuliRegion.exists(self, target, timeout) 114 | -------------------------------------------------------------------------------- /Ch4/reference-test-original/testsuite/TestSuite1.txt: -------------------------------------------------------------------------------- 1 | ***Settings*** 2 | Library TestAction1.XTest WITH NAME TestAction1 3 | Library 2ndcase1staction.XTest WITH NAME 2ndcase1staction 4 | Library anotheraction.XTest WITH NAME anotheraction 5 | ***Test Cases*** 6 | 7 | Test Case 1 8 | TestAction1.Execute 9 | Test Case 2 10 | 2ndcase1staction.Execute 11 | anotheraction.Execute -------------------------------------------------------------------------------- /Ch4/reference-test-original/xat.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SumitBisht/RobotFrameworkTestAutomation/21d8e9feda5a5aa1a369f35ecb01706c3c8153a4/Ch4/reference-test-original/xat.exe -------------------------------------------------------------------------------- /Ch4/reference-test-working-as-desired/Copy of jybottest.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | %~d0 4 | cd %~d0%~p0 5 | 6 | set sikuli_jar=%sikuli_home%sikuli-script.jar 7 | set CLASSPATH=%sikuli_jar% 8 | set JYTHONPATH=%sikuli_jar%/Lib 9 | 10 | call jybot --pythonpath=TestLib ^ 11 | --outputdir=results ^ 12 | --loglevel=TRACE ^ 13 | --argumentfile TestToRun.txt ^ 14 | --output "%~d0%~p0results\output.xml" ^ 15 | --log "%~d0%~p0results\log.html" ^ 16 | --report "%~d0%~p0results\report.html" ^ 17 | %* 18 | -------------------------------------------------------------------------------- /Ch4/reference-test-working-as-desired/TestToRun.txt: -------------------------------------------------------------------------------- 1 | --name suites 2 | testsuite\parent -------------------------------------------------------------------------------- /Ch4/reference-test-working-as-desired/jybottest.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | %~d0 4 | cd %~d0%~p0 5 | 6 | set sikuli_jar=%sikuli_home%sikuli-script.jar 7 | set CLASSPATH=%sikuli_jar% 8 | set JYTHONPATH=%sikuli_jar%/Lib 9 | 10 | call jybot --pythonpath=TestLib ^ 11 | --outputdir=results ^ 12 | --loglevel=TRACE ^ 13 | --output "%~d0%~p0results\output.xml" ^ 14 | --log "%~d0%~p0results\log.html" ^ 15 | --report "%~d0%~p0results\report.html" ^ 16 | testsuite 17 | -------------------------------------------------------------------------------- /Ch4/reference-test-working-as-desired/results/output.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | Arguments: [ ] 12 | [log] TYPE "this is a reference test example" 13 | Return: None 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | Arguments: [ ] 34 | [log] TYPE "5 " 35 | [log] TYPE "4 " 36 | [log] TYPE "3 " 37 | [log] TYPE "2 " 38 | [log] TYPE "1 " 39 | [log] TYPE "0 " 40 | [log] TYPE " boom" 41 | Return: None 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | Arguments: [ ] 67 | [log] TYPE "case changed" 68 | Return: None 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | Critical Tests 99 | All Tests 100 | 101 | 102 | 103 | 104 | Testsuite 105 | Testsuite.Parent 106 | Testsuite.Parent.FirstSuite 107 | Testsuite.Parent.Hhh 108 | Testsuite.Parent.Hhh.ThirdSuite 109 | Testsuite.Parent.Kane 110 | Testsuite.Parent.Kane.SecondSuite 111 | 112 | 113 | 114 | 115 | 116 | -------------------------------------------------------------------------------- /Ch4/reference-test-working-as-desired/testlib/2ndcase1staction$py.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SumitBisht/RobotFrameworkTestAutomation/21d8e9feda5a5aa1a369f35ecb01706c3c8153a4/Ch4/reference-test-working-as-desired/testlib/2ndcase1staction$py.class -------------------------------------------------------------------------------- /Ch4/reference-test-working-as-desired/testlib/2ndcase1staction.py: -------------------------------------------------------------------------------- 1 | from __future__ import with_statement 2 | from sikuliwrapper import * 3 | 4 | #add custom image library 5 | addImagePath(common.cfgImageLibrary) 6 | Settings.MinSimilarity = common.imageMinSimilarity 7 | 8 | class XTest(BaseLogger): 9 | 10 | ROBOT_LIBRARY_SCOPE = 'TEST SUITE' 11 | 12 | def __init__(self): 13 | None 14 | #self.appCoordinates = (0, 0, 1024, 768) 15 | 16 | def Execute(self, *args): 17 | keyDown(Key.ENTER) 18 | keyUp(Key.ENTER) 19 | wait(1.156) 20 | type("case changed") 21 | wait(0.907) 22 | None 23 | -------------------------------------------------------------------------------- /Ch4/reference-test-working-as-desired/testlib/TestAction1$py.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SumitBisht/RobotFrameworkTestAutomation/21d8e9feda5a5aa1a369f35ecb01706c3c8153a4/Ch4/reference-test-working-as-desired/testlib/TestAction1$py.class -------------------------------------------------------------------------------- /Ch4/reference-test-working-as-desired/testlib/TestAction1.py: -------------------------------------------------------------------------------- 1 | from __future__ import with_statement 2 | from sikuliwrapper import * 3 | 4 | #add custom image library 5 | addImagePath(common.cfgImageLibrary) 6 | Settings.MinSimilarity = common.imageMinSimilarity 7 | 8 | class XTest(BaseLogger): 9 | 10 | ROBOT_LIBRARY_SCOPE = 'TEST SUITE' 11 | 12 | def __init__(self): 13 | None 14 | #self.appCoordinates = (0, 0, 1024, 768) 15 | 16 | def Execute(self, *args): 17 | type("this is a reference test example") 18 | wait(0.485) 19 | None 20 | -------------------------------------------------------------------------------- /Ch4/reference-test-working-as-desired/testlib/anotheraction$py.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SumitBisht/RobotFrameworkTestAutomation/21d8e9feda5a5aa1a369f35ecb01706c3c8153a4/Ch4/reference-test-working-as-desired/testlib/anotheraction$py.class -------------------------------------------------------------------------------- /Ch4/reference-test-working-as-desired/testlib/anotheraction.py: -------------------------------------------------------------------------------- 1 | from __future__ import with_statement 2 | from sikuliwrapper import * 3 | 4 | #add custom image library 5 | addImagePath(common.cfgImageLibrary) 6 | Settings.MinSimilarity = common.imageMinSimilarity 7 | 8 | class XTest(BaseLogger): 9 | 10 | ROBOT_LIBRARY_SCOPE = 'TEST SUITE' 11 | 12 | def __init__(self): 13 | None 14 | #self.appCoordinates = (0, 0, 1024, 768) 15 | 16 | def Execute(self, *args): 17 | keyDown(Key.ENTER) 18 | keyUp(Key.ENTER) 19 | type("5 ") 20 | wait(0.547) 21 | type("4 ") 22 | wait(0.391) 23 | type("3 ") 24 | wait(0.368) 25 | type("2 ") 26 | wait(0.368) 27 | type("1 ") 28 | wait(0.357) 29 | type("0 ") 30 | wait(1) 31 | type(" boom") 32 | wait(0.546) 33 | None 34 | -------------------------------------------------------------------------------- /Ch4/reference-test-working-as-desired/testlib/common$py.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SumitBisht/RobotFrameworkTestAutomation/21d8e9feda5a5aa1a369f35ecb01706c3c8153a4/Ch4/reference-test-working-as-desired/testlib/common$py.class -------------------------------------------------------------------------------- /Ch4/reference-test-working-as-desired/testlib/common.py: -------------------------------------------------------------------------------- 1 | # Global variables, can be moved to config file 2 | cfgImageLibrary = "images" # image search directory 3 | cfgLoggingLevel = "debug" # logging level, possible values 'debug', 'info' 4 | imageMinSimilarity = 0.80 5 | 6 | # Custom Exception for verification failures 7 | class VerificationFailed(Exception): 8 | def __init__(self, value): 9 | self.value = value 10 | def __str__(self): 11 | return self.value -------------------------------------------------------------------------------- /Ch4/reference-test-working-as-desired/testlib/logger$py.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SumitBisht/RobotFrameworkTestAutomation/21d8e9feda5a5aa1a369f35ecb01706c3c8153a4/Ch4/reference-test-working-as-desired/testlib/logger$py.class -------------------------------------------------------------------------------- /Ch4/reference-test-working-as-desired/testlib/logger.py: -------------------------------------------------------------------------------- 1 | import logging 2 | import datetime 3 | import shutil 4 | import common 5 | from sikuli.Sikuli import * 6 | 7 | # hack to properly handle WARNING log level 8 | logging.addLevelName(logging.WARNING, 'WARN') 9 | # add HTML log level 10 | HTML = logging.INFO + 5 11 | logging.addLevelName(HTML, 'HTML') 12 | 13 | class RobotHandler(logging.Handler): 14 | def __init__(self): 15 | logging.Handler.__init__(self, level=logging.DEBUG) 16 | 17 | def emit(self, record): 18 | print self.format(record) 19 | 20 | def format(self, record): 21 | if not self.formatter: 22 | # add default formatter 23 | self.formatter = logging.Formatter('*%(levelname)s* %(message)s') 24 | return self.formatter.format(record) 25 | 26 | class RobotLogger(logging.Logger): 27 | def __init__(self, name='robot', level=logging.INFO): 28 | if common.cfgLoggingLevel.lower() == 'debug': 29 | level = logging.DEBUG 30 | logging.Logger.__init__(self, name, level) 31 | self.addHandler(RobotHandler()) 32 | 33 | def _get_unique_name(self, prefix="", suffix=""): 34 | now = datetime.datetime.now() 35 | return prefix + now.strftime('%Y-%m-%d_%H-%M-%S') + suffix 36 | 37 | def screenshot(self, msg="", folder="results/screenshots/", region=(0,0,1440,900)): 38 | name = self._get_unique_name(suffix=".png") 39 | img_src = capture(*region) 40 | shutil.copy(img_src, folder + name) 41 | self.html_img(msg, folder + name) 42 | 43 | def passed(self, msg, *args, **kwargs): 44 | self.info('PASS: ' + msg, *args, **kwargs) 45 | 46 | if self.isEnabledFor(logging.DEBUG) and len(getLastFoundImages()) != 0: 47 | # source image 48 | self.html_img("Source Image", common.cfgImageLibrary + '/' + getLastFoundImage()) 49 | # matched image 50 | last_match = SCREEN.getLastMatch() 51 | region = (last_match.getX(), last_match.getY(), last_match.getW(), last_match.getH()) 52 | self.screenshot(msg="Best Matches", folder='results/matches/', region=region) 53 | # score of match 54 | self.info("Matched with score: %s" % last_match.getScore()) 55 | 56 | def failed(self, msg, *args, **kwargs): 57 | if self.isEnabledFor(logging.DEBUG): 58 | if len(getLastFoundImages()) != 0: 59 | # source image 60 | self.html_img("Source Image", common.cfgImageLibrary + '/' + getLastFoundImage()) 61 | # screenshot 62 | self.screenshot() 63 | raise common.VerificationFailed(msg) 64 | 65 | def html(self, msg, *args, **kwargs): 66 | self.log(HTML, msg, *args, **kwargs) 67 | 68 | def html_img(self, msg, image): 69 | self.html('%s ' % (msg, image)) 70 | 71 | class BaseLogger(object): 72 | """ Base class for logging support """ 73 | log = RobotLogger() 74 | 75 | #============= Modification to RootLogger ===============# 76 | # Use class RobotLogger instead of RootLogger as it support 77 | # additional methods: passed(), failed() 78 | 79 | # setup log level for RootLogger 80 | #logging.basicConfig(level=logging.INFO) 81 | # remove default StreamHandler 82 | #logging.getLogger('').removeHandler(logging.getLogger('').handlers[0]) 83 | # add RobotHandler to the RootLogger 84 | #logging.getLogger('').addHandler(RobotHandler()) 85 | #========================================================# 86 | 87 | # =============================================== # 88 | # Helper functions methods # 89 | # =============================================== # 90 | 91 | # functions for accessing lastly searched images and region 92 | _lastFoundImages = [] 93 | _lastFoundRegion = None 94 | # flag for checking whether last image was already poped 95 | # to prevent appearence old images in log file 96 | _is_new_image = 0 97 | 98 | def getLastFoundImages(): 99 | return _lastFoundImages 100 | def getLastFoundImage(): 101 | _is_new_image = 0 102 | return _lastFoundImages.pop() 103 | def getLastFoundRegion(): 104 | reg = _lastFoundRegion 105 | _lastFoundRegion = None 106 | return reg 107 | def addFoundImage(img, reg=None): 108 | _lastFoundImages.append(img) 109 | _lastFoundRegion = reg 110 | _is_new_image = 1 111 | 112 | # return filename from pattern's target object 113 | def getFilename(target): 114 | try: 115 | filename = target.getFilename() 116 | except: 117 | filename = target 118 | return filename 119 | 120 | -------------------------------------------------------------------------------- /Ch4/reference-test-working-as-desired/testlib/sikuliwrapper$py.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SumitBisht/RobotFrameworkTestAutomation/21d8e9feda5a5aa1a369f35ecb01706c3c8153a4/Ch4/reference-test-working-as-desired/testlib/sikuliwrapper$py.class -------------------------------------------------------------------------------- /Ch4/reference-test-working-as-desired/testlib/sikuliwrapper.py: -------------------------------------------------------------------------------- 1 | import common 2 | from logger import * 3 | from sikuli.Sikuli import Region as SikuliRegion 4 | from sikuli.Sikuli import Screen as SikuliScreen 5 | 6 | log = RobotLogger() 7 | class VerifyException(RuntimeError): 8 | ROBOT_CONTINUE_ON_FAILURE = True 9 | # TODO: appropriately provide for setShowActions(True) 10 | # NOTE: following commented to resolve problem 'in slow mode - start menu item click fails' 11 | ## enable slow motion if debug log level enabled 12 | ## (cfgLoggingLevel is set in file common.py) 13 | #if common.cfgLoggingLevel.lower() == 'debug': 14 | # setShowActions(True) 15 | 16 | # =============================================== # 17 | # Overwritten sikuli methods # 18 | # =============================================== # 19 | 20 | # function for calling native sikuli methods 21 | def sikuli_method(name, *args, **kwargs): 22 | return sys.modules['sikuli.Sikuli'].__dict__[name](*args, **kwargs) 23 | 24 | # overwritten Screen.exists method 25 | def exists(target, timeout=0): 26 | addFoundImage(getFilename(target)) 27 | return sikuli_method('exists', target, float(timeout)) 28 | 29 | ''' 30 | The verify method acts as a semantic wrapper over the exists method. 31 | On a failure, the log is generated while specifying the non-existence of images to be verified, 32 | but no error is reported and the tests run uninterrupted. 33 | ''' 34 | def verify(target, timeout=0): 35 | addFoundImage(getFilename(target)) 36 | result = sikuli_method('exists', target, float(timeout)) 37 | if not result: 38 | log.html_img("verify: Find failed", "images/"+getFilename(target)) 39 | sik_scrn = SikuliScreen() 40 | log.screenshot(msg="Source Image", region=(sik_scrn.getX(), sik_scrn.getY(), sik_scrn.getW(), sik_scrn.getH())) 41 | raise VerifyException('Find failed for image ' + getFilename(target)) 42 | return result 43 | #The overwritten click method 44 | def click(target, modifiers=0): 45 | try: 46 | return sikuli_method('click', target, modifiers) 47 | except FindFailed, e: 48 | log.html_img("click: Find failed", "images/"+getFilename(target)) 49 | sik_scrn = SikuliScreen() 50 | log.screenshot(msg="Screen", region=(sik_scrn.getX(), sik_scrn.getY(), sik_scrn.getW(), sik_scrn.getH())) 51 | raise e 52 | 53 | def doubleClick(target, modifiers=0): 54 | try: 55 | return sikuli_method('doubleClick', target, modifiers) 56 | except FindFailed, e: 57 | log.html_img("doubleClick: Find failed", "images/"+getFilename(target)) 58 | sik_scrn = SikuliScreen() 59 | log.screenshot(msg="Screen", region=(sik_scrn.getX(), sik_scrn.getY(), sik_scrn.getW(), sik_scrn.getH())) 60 | raise e 61 | 62 | def rightClick(target, modifiers=0): 63 | try: 64 | return sikuli_method('rightClick', target, modifiers) 65 | except FindFailed, e: 66 | log.html_img("rightClick: Find failed", "images/"+getFilename(target)) 67 | sik_scrn = SikuliScreen() 68 | log.screenshot(msg="Screen", region=(sik_scrn.getX(), sik_scrn.getY(), sik_scrn.getW(), sik_scrn.getH())) 69 | raise e 70 | 71 | def wait(target, timeout=4): 72 | try: 73 | return sikuli_method('wait', target, float(timeout)) 74 | except FindFailed, e: 75 | log.html_img("wait: Find failed", "images/"+getFilename(target)) 76 | sik_scrn = SikuliScreen() 77 | log.screenshot(msg="Screen", region=(sik_scrn.getX(), sik_scrn.getY(), sik_scrn.getW(), sik_scrn.getH())) 78 | raise e 79 | 80 | 81 | # =============================================== # 82 | # Overwritten sikuli classes # 83 | # =============================================== # 84 | 85 | # overwriten Sikuli Region class 86 | class Region(SikuliRegion, BaseLogger): 87 | 88 | def click(self, target, modifiers=0): 89 | try: 90 | return SikuliRegion.click(self, target, modifiers) 91 | except FindFailed, e: 92 | self.log.html_img("region.click: Find failed", "images/" + getFilename(target)) 93 | self.log.screenshot(msg="Region", region=(self.getX(), self.getY(), self.getW(), self.getH())) 94 | raise e 95 | 96 | def doubleClick(self, target, modifiers=0): 97 | try: 98 | return SikuliRegion.doubleClick(self, target, modifiers) 99 | except FindFailed, e: 100 | self.log.html_img("region.doubleClick: Find failed", "images/" + getFilename(target)) 101 | self.log.screenshot(msg="Region", region=(self.getX(), self.getY(), self.getW(), self.getH())) 102 | raise e 103 | def exists(self, target, timeout=None): 104 | img = getFilename(target) 105 | reg = (self.getX(), self.getY(), self.getW(), self.getH()) 106 | addFoundImage(img, reg) 107 | return SikuliRegion.exists(self, target, timeout) 108 | 109 | def verify(self, target, timeout=None): 110 | img = getFilename(target) 111 | reg = (self.getX(), self.getY(), self.getW(), self.getH()) 112 | addFoundImage(img, reg) 113 | return SikuliRegion.exists(self, target, timeout) 114 | -------------------------------------------------------------------------------- /Ch4/reference-test-working-as-desired/testsuite/parent/FirstSuite.txt: -------------------------------------------------------------------------------- 1 | ***Settings*** 2 | Library TestAction1.XTest WITH NAME TestAction1 3 | ***Test Cases*** 4 | 5 | Test Case 1 6 | TestAction1.Execute -------------------------------------------------------------------------------- /Ch4/reference-test-working-as-desired/testsuite/parent/hhh/ThirdSuite.txt: -------------------------------------------------------------------------------- 1 | ***Settings*** 2 | Library anotheraction.XTest WITH NAME anotheraction 3 | ***Test Cases*** 4 | 5 | Test Case 1 6 | anotheraction.Execute -------------------------------------------------------------------------------- /Ch4/reference-test-working-as-desired/testsuite/parent/kane/SecondSuite.txt: -------------------------------------------------------------------------------- 1 | ***Settings*** 2 | Library 2ndcase1staction.XTest WITH NAME 2ndcase1staction 3 | ***Test Cases*** 4 | 5 | Test Case 1 6 | 2ndcase1staction.Execute -------------------------------------------------------------------------------- /Ch4/reference-test-working-as-desired/xat.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SumitBisht/RobotFrameworkTestAutomation/21d8e9feda5a5aa1a369f35ecb01706c3c8153a4/Ch4/reference-test-working-as-desired/xat.exe -------------------------------------------------------------------------------- /Ch4/seleniumTest/results/output.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Opens a new browser instance to given URL. 8 | 9 | ${LOGIN URL} 10 | 11 | Opening browser 'firefox' to base url 'http://localhost:5000/' 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | Navigates the active browser instance to the provided URL. 22 | 23 | ${LOGIN URL} 24 | 25 | Opening url 'http://localhost:5000/' 26 | 27 | 28 | 29 | Sets the delay in seconds that is waited after each Selenium command. 30 | 31 | ${DELAY} 32 | 33 | 34 | 35 | 36 | Verifies that current page title equals `title`. 37 | 38 | My Application 39 | 40 | Page title is 'My Application'. 41 | 42 | 43 | 44 | Pauses the test executed for the given time. 45 | 46 | 2 47 | 48 | Slept 2 seconds 49 | 50 | 51 | 52 | Types the given `text` into text field identified by `locator`. 53 | 54 | username 55 | ${VALID USER} 56 | 57 | Typing text 'admin' into text field 'username' 58 | 59 | 60 | 61 | Types the given password into text field identified by `locator`. 62 | 63 | password 64 | Wrong password 65 | 66 | Typing password into text field 'password' 67 | 68 | 69 | 70 | Pauses the test executed for the given time. 71 | 72 | 2 73 | 74 | Slept 2 seconds 75 | 76 | 77 | 78 | Clicks a button identified by `locator`. 79 | 80 | Login 81 | 82 | Clicking button 'Login'. 83 | 84 | 85 | 86 | Verifies that current page contains `text`. 87 | 88 | Error while logging in with ${VALID USER} 89 | 90 | Current page contains text 'Error while logging in with admin'. 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | Navigates the active browser instance to the provided URL. 101 | 102 | ${LOGIN URL} 103 | 104 | Opening url 'http://localhost:5000/' 105 | 106 | 107 | 108 | Verifies that current page title equals `title`. 109 | 110 | My Application 111 | 112 | Page title is 'My Application'. 113 | 114 | 115 | 116 | Pauses the test executed for the given time. 117 | 118 | 2 119 | 120 | Slept 2 seconds 121 | 122 | 123 | 124 | Types the given `text` into text field identified by `locator`. 125 | 126 | username 127 | ${VALID USER} 128 | 129 | Typing text 'admin' into text field 'username' 130 | 131 | 132 | 133 | Types the given password into text field identified by `locator`. 134 | 135 | password 136 | ${VALID PASSWD} 137 | 138 | Typing password into text field 'password' 139 | 140 | 141 | 142 | Pauses the test executed for the given time. 143 | 144 | 2 145 | 146 | Slept 2 seconds 147 | 148 | 149 | 150 | Clicks a button identified by `locator`. 151 | 152 | Login 153 | 154 | Clicking button 'Login'. 155 | 156 | 157 | 158 | Verifies that current URL is exactly `url`. 159 | 160 | ${SUCCESS URL} 161 | 162 | Current location is 'http://localhost:5000/secure'. 163 | 164 | 165 | 166 | Verifies that current page contains `text`. 167 | 168 | Logged in successfully 169 | 170 | Current page contains text 'Logged in successfully'. 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | Critical Tests 191 | All Tests 192 | 193 | 194 | 195 | 196 | Testsuites 197 | Testsuites.Login Test 198 | 199 | 200 | 201 | 202 | 203 | -------------------------------------------------------------------------------- /Ch4/seleniumTest/results/selenium-screenshot-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SumitBisht/RobotFrameworkTestAutomation/21d8e9feda5a5aa1a369f35ecb01706c3c8153a4/Ch4/seleniumTest/results/selenium-screenshot-1.png -------------------------------------------------------------------------------- /Ch4/seleniumTest/run.sh: -------------------------------------------------------------------------------- 1 | pybot -o results/output -l results/log -r results/report testsuites 2 | -------------------------------------------------------------------------------- /Ch4/seleniumTest/src/flaskApp/hello.py: -------------------------------------------------------------------------------- 1 | from flask import Flask, request, render_template, flash, redirect, url_for 2 | app = Flask(__name__) 3 | app.secret_key = 'AXAPBswe4B' 4 | 5 | @app.route('/') 6 | def login(): 7 | return render_template('login.html') 8 | 9 | @app.route('/secure', methods=['POST']) 10 | def secured(): 11 | user = request.form['username'] 12 | password = request.form['password'] 13 | if(user == "admin" and password == "s3cur3"): 14 | flash("Logged in successfully") 15 | return render_template('secure.html') 16 | else: 17 | flash("Error while logging in with "+user) 18 | return redirect(url_for('login')) 19 | 20 | 21 | if __name__ == '__main__': 22 | app.run(debug=True) 23 | -------------------------------------------------------------------------------- /Ch4/seleniumTest/src/flaskApp/templates/layout.html: -------------------------------------------------------------------------------- 1 | 2 | My Application 3 | {% with messages = get_flashed_messages() %} 4 | {% if messages %} 5 | 10 | {% endif %} 11 | {% endwith %} 12 | {% block body %}{% endblock %} -------------------------------------------------------------------------------- /Ch4/seleniumTest/src/flaskApp/templates/login.html: -------------------------------------------------------------------------------- 1 | {% extends "layout.html" %} 2 | Enter user details 3 | {% block body %} 4 |
5 |
6 | Name:
7 | Password:
8 | 9 |
10 |

please enter the login credentials

11 |
12 | {% endblock %} -------------------------------------------------------------------------------- /Ch4/seleniumTest/src/flaskApp/templates/secure.html: -------------------------------------------------------------------------------- 1 | Provided details 2 | {% extends "layout.html" %} 3 | {% block body %} 4 |

Logged in succesfully as {{request.form.username}}

5 | Relogin 6 | {% endblock %} -------------------------------------------------------------------------------- /Ch4/seleniumTest/testsuites/login_test.txt: -------------------------------------------------------------------------------- 1 | *** Settings *** 2 | Library Selenium2Library 3 | 4 | 5 | *** Variables *** 6 | 7 | ${SERVER} localhost:5000 8 | ${BROWSER} firefox 9 | ${DELAY} 0 10 | ${VALID USER} admin 11 | ${VALID PASSWD} s3cur3 12 | ${LOGIN URL} http://${SERVER}/ 13 | ${SUCCESS URL} ${LOGIN URL}secure 14 | 15 | *** Test Cases *** 16 | Start up the browser window first Open Browser ${LOGIN URL} 17 | 18 | Perform Wrong credentials GO TO ${LOGIN URL} 19 | #Maximize Browser Window 20 | Set Selenium Speed ${DELAY} 21 | Title Should Be My Application 22 | #Page Should Contain TextField username 23 | #Page Should Contain TextField password 24 | Sleep 2 25 | Input Text username ${VALID USER} 26 | Input Password password Wrong password 27 | Sleep 2 28 | Click Button Login 29 | Page Should Contain Error while logging in with ${VALID USER} 30 | 31 | Perform correct credentials GO TO ${LOGIN URL} 32 | Title Should Be My Application 33 | #Page Should Contain TextField username 34 | #Page Should Contain TextField password 35 | Sleep 2 36 | Input Text username ${VALID USER} 37 | Input Password password ${VALID PASSWD} 38 | Sleep 2 39 | Click Button Login 40 | Location Should be ${SUCCESS URL} 41 | Page Should Contain Logged in successfully -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2013 sumitbisht4u 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | RobotFrameworkTestAutomation 2 | ============================ 3 | 4 | These are the sources for the upcoming book, 'Robot Framework Test Automation' 5 | 6 | 7 | [![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/SumitBisht/robotframeworktestautomation/trend.png)](https://bitdeli.com/free "Bitdeli Badge") 8 | 9 | --------------------------------------------------------------------------------