testcentricity_web 4.1.2.1 → 4.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +26 -2
- data/Gemfile.lock +1 -1
- data/README.md +471 -250
- data/lib/testcentricity_web/appium_server.rb +2 -2
- data/lib/testcentricity_web/version.rb +1 -1
- data/lib/testcentricity_web/web_core/webdriver_helper.rb +78 -120
- data/lib/testcentricity_web/web_elements/select_list.rb +10 -7
- metadata +2 -2
| @@ -26,7 +26,7 @@ module TestCentricity | |
| 26 26 | 
             
                    puts 'Appium Server is starting'
         | 
| 27 27 | 
             
                  end
         | 
| 28 28 | 
             
                  # start new Appium Server
         | 
| 29 | 
            -
                  @process = ChildProcess.build
         | 
| 29 | 
            +
                  @process = ChildProcess.build(*parameters)
         | 
| 30 30 | 
             
                  process.start
         | 
| 31 31 | 
             
                  # wait until confirmation that Appium Server is running
         | 
| 32 32 | 
             
                  wait = Selenium::WebDriver::Wait.new(timeout: 30)
         | 
| @@ -40,7 +40,7 @@ module TestCentricity | |
| 40 40 | 
             
                def running?
         | 
| 41 41 | 
             
                  response = nil
         | 
| 42 42 | 
             
                  begin
         | 
