Class: Scoutui::Utils::TestUtils
- Inherits:
-
Object
- Object
- Scoutui::Utils::TestUtils
- Includes:
- Singleton
- Defined in:
- lib/scoutui/utils/utils.rb
Instance Attribute Summary collapse
-
#app_model ⇒ Object
Returns the value of attribute app_model.
-
#coverage ⇒ Object
Returns the value of attribute coverage.
-
#currentTest ⇒ Object
Returns the value of attribute currentTest.
-
#execution_status ⇒ Object
Returns the value of attribute execution_status.
-
#final_rc ⇒ Object
Returns the value of attribute final_rc.
-
#metrics ⇒ Object
Returns the value of attribute metrics.
-
#options ⇒ Object
Returns the value of attribute options.
Instance Method Summary collapse
- #abort? ⇒ Boolean
- #addPageCoverage(p) ⇒ Object
- #appName ⇒ Object
- #assertExpected? ⇒ Boolean
- #currentMessage ⇒ Object
- #expandVars(h) ⇒ Object
- #eyesBatchId ⇒ Object
- #eyesBatchname ⇒ Object
- #eyesEnabled? ⇒ Boolean
- #eyesFullscreen? ⇒ Boolean
- #eyesMatchTimeout ⇒ Object
- #getAppModel ⇒ Object
- #getBrowser ⇒ Object
- #getBrowserType ⇒ Object
- #getCapabilities ⇒ Object
- #getDefaultWait ⇒ Object
- #getDiffDir ⇒ Object
- #getFinalRc ⇒ Object
- #getForm(s) ⇒ Object
- #getHost ⇒ Object
- #getLicenseFile ⇒ Object
- #getMetrics ⇒ Object
- #getPageCoverage ⇒ Object
- #getPageElement(s) ⇒ Object
- #getPassword ⇒ Object
- #getReporter ⇒ Object
- #getReq ⇒ Object
- #getRole ⇒ Object
- #getSauceBuild ⇒ Object
- #getSauceCaps ⇒ Object
- #getSauceName ⇒ Object
- #getSeleniumServer ⇒ Object
- #getState ⇒ Object
- #getTC ⇒ Object
- #getTestConfig ⇒ Object
-
#getTestSettings ⇒ Object
Returns JSON file contents/format.
- #getUser ⇒ Object
- #getUserId ⇒ Object
- #getViewPort ⇒ Object
- #hasTestConfig? ⇒ Boolean
- #host ⇒ Object
-
#initialize ⇒ TestUtils
constructor
A new instance of TestUtils.
- #isDebug? ⇒ Boolean
- #isFailFast? ⇒ Boolean
- #loadModel(f = nil) ⇒ Object
- #loc ⇒ Object
- #localization ⇒ Object
- #match_level ⇒ Object
- #parseCommandLine ⇒ Object
- #retries ⇒ Object
- #sanitize_filename(filename) ⇒ Object
- #sauceEnabled? ⇒ Boolean
- #saucePlatform ⇒ Object
- #sauceResolution ⇒ Object
- #screenShots? ⇒ Boolean
- #screenShotsDir ⇒ Object
- #screenShotsOnFailure? ⇒ Boolean
- #setDebug(b) ⇒ Object
- #setFinalRc(b) ⇒ Object
- #setHost(_h) ⇒ Object
- #setMetrics(_m) ⇒ Object
- #setReporter(_r) ⇒ Object
- #setReq(_r = 'UI') ⇒ Object
- #setState(s, _d = nil) ⇒ Object
- #setTC(_tc = nil) ⇒ Object
- #testConfigFile ⇒ Object
- #testFile ⇒ Object
- #title ⇒ Object
- #transpile(_val) ⇒ Object
Constructor Details
#initialize ⇒ TestUtils
Returns a new instance of TestUtils.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 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 67 |
# File 'lib/scoutui/utils/utils.rb', line 23 def initialize @currentMessage="" @coverage={:pages => []} @final_rc=false @metrics=nil @execution_status = :ready @env_list={:accounts => 'SCOUTUI_ACCOUNTS', :browser => 'SCOUTUI_BROWSER', :applitools_api_key => 'APPLITOOLS_API_KEY'} @options={} @currentTest={:reqid => 'UI', :testcase => '00' } [:accounts, :browser, :capabilities, :diffs_dir, :dut,:test_file, :host, :loc, :title, :viewport, :userid, :password, :role, :json_config_file, :page_model, :report, :selenium_server, :test_config, :debug].each do |o| @options[o]=nil end @options[:include_expected_as_asserts]=false @options[:role]=nil @options[:sauce_name]='unnamed' @options[:enable_eyes]=false @options[:enable_fullscreen]=true @options[:enable_sauce]=false @options[:batchid]=nil @options[:batchname]=nil @options[:log_level]=:info # :debug, :info, :warn, :error, :fatal @options[:match_level]='layout2' @options[:match_timeout]=nil # Is 2 by Default per Applitools @options[:default_wait]=30 # seconds @options[:debug]=false @options[:fail_fast]=false @options[:screenshots]=false @options[:screenshots_dir]=nil @options[:screenshots_only_on_failure]=true @options[:retries]=1 @app_model=nil Scoutui::Base::UserVars.instance.set('eyes.viewport', '1024x768') Scoutui::Base::UserVars.instance.set('eyes.viewport', nil) end |
Instance Attribute Details
#app_model ⇒ Object
Returns the value of attribute app_model.
14 15 16 |
# File 'lib/scoutui/utils/utils.rb', line 14 def app_model @app_model end |
#coverage ⇒ Object
Returns the value of attribute coverage.
20 21 22 |
# File 'lib/scoutui/utils/utils.rb', line 20 def coverage @coverage end |
#currentTest ⇒ Object
Returns the value of attribute currentTest.
15 16 17 |
# File 'lib/scoutui/utils/utils.rb', line 15 def currentTest @currentTest end |
#execution_status ⇒ Object
Returns the value of attribute execution_status.
21 22 23 |
# File 'lib/scoutui/utils/utils.rb', line 21 def execution_status @execution_status end |
#final_rc ⇒ Object
Returns the value of attribute final_rc.
18 19 20 |
# File 'lib/scoutui/utils/utils.rb', line 18 def final_rc @final_rc end |
#metrics ⇒ Object
Returns the value of attribute metrics.
17 18 19 |
# File 'lib/scoutui/utils/utils.rb', line 17 def metrics @metrics end |
#options ⇒ Object
Returns the value of attribute options.
13 14 15 |
# File 'lib/scoutui/utils/utils.rb', line 13 def @options end |
Instance Method Details
#abort? ⇒ Boolean
78 79 80 |
# File 'lib/scoutui/utils/utils.rb', line 78 def abort? @execution_status==:abort end |
#addPageCoverage(p) ⇒ Object
90 91 92 |
# File 'lib/scoutui/utils/utils.rb', line 90 def addPageCoverage(p) @coverage[:pages] << p end |
#appName ⇒ Object
641 642 643 |
# File 'lib/scoutui/utils/utils.rb', line 641 def appName() @options[:app].to_s end |
#assertExpected? ⇒ Boolean
522 523 524 |
# File 'lib/scoutui/utils/utils.rb', line 522 def assertExpected? @options[:include_expected_as_asserts] end |
#currentMessage ⇒ Object
74 75 76 |
# File 'lib/scoutui/utils/utils.rb', line 74 def currentMessage @currentMessage end |
#expandVars(h) ⇒ Object
679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 |
# File 'lib/scoutui/utils/utils.rb', line 679 def (h) puts __FILE__ + (__LINE__).to_s + " expandVars(#{h})" h.each do |k, v| if v.is_a?(Hash) || v.is_a?(Array) (v) else puts("k is #{k}, value is #{v}") h[k]=transpile(v) end end h end |
#eyesBatchId ⇒ Object
454 455 456 |
# File 'lib/scoutui/utils/utils.rb', line 454 def eyesBatchId() @options[:batchid] end |
#eyesBatchname ⇒ Object
450 451 452 |
# File 'lib/scoutui/utils/utils.rb', line 450 def eyesBatchname() @options[:batchname] end |
#eyesEnabled? ⇒ Boolean
458 459 460 |
# File 'lib/scoutui/utils/utils.rb', line 458 def eyesEnabled? @options[:enable_eyes] end |
#eyesFullscreen? ⇒ Boolean
466 467 468 |
# File 'lib/scoutui/utils/utils.rb', line 466 def eyesFullscreen? @options[:enable_fullscreen] end |
#eyesMatchTimeout ⇒ Object
462 463 464 |
# File 'lib/scoutui/utils/utils.rb', line 462 def eyesMatchTimeout() @options[:match_timeout] end |
#getAppModel ⇒ Object
161 162 163 |
# File 'lib/scoutui/utils/utils.rb', line 161 def getAppModel() @app_model end |
#getBrowser ⇒ Object
510 511 512 |
# File 'lib/scoutui/utils/utils.rb', line 510 def getBrowser() getBrowserType() end |
#getBrowserType ⇒ Object
513 514 515 |
# File 'lib/scoutui/utils/utils.rb', line 513 def getBrowserType() @options[:browser] end |
#getCapabilities ⇒ Object
358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 |
# File 'lib/scoutui/utils/utils.rb', line 358 def getCapabilities() @options[:capabilities]=Hash.new if @options.has_key?(:capabilities) && @options[:capabilities].nil? if @options.has_key?(:sauce_platform) && !@options[:sauce_platform].nil? @options[:capabilities][:platform]=@options[:sauce_platform] end if !sauceResolution().nil? @options[:capabilities][:screenResolution]=sauceResolution() end if @options.has_key?(:sauce_browser) @options[:capabilities][:browser] = @options[:sauce_browser] end if @options.has_key?(:sauce_version) @options[:capabilities][:version] = @options[:sauce_version] end if @options.has_key?(:sauce_name) @options[:capabilities][:name] = @options[:sauce_name] end if @options.has_key?(:sauce_build) @options[:capabilities][:build] = @options[:sauce_build] end if @options.has_key?(:sauce_browsername) @options[:capabilities][:browserName] = @options[:sauce_browsername] end Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + " caps => #{@options[:capabilities].to_s}" @options[:capabilities][:tags]=[@options[:sauce_name], "ScoutUI"] @options[:capabilities] end |
#getDefaultWait ⇒ Object
517 518 519 |
# File 'lib/scoutui/utils/utils.rb', line 517 def getDefaultWait() @options[:default_wait] end |
#getDiffDir ⇒ Object
610 611 612 |
# File 'lib/scoutui/utils/utils.rb', line 610 def getDiffDir() @options[:diffs_dir] end |
#getFinalRc ⇒ Object
98 99 100 |
# File 'lib/scoutui/utils/utils.rb', line 98 def getFinalRc() @final_rc end |
#getForm(s) ⇒ Object
146 147 148 149 |
# File 'lib/scoutui/utils/utils.rb', line 146 def getForm(s) _h = getPageElement(s) Scoutui::Base::QForm.new(_h) end |
#getHost ⇒ Object
425 426 427 |
# File 'lib/scoutui/utils/utils.rb', line 425 def getHost() @options[:host].to_s end |
#getLicenseFile ⇒ Object
478 479 480 |
# File 'lib/scoutui/utils/utils.rb', line 478 def getLicenseFile() @options[:license_file].to_s end |
#getMetrics ⇒ Object
106 107 108 |
# File 'lib/scoutui/utils/utils.rb', line 106 def getMetrics() @metrics end |
#getPageCoverage ⇒ Object
86 87 88 |
# File 'lib/scoutui/utils/utils.rb', line 86 def getPageCoverage() @coverage[:pages] end |
#getPageElement(s) ⇒ Object
151 152 153 154 155 156 157 158 159 |
# File 'lib/scoutui/utils/utils.rb', line 151 def getPageElement(s) rc=nil if !@app_model.nil? rc=@app_model.getPageElement(s) end rc end |
#getPassword ⇒ Object
622 623 624 |
# File 'lib/scoutui/utils/utils.rb', line 622 def getPassword() @options[:password] end |
#getReporter ⇒ Object
434 435 436 |
# File 'lib/scoutui/utils/utils.rb', line 434 def getReporter() @options[:report] end |
#getReq ⇒ Object
114 115 116 |
# File 'lib/scoutui/utils/utils.rb', line 114 def getReq() @currentTest[:reqid] end |
#getRole ⇒ Object
486 487 488 |
# File 'lib/scoutui/utils/utils.rb', line 486 def getRole() @options[:role] end |
#getSauceBuild ⇒ Object
502 503 504 |
# File 'lib/scoutui/utils/utils.rb', line 502 def getSauceBuild() @options[:sauce_build] || nil end |
#getSauceCaps ⇒ Object
494 495 496 |
# File 'lib/scoutui/utils/utils.rb', line 494 def getSauceCaps() @options[:sauce_capabilities] end |
#getSauceName ⇒ Object
498 499 500 |
# File 'lib/scoutui/utils/utils.rb', line 498 def getSauceName() @options[:sauce_name].to_s end |
#getSeleniumServer ⇒ Object
506 507 508 |
# File 'lib/scoutui/utils/utils.rb', line 506 def getSeleniumServer() @options[:selenium_server] end |
#getState ⇒ Object
82 83 84 |
# File 'lib/scoutui/utils/utils.rb', line 82 def getState() @execution_status end |
#getTC ⇒ Object
118 119 120 |
# File 'lib/scoutui/utils/utils.rb', line 118 def getTC() @currentTest[:testcase] end |
#getTestConfig ⇒ Object
602 603 604 |
# File 'lib/scoutui/utils/utils.rb', line 602 def getTestConfig() @options[:test_config] end |
#getTestSettings ⇒ Object
Returns JSON file contents/format
535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 |
# File 'lib/scoutui/utils/utils.rb', line 535 def getTestSettings() Scoutui::Logger::LogMgr.instance.setLevel(@options[:log_level]) [:accounts, :browser, :dut, :host, :role, :userid, :password].each do |k| Scoutui::Logger::LogMgr.instance.info __FILE__ + (__LINE__).to_s + " opt[test_config].has_key(#{k.to_s}) => #{@options[:test_config].has_key?(k.to_s)}" Scoutui::Logger::LogMgr.instance.info __FILE__ + (__LINE__).to_s + " options[#{k}] : #{@options[k].to_s}" if Scoutui::Utils::TestUtils.instance.isDebug? if @options.has_key?(k) && !@options[k].nil? Scoutui::Base::UserVars.instance.set(k, @options[k].to_s) elsif @options[:test_config].has_key?(k.to_s) Scoutui::Logger::LogMgr.instance.info __FILE__ + (__LINE__).to_s + " opts[#{k}].nil => #{@options[k].nil?}" if Scoutui::Utils::TestUtils.instance.isDebug? # Ensure commnand line takes precedence if !@options[k].nil? Scoutui::Logger::LogMgr.instance.info __FILE__ + (__LINE__).to_s + " opt[#{k.to_s} => #{@options[k].to_s}" if Scoutui::Utils::TestUtils.instance.isDebug? Scoutui::Base::UserVars.instance.set(k, @options[k].to_s) else Scoutui::Base::UserVars.instance.set(k, @options[:test_config][k.to_s].to_s) end elsif @env_list.has_key?(k) # If an ENV is available, use it. Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + " #{k} => ENV(#{@env_list[k]}) = #{ENV[@env_list[k].to_s]}" if Scoutui::Utils::TestUtils.instance.isDebug? Scoutui::Base::UserVars.instance.set(k, ENV[@env_list[k].to_s]) end end Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + " test_config => #{@options[:test_config]}" # If the user explicitly provided command file from args. if @options.has_key?(:dut) && !@options[:dut].nil? @options[:test_config]['dut']=@options[:dut] end # Applitools Eyes settings if @options[:test_config].has_key?('eyes') ['match_level', 'title', 'app', 'viewport'].each do |k| _v=nil if @options[:test_config]['eyes'].has_key?(k) _v=@options[:test_config]['eyes'][k].to_s end if !@options[k.to_sym].nil? Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + " eyes[#{k.to_s}] override with #{@options[k.to_sym]}" _v=@options[k.to_sym].to_s end Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + " #{k} => #{_v}" Scoutui::Base::UserVars.instance.set('eyes.' + k, _v) if !_v.nil? end end @options[:test_config] end |
#getUser ⇒ Object
618 619 620 |
# File 'lib/scoutui/utils/utils.rb', line 618 def getUser() getUserId() end |
#getUserId ⇒ Object
614 615 616 |
# File 'lib/scoutui/utils/utils.rb', line 614 def getUserId() @options[:userid] end |
#getViewPort ⇒ Object
165 166 167 168 169 170 171 172 173 174 175 176 |
# File 'lib/scoutui/utils/utils.rb', line 165 def getViewPort() rc=nil if ![:viewport].nil? arr=[:viewport].match(/(\d+)\s*x\s*(\d+)$/i) if arr.size==3 rc = {width: arr[1].to_i, height: arr[2].to_i} end end rc end |
#hasTestConfig? ⇒ Boolean
526 527 528 |
# File 'lib/scoutui/utils/utils.rb', line 526 def hasTestConfig? !@options[:json_config_file].nil? end |
#host ⇒ Object
630 631 632 |
# File 'lib/scoutui/utils/utils.rb', line 630 def host() @options[:host] end |
#isDebug? ⇒ Boolean
446 447 448 |
# File 'lib/scoutui/utils/utils.rb', line 446 def isDebug? @options[:debug] end |
#isFailFast? ⇒ Boolean
94 95 96 |
# File 'lib/scoutui/utils/utils.rb', line 94 def isFailFast? @options[:fail_fast] end |
#loadModel(f = nil) ⇒ Object
130 131 132 133 134 135 136 137 138 139 140 141 142 143 |
# File 'lib/scoutui/utils/utils.rb', line 130 def loadModel(f=nil) if f.nil? return nil end begin @app_model = Scoutui::ApplicationModel::QModel.new(f) @app_model.getAppModel() rescue => ex raise "ErrorLoad : #{f.to_s}" end @app_model end |
#loc ⇒ Object
634 635 636 |
# File 'lib/scoutui/utils/utils.rb', line 634 def loc() @options[:loc] end |
#localization ⇒ Object
637 638 639 |
# File 'lib/scoutui/utils/utils.rb', line 637 def localization() loc() end |
#match_level ⇒ Object
606 607 608 |
# File 'lib/scoutui/utils/utils.rb', line 606 def match_level() @options[:match_level] end |
#parseCommandLine ⇒ Object
179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 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 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 |
# File 'lib/scoutui/utils/utils.rb', line 179 def parseCommandLine() OptionParser.new do |opt| opt.on('-c', '--config TESTFILE') { |o| if !o.nil? @options[:json_config_file]=o jFile = File.read(@options[:json_config_file]) @options[:test_config]=jsonData=JSON.parse(jFile) end } opt.on('--accounts [Account]') { |o| @options[:accounts] = o } opt.on('-b', '--browser [TYPE]', [:chrome, :firefox, :ie, :safari, :phantomjs], "Select browser (chrome, ie, firefox, safari)") { |o| @options[:browser] = o } opt.on('--capabilities CAP') { |o| @options[:capabilities]=o jFile = File.read(o) @options[:capabilities]=jsonData=JSON.parse(jFile, :symbolize_names => true) } opt.on('--loglevel Level') { |o| if o.match(/error/i) @options[:log_level] = :error elsif o.match(/fatal/i) @options[:log_level] = :fatal elsif o.match(/info/i) @options[:log_level] = :info elsif o.match(/warn/i) @options[:log_level] = :warn elsif o.match(/debug/i) @options[:log_level] = :debug end Scoutui::Logger::LogMgr.instance.setLevel(@options[:log_level]) } opt.on('--diffs Full Path') { |o| @options[:diffs_dir] = o } opt.on('-d', '--debug', 'Enable debug') { |o| @options[:debug] = true @options[:log_level] = :debug } opt.on('--dut DUT') { |o| @options[:dut]=o } opt.on('-h', '--host HOST') { |o| @options[:host] = o } opt.on('-i', '--include_expectations') { |o| @options[:include_expected_as_asserts] = true} opt.on('-l', '--lang LOCAL') { |o| @options[:loc] = o Scoutui::Base::UserVars.instance.setVar(:lang, @options[:loc].to_s) } opt.on('-k', '--key EyesLicense') { |o| [:license_file] = o } opt.on('-a', '--app AppName') { |o| @options[:app] = o } opt.on('--match [LEVEL]', [:layout2, :layout, :strict, :exact, :content], "Select match level (layout, strict, exact, content)") { |o| @options[:match_level] = o } opt.on('--eyes:match [LEVEL]', [:layout2, :layout, :strict, :exact, :content], "Select match level (layout, strict, exact, content)") { |o| @options[:match_level] = o } opt.on('--failfast Bool', [:true, :false]) { |o| @options[:fail_fast] = !o.match(/true/i).nil? } opt.on("--pages a,b,c", Array, "List of page models") do |list| Scoutui::Logger::LogMgr.instance.info __FILE__ + (__LINE__).to_s + " list => #{list}" @options[:pages]=list loadModel(@options[:pages]) end opt.on('--var [Key:Value]') { |o| if o.match(/(.+?):(.*)$/) _result=o.match(/(.+)?:(.*)$/) Scoutui::Base::UserVars.instance.setVar(_result[1].to_s, _result[2].to_s) else Scoutui::Logger::LogMgr.instance.warn __FILE__ + (__LINE__).to_s + " Invalid --var value : #{o}, should be <key>:<value>" end } opt.on('--pagemodel [PageModel]') { |o| @options[:page_model] = o loadModel(@options[:page_model].to_s) } opt.on('--retries RETRIES') { |o| if o.match(/\d+/) @options[:retries] = o.to_i end } opt.on('-w', '--wait WaitOnElement') { |o| if o.match(/\d+/) @options[:default_wait] = o.to_i end } opt.on('-t', '--title TITLE') { |o| @options[:title] = o } opt.on('-u', '--user USER_ID') { |o| @options[:userid] = o Scoutui::Base::UserVars.instance.setVar(:user, @options[:userid].to_s) } opt.on('-p', '--password PASSWORD') { |o| @options[:password] = o } opt.on('-e', '--eyes', "Toggle eyes") { @options[:enable_eyes]=true } opt.on('--eyes:run Bool', [:true, :false]) { |o| @options[:enable_eyes] = !o.match(/true/i).nil? } opt.on('--eyes:batchname Name') { |o| @options[:batchname] = o } opt.on('--eyes:batchid ID') { |o| @options[:batchid] = o } opt.on('--eyes:fullscreen Bool', [:true, :false]) { |o| @options[:enable_fullscreen] = !o.match(/true/i).nil? } opt.on('--eyes:app AppName') { |o| @options[:app] = o } opt.on('--eyes:title Title') { |o| @options[:title] = o } opt.on('--eyes:viewport [resolution]') { |o| @options[:viewport] = o } opt.on('--eyes:matchtimeout MatchTimeWait') { |o| if o.match(/\d+/) @options[:match_timeout] = o.to_i end } opt.on('--report:junit File') { |o| @options[:report] = o } opt.on('--screenshots Bool', [:true, :false]) { |o| @options[:screenshots] = !o.match(/true/i).nil? } opt.on('--screenshots:run Bool') { |o| @options[:screenshots] = !o.match(/true/i).nil? } opt.on('--screenshots:dir DIR') { |o| @options[:screenshots_dir] = o.to_s } opt.on('--screenshots:onfailure Bool') { |o| @options[:screenshots_only_on_failure] = o.to_s } opt.on('--role ROLE') { |o| @options[:role]=o } opt.on('-s', '--sauce', "Toggle SauceLabs") { @options[:enable_sauce]=true } opt.on('--sauce:run NAME', [:true, :false]) { |o| @options[:enable_sauce] = !o.match(/true/i).nil? } opt.on('--sauce_name NAME') { |o| @options[:sauce_name] = o } opt.on('--sauce:capabilities Capabilities') { |o| @options[:sauce_capabilities] = o } opt.on('--sauce:name NAME') { |o| @options[:sauce_name] = o } opt.on('--sauce:build id') { |o| @options[:sauce_build] = o } opt.on('--sauce:browser Browser') { |o| @options[:sauce_browser] = o } opt.on('--sauce:browsername BrowserName') { |o| @options[:sauce_browsername] = o } opt.on('--sauce:platform Platform') { |o| @options[:sauce_platform] = o } opt.on('--sauce:resolution Resolution') { |o| @options[:sauce_resolution] = o } opt.on('--sauce:version Version') { |o| @options[:sauce_version] = o } opt.on('--seleniumserver URL') { |o| @options[:selenium_server] = o } opt.on('--viewport [resolution]') { |o| @options[:viewport] = o Scoutui::Base::UserVars.instance.set('eyes.viewport', @options[:viewport]) } end.parse! if Scoutui::Utils::TestUtils.instance.isDebug? Scoutui::Logger::LogMgr.instance.info __FILE__ + (__LINE__).to_s + " ScoutUI Version : " + Scoutui::VERSION Scoutui::Logger::LogMgr.instance.info __FILE__ + (__LINE__).to_s + " " + @options.to_s Scoutui::Logger::LogMgr.instance.info "Test file => #{@options[:test_file]}" Scoutui::Logger::LogMgr.instance.info "Host => #{@options[:host]}" Scoutui::Logger::LogMgr.instance.info "Command => #{@options[:dut].to_s}" Scoutui::Logger::LogMgr.instance.info "Loc => #{@options[:loc]}" Scoutui::Logger::LogMgr.instance.info "Title => #{@options[:title]}" Scoutui::Logger::LogMgr.instance.info "Browser => #{@options[:browser]}" Scoutui::Logger::LogMgr.instance.info "UserID => #{@options[:userid]}" Scoutui::Logger::LogMgr.instance.info "Password => #{@options[:password]}" Scoutui::Logger::LogMgr.instance.info "Role => #{@options[:role]}" Scoutui::Logger::LogMgr.instance.info "Eyes => #{@options[:enable_eyes]}" Scoutui::Logger::LogMgr.instance.info "Eyes.Fullscreen => #{@options[:enable_fullscreen]}" Scoutui::Logger::LogMgr.instance.info "Test Cfg => #{@options[:json_config_file]}" Scoutui::Logger::LogMgr.instance.info "Match Level => #{@options[:match_level]}" Scoutui::Logger::LogMgr.instance.info "Accounts => #{@options[:accounts]}" Scoutui::Logger::LogMgr.instance.info "Viewport => #{@options[:viewport]}" Scoutui::Logger::LogMgr.instance.info "Viewport (Var) => #{Scoutui::Base::UserVars.instance.getViewPort().to_s}" Scoutui::Logger::LogMgr.instance.info "PageModel file => #{@options[:page_model].to_s}" Scoutui::Logger::LogMgr.instance.info "Sauce.Run => #{@options[:sauce_run].to_s}" Scoutui::Logger::LogMgr.instance.info "Sauce.Platform => #{@options[:sauce_platform].to_s}" Scoutui::Logger::LogMgr.instance.info "Failfast => #{@options[:fail_fast]}" end @options end |
#retries ⇒ Object
490 491 492 |
# File 'lib/scoutui/utils/utils.rb', line 490 def retries() @options[:retries] end |
#sanitize_filename(filename) ⇒ Object
397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 |
# File 'lib/scoutui/utils/utils.rb', line 397 def sanitize_filename(filename) # Split the name when finding a period which is preceded by some # character, and is followed by some character other than a period, # if there is no following period that is followed by something # other than a period fn = filename.split /(?<=.)\.(?=[^.])(?!.*\.[^.])/m # We now have one or two parts (depending on whether we could find # a suitable period). For each of these parts, replace any unwanted # sequence of characters with an underscore fn.map! { |s| s.gsub /[^a-z0-9\-]+/i, '_' } # Finally, join the parts with a period and return the result return fn.join '.' end |
#sauceEnabled? ⇒ Boolean
470 471 472 |
# File 'lib/scoutui/utils/utils.rb', line 470 def sauceEnabled? @options[:enable_sauce] end |
#saucePlatform ⇒ Object
474 475 476 |
# File 'lib/scoutui/utils/utils.rb', line 474 def saucePlatform() @options[:sauce_platform] end |
#sauceResolution ⇒ Object
482 483 484 |
# File 'lib/scoutui/utils/utils.rb', line 482 def sauceResolution() @options[:sauce_resolution] end |
#screenShots? ⇒ Boolean
413 414 415 |
# File 'lib/scoutui/utils/utils.rb', line 413 def screenShots? @options[:screenshots] end |
#screenShotsDir ⇒ Object
421 422 423 |
# File 'lib/scoutui/utils/utils.rb', line 421 def screenShotsDir @options[:screenshots_dir] end |
#screenShotsOnFailure? ⇒ Boolean
417 418 419 |
# File 'lib/scoutui/utils/utils.rb', line 417 def screenShotsOnFailure? @options[:screenshots_only_on_failure] end |
#setDebug(b) ⇒ Object
442 443 444 |
# File 'lib/scoutui/utils/utils.rb', line 442 def setDebug(b) @options[:debug]=b end |
#setFinalRc(b) ⇒ Object
102 103 104 |
# File 'lib/scoutui/utils/utils.rb', line 102 def setFinalRc(b) @final_rc=b end |
#setHost(_h) ⇒ Object
429 430 431 432 |
# File 'lib/scoutui/utils/utils.rb', line 429 def setHost(_h) @options[:host]=_h Scoutui::Base::UserVars.instance.set(:host, @options[:host].to_s) end |
#setMetrics(_m) ⇒ Object
110 111 112 |
# File 'lib/scoutui/utils/utils.rb', line 110 def setMetrics(_m) @metrics=_m end |
#setReporter(_r) ⇒ Object
438 439 440 |
# File 'lib/scoutui/utils/utils.rb', line 438 def setReporter(_r) @options[:report]=_r end |
#setReq(_r = 'UI') ⇒ Object
122 123 124 |
# File 'lib/scoutui/utils/utils.rb', line 122 def setReq(_r='UI') @currentTest[:reqid]=_r end |
#setState(s, _d = nil) ⇒ Object
69 70 71 72 |
# File 'lib/scoutui/utils/utils.rb', line 69 def setState(s, _d=nil) @execution_status=s @currentMessage=_d if !_d.nil? end |
#setTC(_tc = nil) ⇒ Object
126 127 128 |
# File 'lib/scoutui/utils/utils.rb', line 126 def setTC(_tc=nil) @currentTest[:testcase]=_tc end |
#testConfigFile ⇒ Object
530 531 532 |
# File 'lib/scoutui/utils/utils.rb', line 530 def testConfigFile() @options[:json_config_file] end |
#testFile ⇒ Object
626 627 628 |
# File 'lib/scoutui/utils/utils.rb', line 626 def testFile() @options[:test_file] end |
#title ⇒ Object
645 646 647 |
# File 'lib/scoutui/utils/utils.rb', line 645 def title() @options[:title] end |
#transpile(_val) ⇒ Object
650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 |
# File 'lib/scoutui/utils/utils.rb', line 650 def transpile(_val) _uservars = _val.scan(/\$\{(.*?)\}/) _v2 = _val for i in 0 .. (_uservars.size - 1) _t = Scoutui::Base::UserVars.instance.get(_uservars[i][0]) puts __FILE__ + (__LINE__).to_s + " translate(#{_uservars[i][0]}) => #{_t}" if !_t.nil? && _uservars[i][0]!=_t _v2.gsub!("\$\{#{_uservars[i][0]}\}", _t) end puts __FILE__ + (__LINE__).to_s + " value => #{_v2}" end ## Global replaces _text_to_type = Scoutui::Base::UserVars.instance.get(_v2) puts __FILE__ + (__LINE__).to_s + " rawText : #{_text_to_type}" _text_to_type = Scoutui::Commands::Utils.instance.(_text_to_type) puts __FILE__ + (__LINE__).to_s + " Text to type : #{_text_to_type}" _text_to_type end |