Module: PrependSystemTestingDriver

Defined in:
lib/cyperful/framework_injections.rb

Instance Method Summary collapse

Instance Method Details

#initializeObject



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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/cyperful/framework_injections.rb', line 41

def initialize(...)
  super(...)

  # SUPER NAIVE way to include the width/height of the sidebar/header
  # in the new screen size
  @screen_size = [@screen_size.fetch(0) + 300, @screen_size.fetch(1) + 60]

  prev_capabilities = @capabilities
  @capabilities =
    proc do |driver_opts|
      prev_capabilities&.call(driver_opts)

      next unless driver_opts.respond_to?(:add_argument)

      # this assumes Selenium and Chrome:

      # all chrome flags: https://peter.sh/experiments/chromium-command-line-switches
      # chrome flags for tooling: https://github.com/GoogleChrome/chrome-launcher/blob/main/docs/chrome-flags-for-tools.md

      # set the min flags to make cyperful functional:

      # so user isn't prompted when we start recording video w/ MediaStream
      driver_opts.add_argument("--auto-accept-this-tab-capture")
      driver_opts.add_argument("--use-fake-ui-for-media-stream")

      if driver_opts.args.none? { |arg| arg.include?("--disable-features=") }
        # credit: https://github.com/krausest/js-framework-benchmark/discussions/1682
        disabled_features = %w[
          InterestFeedContentSuggestions
          IPH_DemoMode
          BackForwardCache
          OptimizationHints
          OptimizationHintsFetching
          OptimizationTargetPrediction
          PrivacySandboxSettings4
          Translate
        ]
        driver_opts.add_argument(
          "--flag-switches-begin --disable-features=#{disabled_features.join(",")} --flag-switches-end",
        )
      end

      # make sure we're not in headless mode
      driver_opts.args.delete("--headless")
      driver_opts.args.delete("--headless=new")

      # hide the "Chrome is being controlled by automated test software" infobar
      driver_opts.args.delete("--enable-automation")
      driver_opts.exclude_switches << "enable-automation"
    end
end