| 43 | 
            -
                    response = Net::HTTP.get_response(URI('http:// | 
| 43 | 
            +
                    response = Net::HTTP.get_response(URI('http://0.0.0.0:4723/wd/hub/sessions'))
         | 
| 44 44 | 
             
                  rescue
         | 
| 45 45 | 
             
                  end
         | 
| 46 46 | 
             
                  response && response.code_type == Net::HTTPOK
         | 
| @@ -49,7 +49,7 @@ module TestCentricity | |
| 49 49 | 
             
                  context = case browser.downcase.to_sym
         | 
| 50 50 | 
             
                            when :appium
         | 
| 51 51 | 
             
                              initialize_appium
         | 
| 52 | 
            -
                              ' | 
| 52 | 
            +
                              'Appium'
         | 
| 53 53 | 
             
                            when :browserstack
         | 
| 54 54 | 
             
                              initialize_browserstack
         | 
| 55 55 | 
             
                              'Browserstack cloud service'
         | 
| @@ -137,7 +137,7 @@ module TestCentricity | |
| 137 137 | 
             
                  Environ.device_os_version = ENV['APP_VERSION']
         | 
| 138 138 | 
             
                  Environ.device_orientation = ENV['ORIENTATION'] if ENV['ORIENTATION']
         | 
| 139 139 | 
             
                  Capybara.default_driver = :appium
         | 
| 140 | 
            -
                   | 
| 140 | 
            +
                  Environ.driver = :appium
         | 
| 141 141 | 
             
                  desired_capabilities = {
         | 
| 142 142 | 
             
                      platformName:    Environ.device_os,
         | 
| 143 143 | 
             
                      platformVersion: Environ.device_os_version,
         | 
| @@ -189,14 +189,13 @@ module TestCentricity | |
| 189 189 | 
             
                    desired_capabilities[:systemPort]   = ENV['SYSTEM_PORT'] if ENV['SYSTEM_PORT']
         | 
| 190 190 | 
             
                  end
         | 
| 191 191 |  | 
| 192 | 
            -
                  unless @capabilities.nil?
         | 
| 193 | 
            -
             | 
| 194 | 
            -
                   | 
| 192 | 
            +
                  desired_capabilities = @capabilities unless @capabilities.nil?
         | 
| 193 | 
            +
                  # specify endpoint url
         | 
| 194 | 
            +
                  @endpoint = 'http://localhost:4723/wd/hub' if @endpoint.nil?
         | 
| 195 195 |  | 
| 196 | 
            -
                  Capybara.register_driver | 
| 197 | 
            -
                    appium_lib_options = { server_url: @endpoint }
         | 
| 196 | 
            +
                  Capybara.register_driver(:appium) do |app|
         | 
| 198 197 | 
             
                    all_options = {
         | 
| 199 | 
            -
                      appium_lib:  | 
| 198 | 
            +
                      appium_lib: { server_url: @endpoint },
         | 
| 200 199 | 
             
                      caps:       desired_capabilities
         | 
| 201 200 | 
             
                    }
         | 
| 202 201 | 
             
                    Appium::Capybara::Driver.new(app, all_options)
         | 
| @@ -232,63 +231,18 @@ module TestCentricity | |
| 232 231 | 
             
                    when :safari, :ie
         | 
| 233 232 | 
             
                      Capybara::Selenium::Driver.new(app, browser: browser)
         | 
| 234 233 | 
             
                    when :firefox, :firefox_headless
         | 
| 235 | 
            -
                       | 
| 236 | 
            -
                      profile['browser.download.dir'] = @downloads_path
         | 
| 237 | 
            -
                      profile['browser.download.folderList'] = 2
         | 
| 238 | 
            -
                      profile['browser.download.manager.showWhenStarting'] = false
         | 
| 239 | 
            -
                      profile['browser.download.manager.closeWhenDone'] = true
         | 
| 240 | 
            -
                      profile['browser.download.manager.showAlertOnComplete'] = false
         | 
| 241 | 
            -
                      profile['browser.download.manager.alertOnEXEOpen'] = false
         | 
| 242 | 
            -
                      profile['browser.download.manager.useWindow'] = false
         | 
| 243 | 
            -
                      profile['browser.helperApps.alwaysAsk.force'] = false
         | 
| 244 | 
            -
                      profile['pdfjs.disabled'] = true
         | 
| 245 | 
            -
             | 
| 246 | 
            -
                      mime_types = ENV['MIME_TYPES'] || 'images/jpeg, application/pdf, application/octet-stream'
         | 
| 247 | 
            -
                      profile['browser.helperApps.neverAsk.saveToDisk'] = mime_types
         | 
| 248 | 
            -
             | 
| 249 | 
            -
                      profile['intl.accept_languages'] = ENV['LOCALE'] if ENV['LOCALE']
         | 
| 250 | 
            -
                      options = Selenium::WebDriver::Firefox::Options.new(profile: profile)
         | 
| 251 | 
            -
                      options.args << '--headless' if browser == :firefox_headless
         | 
| 234 | 
            +
                      options = firefox_options(browser)
         | 
| 252 235 | 
             
                      Capybara::Selenium::Driver.new(app, browser: :firefox, capabilities: [options])
         | 
| 253 236 | 
             
                    when :chrome, :chrome_headless
         | 
| 254 | 
            -
                      options =  | 
| 255 | 
            -
                      prefs = {
         | 
| 256 | 
            -
                        prompt_for_download: false,
         | 
| 257 | 
            -
                        directory_upgrade:   true,
         | 
| 258 | 
            -
                        default_directory:   @downloads_path
         | 
| 259 | 
            -
                      }
         | 
| 260 | 
            -
                      options.add_preference(:download, prefs)
         | 
| 261 | 
            -
                      options.add_argument('--disable-dev-shm-usage')
         | 
| 262 | 
            -
                      options.add_argument("--lang=#{ENV['LOCALE']}") if ENV['LOCALE']
         | 
| 263 | 
            -
                      if browser == :chrome_headless
         | 
| 264 | 
            -
                        options.add_argument('--headless')
         | 
| 265 | 
            -
                        options.add_argument('--disable-gpu')
         | 
| 266 | 
            -
                        options.add_argument('--no-sandbox')
         | 
| 267 | 
            -
                      end
         | 
| 268 | 
            -
             | 
| 237 | 
            +
                      options = chrome_edge_options(browser)
         | 
| 269 238 | 
             
                      Capybara::Selenium::Driver.new(app, browser: :chrome, capabilities: [options])
         | 
| 270 239 | 
             
                    when :edge, :edge_headless
         | 
| 271 | 
            -
                      options =  | 
| 272 | 
            -
                      prefs = {
         | 
| 273 | 
            -
                        prompt_for_download: false,
         | 
| 274 | 
            -
                        directory_upgrade:   true,
         | 
| 275 | 
            -
                        default_directory:   @downloads_path
         | 
| 276 | 
            -
                      }
         | 
| 277 | 
            -
                      options.add_preference(:download, prefs)
         | 
| 278 | 
            -
                      options.add_argument('--disable-dev-shm-usage')
         | 
| 279 | 
            -
                      options.add_argument("--lang=#{ENV['LOCALE']}") if ENV['LOCALE']
         | 
| 280 | 
            -
                      if browser == :edge_headless
         | 
| 281 | 
            -
                        options.add_argument('--headless')
         | 
| 282 | 
            -
                        options.add_argument('--disable-gpu')
         | 
| 283 | 
            -
                        options.add_argument('--no-sandbox')
         | 
| 284 | 
            -
                      end
         | 
| 285 | 
            -
             | 
| 240 | 
            +
                      options = chrome_edge_options(browser)
         | 
| 286 241 | 
             
                      Capybara::Selenium::Driver.new(app, browser: :edge, capabilities: [options])
         | 
| 287 242 | 
             
                    else
         | 
| 288 243 | 
             
                      if ENV['HOST_BROWSER'] && ENV['HOST_BROWSER'].downcase.to_sym == :chrome
         | 
| 289 244 | 
             
                        user_agent = Browsers.mobile_device_agent(ENV['WEB_BROWSER'])
         | 
| 290 245 | 
             
                        options = Selenium::WebDriver::Chrome::Options.new(options: {'excludeSwitches' => ['enable-automation']})
         | 
| 291 | 
            -
                        options.add_argument('--disable-infobars')
         | 
| 292 246 | 
             
                        options.add_argument('--disable-dev-shm-usage')
         | 
| 293 247 | 
             
                        options.add_argument("--user-agent='#{user_agent}'")
         | 
| 294 248 | 
             
                        options.add_argument("--lang=#{ENV['LOCALE']}") if ENV['LOCALE']
         | 
| @@ -451,74 +405,31 @@ module TestCentricity | |
| 451 405 | 
             
                  Environ.grid = :selenium_grid
         | 
| 452 406 | 
             
                  browser  = ENV['WEB_BROWSER'].downcase.to_sym
         | 
| 453 407 | 
             
                  @endpoint = ENV['REMOTE_ENDPOINT'] || 'http://127.0.0.1:4444/wd/hub' if @endpoint.nil?
         | 
| 454 | 
            -
             | 
| 455 | 
            -
             | 
| 456 | 
            -
             | 
| 457 | 
            -
             | 
| 458 | 
            -
             | 
| 459 | 
            -
             | 
| 460 | 
            -
             | 
| 461 | 
            -
             | 
| 462 | 
            -
             | 
| 463 | 
            -
             | 
| 464 | 
            -
             | 
| 465 | 
            -
             | 
| 466 | 
            -
                       | 
| 467 | 
            -
                       | 
| 468 | 
            -
                       | 
| 469 | 
            -
                      profile['browser.helperApps.alwaysAsk.force'] = false
         | 
| 470 | 
            -
                      profile['pdfjs.disabled'] = true
         | 
| 471 | 
            -
             | 
| 472 | 
            -
                      mime_types = ENV['MIME_TYPES'] || 'images/jpeg, application/pdf, application/octet-stream'
         | 
| 473 | 
            -
                      profile['browser.helperApps.neverAsk.saveToDisk'] = mime_types
         | 
| 474 | 
            -
             | 
| 475 | 
            -
                      profile['intl.accept_languages'] = ENV['LOCALE'] if ENV['LOCALE']
         | 
| 476 | 
            -
                      options = Selenium::WebDriver::Firefox::Options.new(profile: profile)
         | 
| 477 | 
            -
                      options.args << '--headless' if browser == :firefox_headless
         | 
| 478 | 
            -
                    when :chrome, :chrome_headless
         | 
| 408 | 
            +
             | 
| 409 | 
            +
                  case browser
         | 
| 410 | 
            +
                  when :safari
         | 
| 411 | 
            +
                    options = Selenium::WebDriver::Safari::Options.new
         | 
| 412 | 
            +
                  when :ie
         | 
| 413 | 
            +
                    options = Selenium::WebDriver::IE::Options.new
         | 
| 414 | 
            +
                  when :firefox, :firefox_headless
         | 
| 415 | 
            +
                    options = firefox_options(browser)
         | 
| 416 | 
            +
                  when :chrome, :chrome_headless, :edge, :edge_headless
         | 
| 417 | 
            +
                    options = chrome_edge_options(browser)
         | 
| 418 | 
            +
                  else
         | 
| 419 | 
            +
                    if ENV['HOST_BROWSER'] && ENV['HOST_BROWSER'].downcase.to_sym == :chrome
         | 
| 420 | 
            +
                      Environ.platform = :mobile
         | 
| 421 | 
            +
                      Environ.device_name = Browsers.mobile_device_name(ENV['WEB_BROWSER'])
         | 
| 422 | 
            +
                      user_agent = Browsers.mobile_device_agent(ENV['WEB_BROWSER'])
         | 
| 479 423 | 
             
                      options = Selenium::WebDriver::Chrome::Options.new(options: {'excludeSwitches' => ['enable-automation']})
         | 
| 480 | 
            -
                      prefs = {
         | 
| 481 | 
            -
                        prompt_for_download: false,
         | 
| 482 | 
            -
                        directory_upgrade:   true,
         | 
| 483 | 
            -
                        default_directory:   @downloads_path
         | 
| 484 | 
            -
                      }
         | 
| 485 | 
            -
                      options.add_preference(:download, prefs)
         | 
| 486 | 
            -
                      options.add_argument('--disable-dev-shm-usage')
         | 
| 487 | 
            -
                      options.add_argument("--lang=#{ENV['LOCALE']}") if ENV['LOCALE']
         | 
| 488 | 
            -
                      if browser == :chrome_headless
         | 
| 489 | 
            -
                        options.add_argument('--headless')
         | 
| 490 | 
            -
                        options.add_argument('--disable-gpu')
         | 
| 491 | 
            -
                        options.add_argument('--no-sandbox')
         | 
| 492 | 
            -
                      end
         | 
| 493 | 
            -
                    when :edge, :edge_headless
         | 
| 494 | 
            -
                      options = Selenium::WebDriver::Edge::Options.new(options: {'excludeSwitches' => ['enable-automation']})
         | 
| 495 | 
            -
                      prefs = {
         | 
| 496 | 
            -
                        prompt_for_download: false,
         | 
| 497 | 
            -
                        directory_upgrade:   true,
         | 
| 498 | 
            -
                        default_directory:   @downloads_path
         | 
| 499 | 
            -
                      }
         | 
| 500 | 
            -
                      options.add_preference(:download, prefs)
         | 
| 501 424 | 
             
                      options.add_argument('--disable-dev-shm-usage')
         | 
| 425 | 
            +
                      options.add_argument("--user-agent='#{user_agent}'")
         | 
| 502 426 | 
             
                      options.add_argument("--lang=#{ENV['LOCALE']}") if ENV['LOCALE']
         | 
| 503 | 
            -
                      if browser == :edge_headless
         | 
| 504 | 
            -
                        options.add_argument('--headless')
         | 
| 505 | 
            -
                        options.add_argument('--disable-gpu')
         | 
| 506 | 
            -
                        options.add_argument('--no-sandbox')
         | 
| 507 | 
            -
                      end
         | 
| 508 427 | 
             
                    else
         | 
| 509 | 
            -
                       | 
| 510 | 
            -
                        Environ.platform = :mobile
         | 
| 511 | 
            -
                        Environ.device_name = Browsers.mobile_device_name(ENV['WEB_BROWSER'])
         | 
| 512 | 
            -
                        user_agent = Browsers.mobile_device_agent(ENV['WEB_BROWSER'])
         | 
| 513 | 
            -
                        options = Selenium::WebDriver::Chrome::Options.new(options: {'excludeSwitches' => ['enable-automation']})
         | 
| 514 | 
            -
                        options.add_argument('--disable-infobars')
         | 
| 515 | 
            -
                        options.add_argument('--disable-dev-shm-usage')
         | 
| 516 | 
            -
                        options.add_argument("--user-agent='#{user_agent}'")
         | 
| 517 | 
            -
                        options.add_argument("--lang=#{ENV['LOCALE']}") if ENV['LOCALE']
         | 
| 518 | 
            -
                      else
         | 
| 519 | 
            -
                        raise "Requested browser '#{browser}' is not supported on Selenium Grid"
         | 
| 520 | 
            -
                      end
         | 
| 428 | 
            +
                      raise "Requested browser '#{browser}' is not supported on Selenium Grid"
         | 
| 521 429 | 
             
                    end
         | 
| 430 | 
            +
                  end
         | 
| 431 | 
            +
             | 
| 432 | 
            +
                  Capybara.register_driver :remote_browser do |app|
         | 
| 522 433 | 
             
                    Capybara::Selenium::Driver.new(app,
         | 
| 523 434 | 
             
                                                   browser: :remote,
         | 
| 524 435 | 
             
                                                   url: @endpoint,
         | 
| @@ -644,6 +555,50 @@ module TestCentricity | |
| 644 555 | 
             
                  config_file_uploads unless ENV['TB_PLATFORM']
         | 
| 645 556 | 
             
                end
         | 
| 646 557 |  | 
| 558 | 
            +
                def self.chrome_edge_options(browser)
         | 
| 559 | 
            +
                  options = case browser
         | 
| 560 | 
            +
                            when :chrome, :chrome_headless
         | 
| 561 | 
            +
                              Selenium::WebDriver::Chrome::Options.new(options: {'excludeSwitches' => ['enable-automation']})
         | 
| 562 | 
            +
                            when :edge, :edge_headless
         | 
| 563 | 
            +
                              Selenium::WebDriver::Edge::Options.new(options: {'excludeSwitches' => ['enable-automation']})
         | 
| 564 | 
            +
                            end
         | 
| 565 | 
            +
                  prefs = {
         | 
| 566 | 
            +
                    prompt_for_download: false,
         | 
| 567 | 
            +
                    directory_upgrade:   true,
         | 
| 568 | 
            +
                    default_directory:   @downloads_path
         | 
| 569 | 
            +
                  }
         | 
| 570 | 
            +
                  options.add_preference(:download, prefs)
         | 
| 571 | 
            +
                  options.add_argument('--disable-dev-shm-usage')
         | 
| 572 | 
            +
                  options.add_argument("--lang=#{ENV['LOCALE']}") if ENV['LOCALE']
         | 
| 573 | 
            +
                  if browser == :chrome_headless || browser == :edge_headless
         | 
| 574 | 
            +
                    options.add_argument('--headless')
         | 
| 575 | 
            +
                    options.add_argument('--disable-gpu')
         | 
| 576 | 
            +
                    options.add_argument('--no-sandbox')
         | 
| 577 | 
            +
                  end
         | 
| 578 | 
            +
                  options
         | 
| 579 | 
            +
                end
         | 
| 580 | 
            +
             | 
| 581 | 
            +
                def self.firefox_options(browser)
         | 
| 582 | 
            +
                  profile = Selenium::WebDriver::Firefox::Profile.new
         | 
| 583 | 
            +
                  profile['browser.download.dir'] = @downloads_path
         | 
| 584 | 
            +
                  profile['browser.download.folderList'] = 2
         | 
| 585 | 
            +
                  profile['browser.download.manager.showWhenStarting'] = false
         | 
| 586 | 
            +
                  profile['browser.download.manager.closeWhenDone'] = true
         | 
| 587 | 
            +
                  profile['browser.download.manager.showAlertOnComplete'] = false
         | 
| 588 | 
            +
                  profile['browser.download.manager.alertOnEXEOpen'] = false
         | 
| 589 | 
            +
                  profile['browser.download.manager.useWindow'] = false
         | 
| 590 | 
            +
                  profile['browser.helperApps.alwaysAsk.force'] = false
         | 
| 591 | 
            +
                  profile['pdfjs.disabled'] = true
         | 
| 592 | 
            +
             | 
| 593 | 
            +
                  mime_types = ENV['MIME_TYPES'] || 'images/jpeg, application/pdf, application/octet-stream'
         | 
| 594 | 
            +
                  profile['browser.helperApps.neverAsk.saveToDisk'] = mime_types
         | 
| 595 | 
            +
             | 
| 596 | 
            +
                  profile['intl.accept_languages'] = ENV['LOCALE'] if ENV['LOCALE']
         | 
| 597 | 
            +
                  options = Selenium::WebDriver::Firefox::Options.new(profile: profile)
         | 
| 598 | 
            +
                  options.args << '--headless' if browser == :firefox_headless
         | 
| 599 | 
            +
                  options
         | 
| 600 | 
            +
                end
         | 
| 601 | 
            +
             | 
| 647 602 | 
             
                def self.test_context_message
         | 
| 648 603 | 
             
                  context_message = if ENV['TEST_CONTEXT']
         | 
| 649 604 | 
             
                                      "#{Environ.test_environment.to_s.upcase} - #{ENV['TEST_CONTEXT']}"
         | 
| @@ -661,7 +616,10 @@ module TestCentricity | |
| 661 616 | 
             
                def self.register_remote_driver(driver, browser, options)
         | 
| 662 617 | 
             
                  Capybara.register_driver driver do |app|
         | 
| 663 618 | 
             
                    capabilities = Selenium::WebDriver::Remote::Capabilities.send(browser.gsub(/\s+/, '_').downcase.to_sym, options)
         | 
| 664 | 
            -
                    Capybara::Selenium::Driver.new(app, | 
| 619 | 
            +
                    Capybara::Selenium::Driver.new(app,
         | 
| 620 | 
            +
                                                   browser: :remote,
         | 
| 621 | 
            +
                                                   url: @endpoint,
         | 
| 622 | 
            +
                                                   capabilities: capabilities)
         | 
| 665 623 | 
             
                  end
         | 
| 666 624 |  | 
| 667 625 | 
             
                  Environ.browser = browser
         | 
| @@ -246,13 +246,16 @@ module TestCentricity | |
| 246 246 | 
             
                def get_selected_option
         | 
| 247 247 | 
             
                  @base_object, = find_element
         | 
| 248 248 | 
             
                  object_not_found_exception(@base_object, nil)
         | 
| 249 | 
            -
                   | 
| 250 | 
            -
             | 
| 251 | 
            -
             | 
| 252 | 
            -
             | 
| 253 | 
            -
             | 
| 254 | 
            -
             | 
| 255 | 
            -
             | 
| 249 | 
            +
                  trigger_list
         | 
| 250 | 
            +
                  selection = if @base_object.first(:css, @list_item, minimum: 0, wait: 1, visible: :all)
         | 
| 251 | 
            +
                                @base_object.first(:css, @selected_item, wait: 1, visible: :all).text
         | 
| 252 | 
            +
                              elsif @base_object.first(:css, @selected_item, minimum: 0, wait: 1, visible: :all)
         | 
| 253 | 
            +
                                @base_object.first(:css, @selected_item, visible: :all).text
         | 
| 254 | 
            +
                              else
         | 
| 255 | 
            +
                                @base_object.first('option[selected]', visible: :all).text
         | 
| 256 | 
            +
                              end
         | 
| 257 | 
            +
                  trigger_list
         | 
| 258 | 
            +
                  selection
         | 
| 256 259 | 
             
                end
         | 
| 257 260 |  | 
| 258 261 | 
             
                alias selected? get_selected_option
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: testcentricity_web
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 4.1. | 
| 4 | 
            +
              version: 4.1.5
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - A.J. Mrozinski
         | 
| 8 8 | 
             
            autorequire:
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2022-03- | 
| 11 | 
            +
            date: 2022-03-15 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: bundler
         |