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
- #abortMessage ⇒ Object
- #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
- #getSauceTunnel ⇒ 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(args = nil) ⇒ 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 68 69 |
# File 'lib/scoutui/utils/utils.rb', line 23 def initialize @currentMessage="" @failedFastMessage=[] @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[:sauce_tunnelid]=nil @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
90 91 92 |
# File 'lib/scoutui/utils/utils.rb', line 90 def abort? @execution_status==:abort end |
#abortMessage ⇒ Object
82 83 84 |
# File 'lib/scoutui/utils/utils.rb', line 82 def abortMessage @failedFastMessage end |
#addPageCoverage(p) ⇒ Object
102 103 104 |
# File 'lib/scoutui/utils/utils.rb', line 102 def addPageCoverage(p) @coverage[:pages] << p end |
#appName ⇒ Object
672 673 674 |
# File 'lib/scoutui/utils/utils.rb', line 672 def appName() @options[:app].to_s end |
#assertExpected? ⇒ Boolean
553 554 555 |
# File 'lib/scoutui/utils/utils.rb', line 553 def assertExpected? @options[:include_expected_as_asserts] end |
#currentMessage ⇒ Object
86 87 88 |
# File 'lib/scoutui/utils/utils.rb', line 86 def currentMessage @currentMessage end |
#expandVars(h) ⇒ Object
710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 |
# File 'lib/scoutui/utils/utils.rb', line 710 def (h) Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + " expandVars(#{h})" h.each do |k, v| if v.is_a?(Hash) || v.is_a?(Array) (v) else Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + "k is #{k}, value is #{v}" h[k]=transpile(v) end end h end |
#eyesBatchId ⇒ Object
481 482 483 |
# File 'lib/scoutui/utils/utils.rb', line 481 def eyesBatchId() @options[:batchid] end |
#eyesBatchname ⇒ Object
477 478 479 |
# File 'lib/scoutui/utils/utils.rb', line 477 def eyesBatchname() @options[:batchname] end |
#eyesEnabled? ⇒ Boolean
485 486 487 |
# File 'lib/scoutui/utils/utils.rb', line 485 def eyesEnabled? @options[:enable_eyes] end |
#eyesFullscreen? ⇒ Boolean
493 494 495 |
# File 'lib/scoutui/utils/utils.rb', line 493 def eyesFullscreen? @options[:enable_fullscreen] end |
#eyesMatchTimeout ⇒ Object
489 490 491 |
# File 'lib/scoutui/utils/utils.rb', line 489 def eyesMatchTimeout() @options[:match_timeout] end |
#getAppModel ⇒ Object
173 174 175 |
# File 'lib/scoutui/utils/utils.rb', line 173 def getAppModel() @app_model end |
#getBrowser ⇒ Object
541 542 543 |
# File 'lib/scoutui/utils/utils.rb', line 541 def getBrowser() getBrowserType() end |
#getBrowserType ⇒ Object
544 545 546 |
# File 'lib/scoutui/utils/utils.rb', line 544 def getBrowserType() @options[:browser] end |
#getCapabilities ⇒ Object
385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 |
# File 'lib/scoutui/utils/utils.rb', line 385 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
548 549 550 |
# File 'lib/scoutui/utils/utils.rb', line 548 def getDefaultWait() @options[:default_wait] end |
#getDiffDir ⇒ Object
641 642 643 |
# File 'lib/scoutui/utils/utils.rb', line 641 def getDiffDir() @options[:diffs_dir] end |
#getFinalRc ⇒ Object
110 111 112 |
# File 'lib/scoutui/utils/utils.rb', line 110 def getFinalRc() @final_rc end |
#getForm(s) ⇒ Object
158 159 160 161 |
# File 'lib/scoutui/utils/utils.rb', line 158 def getForm(s) _h = getPageElement(s) Scoutui::Base::QForm.new(_h) end |
#getHost ⇒ Object
452 453 454 |
# File 'lib/scoutui/utils/utils.rb', line 452 def getHost() @options[:host].to_s end |
#getLicenseFile ⇒ Object
505 506 507 |
# File 'lib/scoutui/utils/utils.rb', line 505 def getLicenseFile() @options[:license_file].to_s end |
#getMetrics ⇒ Object
118 119 120 |
# File 'lib/scoutui/utils/utils.rb', line 118 def getMetrics() @metrics end |
#getPageCoverage ⇒ Object
98 99 100 |
# File 'lib/scoutui/utils/utils.rb', line 98 def getPageCoverage() @coverage[:pages] end |
#getPageElement(s) ⇒ Object
163 164 165 166 167 168 169 170 171 |
# File 'lib/scoutui/utils/utils.rb', line 163 def getPageElement(s) rc=nil if !@app_model.nil? rc=@app_model.getPageElement(s) end rc end |
#getPassword ⇒ Object
653 654 655 |
# File 'lib/scoutui/utils/utils.rb', line 653 def getPassword() @options[:password] end |
#getReporter ⇒ Object
461 462 463 |
# File 'lib/scoutui/utils/utils.rb', line 461 def getReporter() @options[:report] end |
#getReq ⇒ Object
126 127 128 |
# File 'lib/scoutui/utils/utils.rb', line 126 def getReq() @currentTest[:reqid] end |
#getRole ⇒ Object
513 514 515 |
# File 'lib/scoutui/utils/utils.rb', line 513 def getRole() @options[:role] end |
#getSauceBuild ⇒ Object
529 530 531 |
# File 'lib/scoutui/utils/utils.rb', line 529 def getSauceBuild() @options[:sauce_build] || nil end |
#getSauceCaps ⇒ Object
521 522 523 |
# File 'lib/scoutui/utils/utils.rb', line 521 def getSauceCaps() @options[:sauce_capabilities] end |
#getSauceName ⇒ Object
525 526 527 |
# File 'lib/scoutui/utils/utils.rb', line 525 def getSauceName() @options[:sauce_name].to_s end |
#getSauceTunnel ⇒ Object
533 534 535 |
# File 'lib/scoutui/utils/utils.rb', line 533 def getSauceTunnel() @options[:sauce_tunnelid] end |
#getSeleniumServer ⇒ Object
537 538 539 |
# File 'lib/scoutui/utils/utils.rb', line 537 def getSeleniumServer() @options[:selenium_server] end |
#getState ⇒ Object
94 95 96 |
# File 'lib/scoutui/utils/utils.rb', line 94 def getState() @execution_status end |
#getTC ⇒ Object
130 131 132 |
# File 'lib/scoutui/utils/utils.rb', line 130 def getTC() @currentTest[:testcase] end |
#getTestConfig ⇒ Object
633 634 635 |
# File 'lib/scoutui/utils/utils.rb', line 633 def getTestConfig() @options[:test_config] end |
#getTestSettings ⇒ Object
Returns JSON file contents/format
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 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 |
# File 'lib/scoutui/utils/utils.rb', line 566 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
649 650 651 |
# File 'lib/scoutui/utils/utils.rb', line 649 def getUser() getUserId() end |
#getUserId ⇒ Object
645 646 647 |
# File 'lib/scoutui/utils/utils.rb', line 645 def getUserId() @options[:userid] end |
#getViewPort ⇒ Object
177 178 179 180 181 182 183 184 185 186 187 188 |
# File 'lib/scoutui/utils/utils.rb', line 177 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
557 558 559 |
# File 'lib/scoutui/utils/utils.rb', line 557 def hasTestConfig? !@options[:json_config_file].nil? end |
#host ⇒ Object
661 662 663 |
# File 'lib/scoutui/utils/utils.rb', line 661 def host() @options[:host] end |
#isDebug? ⇒ Boolean
473 474 475 |
# File 'lib/scoutui/utils/utils.rb', line 473 def isDebug? @options[:debug] end |
#isFailFast? ⇒ Boolean
106 107 108 |
# File 'lib/scoutui/utils/utils.rb', line 106 def isFailFast? @options[:fail_fast] end |
#loadModel(f = nil) ⇒ Object
142 143 144 145 146 147 148 149 150 151 152 153 154 155 |
# File 'lib/scoutui/utils/utils.rb', line 142 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
665 666 667 |
# File 'lib/scoutui/utils/utils.rb', line 665 def loc() @options[:loc] end |
#localization ⇒ Object
668 669 670 |
# File 'lib/scoutui/utils/utils.rb', line 668 def localization() loc() end |
#match_level ⇒ Object
637 638 639 |
# File 'lib/scoutui/utils/utils.rb', line 637 def match_level() @options[:match_level] end |
#parseCommandLine(args = nil) ⇒ Object
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 357 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 |
# File 'lib/scoutui/utils/utils.rb', line 191 def parseCommandLine(args=nil) opt_parser = OptionParser.new do |opt| opt.on('-c', '--config TESTFILE') { |o| if !o.nil? @options[:json_config_file]=o if File.exist?(@options[:json_config_file]) jFile = File.read(@options[:json_config_file]) @options[:test_config]=jsonData=JSON.parse(jFile) else Scoutui::Utils::TestUtils.instance.setState(:abort, "Unable to access test config file: #{@options[:json_config_file]}") raise "SCOUTUI::MissingFile::TestConfig : #{@options[:json_config_file]}" end end } opt.on('--accounts [Account]') { |o| @options[:accounts] = o } opt.on('-b', '--browser [TYPE]', [:chrome, :firefox, :edge, :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:tunnelid TunnelID') { |o| @options[:sauce_tunnelid] = o } opt.on('--sauce:resolution Resolution') { |o| @options[:sauce_resolution] = o } opt.on('--sauce:version Version') { |o| @options[:sauce_version] = o; Scoutui::Base::UserVars.instance.setVar('browser_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 # end.parse!(args) if !args.nil? opt_parser.parse!(args) else opt_parser.parse! end 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
517 518 519 |
# File 'lib/scoutui/utils/utils.rb', line 517 def retries() @options[:retries] end |
#sanitize_filename(filename) ⇒ Object
424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 |
# File 'lib/scoutui/utils/utils.rb', line 424 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
497 498 499 |
# File 'lib/scoutui/utils/utils.rb', line 497 def sauceEnabled? @options[:enable_sauce] end |
#saucePlatform ⇒ Object
501 502 503 |
# File 'lib/scoutui/utils/utils.rb', line 501 def saucePlatform() @options[:sauce_platform] end |
#sauceResolution ⇒ Object
509 510 511 |
# File 'lib/scoutui/utils/utils.rb', line 509 def sauceResolution() @options[:sauce_resolution] end |
#screenShots? ⇒ Boolean
440 441 442 |
# File 'lib/scoutui/utils/utils.rb', line 440 def screenShots? @options[:screenshots] end |
#screenShotsDir ⇒ Object
448 449 450 |
# File 'lib/scoutui/utils/utils.rb', line 448 def screenShotsDir @options[:screenshots_dir] end |
#screenShotsOnFailure? ⇒ Boolean
444 445 446 |
# File 'lib/scoutui/utils/utils.rb', line 444 def screenShotsOnFailure? @options[:screenshots_only_on_failure] end |
#setDebug(b) ⇒ Object
469 470 471 |
# File 'lib/scoutui/utils/utils.rb', line 469 def setDebug(b) @options[:debug]=b end |
#setFinalRc(b) ⇒ Object
114 115 116 |
# File 'lib/scoutui/utils/utils.rb', line 114 def setFinalRc(b) @final_rc=b end |
#setHost(_h) ⇒ Object
456 457 458 459 |
# File 'lib/scoutui/utils/utils.rb', line 456 def setHost(_h) @options[:host]=_h Scoutui::Base::UserVars.instance.set(:host, @options[:host].to_s) end |
#setMetrics(_m) ⇒ Object
122 123 124 |
# File 'lib/scoutui/utils/utils.rb', line 122 def setMetrics(_m) @metrics=_m end |
#setReporter(_r) ⇒ Object
465 466 467 |
# File 'lib/scoutui/utils/utils.rb', line 465 def setReporter(_r) @options[:report]=_r end |
#setReq(_r = 'UI') ⇒ Object
134 135 136 |
# File 'lib/scoutui/utils/utils.rb', line 134 def setReq(_r='UI') @currentTest[:reqid]=_r end |
#setState(s, _d = nil) ⇒ Object
71 72 73 74 75 76 77 78 79 80 |
# File 'lib/scoutui/utils/utils.rb', line 71 def setState(s, _d=nil) @execution_status=s @currentMessage=_d if !_d.nil? if @execution_status==:abort && !_d.nil? @failedFastMessage << _d.to_s Scoutui::Logger::LogMgr.instance.fatal "[ABORT]: #{_d}" end end |
#setTC(_tc = nil) ⇒ Object
138 139 140 |
# File 'lib/scoutui/utils/utils.rb', line 138 def setTC(_tc=nil) @currentTest[:testcase]=_tc end |
#testConfigFile ⇒ Object
561 562 563 |
# File 'lib/scoutui/utils/utils.rb', line 561 def testConfigFile() @options[:json_config_file] end |
#testFile ⇒ Object
657 658 659 |
# File 'lib/scoutui/utils/utils.rb', line 657 def testFile() @options[:test_file] end |
#title ⇒ Object
676 677 678 |
# File 'lib/scoutui/utils/utils.rb', line 676 def title() @options[:title] end |
#transpile(_val) ⇒ Object
681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 |
# File 'lib/scoutui/utils/utils.rb', line 681 def transpile(_val) _uservars = _val.scan(/\$\{(.*?)\}/) _v2 = _val for i in 0 .. (_uservars.size - 1) _t = Scoutui::Base::UserVars.instance.get(_uservars[i][0]) Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + " translate(#{_uservars[i][0]}) => #{_t}" if !_t.nil? && _uservars[i][0]!=_t _v2.gsub!("\$\{#{_uservars[i][0]}\}", _t) end Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + " value => #{_v2}" end ## Global replaces _text_to_type = Scoutui::Base::UserVars.instance.get(_v2) Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + " rawText : #{_text_to_type}" _text_to_type = Scoutui::Commands::Utils.instance.(_text_to_type) Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + " Text to type : #{_text_to_type}" _text_to_type end |