sauce_bindings 1.2.1 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -4,12 +4,6 @@ require 'spec_helper'
4
4
 
5
5
  module SauceBindings
6
6
  describe Options do
7
- before do
8
- allow(ENV).to receive(:[]).with('BUILD_TAG').and_return('')
9
- allow(ENV).to receive(:[]).with('BUILD_NAME').and_return('TEMP BUILD')
10
- allow(ENV).to receive(:[]).with('BUILD_NUMBER').and_return('11')
11
- end
12
-
13
7
  describe '::chrome' do
14
8
  it 'uses latest Chrome version on Windows 10 by default' do
15
9
  options = Options.chrome
@@ -75,83 +69,66 @@ module SauceBindings
75
69
  end
76
70
 
77
71
  describe '::edge' do
78
- context 'with Selenium 3' do
79
- before do
80
- skip('test only applies with Selenium 3') unless Selenium::WebDriver::VERSION[0] == '3'
81
- end
72
+ it 'uses latest Edge version on Windows 10 by default' do
73
+ options = Options.edge
82
74
 
83
- it 'raises exception' do
84
- msg = /Selenium 3 is not compatible with the Chromium based Microsoft Edge/
85
- expect { Options.edge }.to raise_error(ArgumentError, msg)
86
- end
75
+ expect(options.browser_name).to eq 'MicrosoftEdge'
76
+ expect(options.browser_version).to eq 'latest'
77
+ expect(options.platform_name).to eq 'Windows 10'
87
78
  end
88
79
 
89
- context 'with Selenium 4' do
90
- before do
91
- skip('test only applies with Selenium 4') unless Selenium::WebDriver::VERSION[0] == '4'
92
- end
93
-
94
- it 'uses latest Edge version on Windows 10 by default' do
95
- options = Options.edge
96
-
97
- expect(options.browser_name).to eq 'MicrosoftEdge'
98
- expect(options.browser_version).to eq 'latest'
99
- expect(options.platform_name).to eq 'Windows 10'
100
- end
101
-
102
- it 'accepts correct Selenium Options class' do
103
- browser_opts = Selenium::WebDriver::Edge::Options.new(args: ['-foo'])
104
- options = Options.edge(selenium_options: browser_opts)
80
+ it 'accepts correct Selenium Options class' do
81
+ browser_opts = Selenium::WebDriver::Edge::Options.new(args: ['-foo'])
82
+ options = Options.edge(selenium_options: browser_opts)
105
83
 
106
- expect(options.selenium_options.dig('ms:edgeOptions', 'args')).to eq ['-foo']
107
- end
84
+ expect(options.selenium_options.dig('ms:edgeOptions', 'args')).to eq ['-foo']
85
+ end
108
86
 
109
- it 'does not accept incorrect Selenium Options class' do
110
- browser_opts = Selenium::WebDriver::Chrome::Options.new
87
+ it 'does not accept incorrect Selenium Options class' do
88
+ browser_opts = Selenium::WebDriver::Chrome::Options.new
111
89
 
112
- expect { Options.edge(selenium_options: browser_opts) }.to raise_exception(ArgumentError)
113
- end
90
+ expect { Options.edge(selenium_options: browser_opts) }.to raise_exception(ArgumentError)
91
+ end
114
92
 
115
- it 'accepts correct Selenium Capabilities class' do
116
- browser_opts = Selenium::WebDriver::Remote::Capabilities.edge(browser_version: '99')
117
- options = Options.edge(selenium_options: browser_opts)
93
+ it 'accepts correct Selenium Capabilities class' do
94
+ browser_opts = Selenium::WebDriver::Remote::Capabilities.edge(browser_version: '99')
95
+ options = Options.edge(selenium_options: browser_opts)
118
96
 
119
- expect(options.browser_version).to eq '99'
120
- end
97
+ expect(options.browser_version).to eq '99'
98
+ end
121
99
 
122
- it 'does not accept incorrect Selenium Capabilities class' do
123
- browser_opts = Selenium::WebDriver::Remote::Capabilities.chrome(browser_version: '99')
100
+ it 'does not accept incorrect Selenium Capabilities class' do
101
+ browser_opts = Selenium::WebDriver::Remote::Capabilities.chrome(browser_version: '99')
124
102
 
125
- expect { Options.edge(selenium_options: browser_opts) }.to raise_exception(ArgumentError)
126
- end
103
+ expect { Options.edge(selenium_options: browser_opts) }.to raise_exception(ArgumentError)
104
+ end
127
105
 
128
- it 'accepts base configurations' do
129
- options = Options.edge(custom_data: {foo: 'bar'})
130
- options.tags = %w[foo bar]
106
+ it 'accepts base configurations' do
107
+ options = Options.edge(custom_data: {foo: 'bar'})
108
+ options.tags = %w[foo bar]
131
109
 
132
- expect(options.custom_data).to eq(foo: 'bar')
133
- expect(options.tags).to eq %w[foo bar]
134
- end
110
+ expect(options.custom_data).to eq(foo: 'bar')
111
+ expect(options.tags).to eq %w[foo bar]
112
+ end
135
113
 
136
- it 'accepts vdc configurations' do
137
- options = Options.edge(browser_version: '42.0')
138
- options.page_load_strategy = 'eager'
114
+ it 'accepts vdc configurations' do
115
+ options = Options.edge(browser_version: '42.0')
116
+ options.page_load_strategy = 'eager'
139
117
 
140
- expect(options.browser_version).to eq '42.0'
141
- expect(options.page_load_strategy).to eq 'eager'
142
- end
118
+ expect(options.browser_version).to eq '42.0'
119
+ expect(options.page_load_strategy).to eq 'eager'
120
+ end
143
121
 
144
- it 'accepts valid configurations' do
145
- options = Options.edge(edgedriver_version: '99')
146
- options.selenium_version = '3.14'
122
+ it 'accepts valid configurations' do
123
+ options = Options.edge(edgedriver_version: '99')
124
+ options.selenium_version = '3.14'
147
125
 
148
- expect(options.selenium_version).to eq '3.14'
149
- expect(options.edgedriver_version).to eq '99'
150
- end
126
+ expect(options.selenium_version).to eq '3.14'
127
+ expect(options.edgedriver_version).to eq '99'
128
+ end
151
129
 
152
- it 'does not accept invalid configurations' do
153
- expect { Options.edge(chromedriver_version: 'anything') }.to raise_exception(ArgumentError)
154
- end
130
+ it 'does not accept invalid configurations' do
131
+ expect { Options.edge(chromedriver_version: 'anything') }.to raise_exception(ArgumentError)
155
132
  end
156
133
  end
157
134
 
@@ -502,31 +479,38 @@ module SauceBindings
502
479
  it 'correctly generates capabilities for w3c values' do
503
480
  proxy = Selenium::WebDriver::Proxy.new(ssl: 'foo')
504
481
 
505
- options = Options.firefox(platform_name: 'Mac',
506
- accept_insecure_certs: true,
507
- page_load_strategy: 'eager',
508
- proxy: proxy,
509
- set_window_rect: true,
510
- unhandled_prompt_behavior: 'accept',
511
- strict_file_interactability: true,
512
- implicit_wait_timeout: 1,
513
- page_load_timeout: 59,
514
- script_timeout: 29)
515
- proxy_type = Selenium::WebDriver::VERSION[0] == '3' ? 'MANUAL' : 'manual'
516
-
517
- expect(options.capabilities).to eq('browserName' => 'firefox',
518
- 'browserVersion' => 'latest',
519
- 'platformName' => 'Mac',
520
- 'acceptInsecureCerts' => true,
521
- 'pageLoadStrategy' => 'eager',
522
- 'proxy' => {'proxyType' => proxy_type, 'sslProxy' => 'foo'},
523
- 'setWindowRect' => true,
524
- 'unhandledPromptBehavior' => 'accept',
525
- 'strictFileInteractability' => true,
526
- 'timeouts' => {'implicit' => 1000,
527
- 'pageLoad' => 59_000,
528
- 'script' => 29_000},
529
- 'sauce:options' => {'build' => 'TEMP BUILD: 11'})
482
+ ClimateControl.modify BUILD_TAG: '', BUILD_NAME: 'TEMP BUILD', BUILD_NUMBER: '11' do
483
+ @options = Options.firefox(platform_name: 'Mac',
484
+ accept_insecure_certs: true,
485
+ page_load_strategy: 'eager',
486
+ proxy: proxy,
487
+ set_window_rect: true,
488
+ unhandled_prompt_behavior: 'accept',
489
+ strict_file_interactability: true,
490
+ implicit_wait_timeout: 1,
491
+ page_load_timeout: 59,
492
+ script_timeout: 29)
493
+ end
494
+
495
+ ClimateControl.modify(**SAUCE_ACCESS) do
496
+ @capabilities = @options.capabilities
497
+ end
498
+
499
+ expect(@capabilities).to eq('browserName' => 'firefox',
500
+ 'browserVersion' => 'latest',
501
+ 'platformName' => 'Mac',
502
+ 'acceptInsecureCerts' => true,
503
+ 'pageLoadStrategy' => 'eager',
504
+ 'proxy' => {'proxyType' => 'manual', 'sslProxy' => 'foo'},
505
+ 'setWindowRect' => true,
506
+ 'unhandledPromptBehavior' => 'accept',
507
+ 'strictFileInteractability' => true,
508
+ 'timeouts' => {'implicit' => 1000,
509
+ 'pageLoad' => 59_000,
510
+ 'script' => 29_000},
511
+ 'sauce:options' => {'build' => 'TEMP BUILD: 11',
512
+ 'username' => 'foo',
513
+ 'accessKey' => '123'})
530
514
  end
531
515
 
532
516
  it 'correctly generates capabilities for sauce values' do
@@ -566,81 +550,64 @@ module SauceBindings
566
550
  'background' => false,
567
551
  'timeout' => 120}
568
552
 
569
- expect(options.capabilities).to eq('browserName' => 'chrome',
570
- 'browserVersion' => 'latest',
571
- 'platformName' => 'Windows 10',
572
- 'sauce:options' => {'build' => 'Sample Build Name',
573
- 'capturePerformance' => true,
574
- 'chromedriverVersion' => '71',
575
- 'commandTimeout' => 2,
576
- 'customData' => {'foo' => 'foo',
577
- 'bar' => 'bar'},
578
- 'extendedDebugging' => true,
579
- 'idleTimeout' => 3,
580
- 'maxDuration' => 300,
581
- 'name' => 'Sample Test Name',
582
- 'parentTunnel' => 'Mommy',
583
- 'prerun' => prerun_caps,
584
- 'priority' => 0,
585
- 'public' => 'team',
586
- 'recordLogs' => false,
587
- 'recordScreenshots' => false,
588
- 'recordVideo' => false,
589
- 'screenResolution' => '10x10',
590
- 'tags' => %w[foo bar foobar],
591
- 'timeZone' => 'San Francisco',
592
- 'tunnelIdentifier' => 'tunnelname',
593
- 'videoUploadOnPass' => false})
594
- end
595
-
596
- it 'correctly generates capabilities for selenium object values Selenium 3' do
597
- skip unless Selenium::WebDriver::VERSION[0] == '3'
598
-
599
- caps = Selenium::WebDriver::Remote::Capabilities.chrome(accept_insecure_certs: true,
600
- page_load_strategy: 'eager')
601
- browser_opts = Selenium::WebDriver::Chrome::Options.new(args: ['--foo'])
602
- options = Options.chrome(selenium_options: [caps, browser_opts])
603
-
604
- jwp_defaults = {'cssSelectorsEnabled' => true,
605
- 'javascriptEnabled' => true,
606
- 'nativeEvents' => false,
607
- 'platform' => 'ANY',
608
- 'rotatable' => false,
609
- 'takesScreenshot' => false,
610
- 'version' => ''}
611
-
612
- expected_caps = {'browserName' => 'chrome',
613
- 'browserVersion' => 'latest',
614
- 'platformName' => 'Windows 10',
615
- 'acceptInsecureCerts' => true,
616
- 'pageLoadStrategy' => 'eager',
617
- 'sauce:options' => {'build' => 'TEMP BUILD: 11'},
618
- 'goog:chromeOptions' => {'args' => ['--foo']}}
619
-
620
- expect(options.capabilities).to eq(jwp_defaults.merge(expected_caps))
621
- end
622
-
623
- it 'correctly generates capabilities for selenium object values Selenium 4' do
624
- skip if Selenium::WebDriver::VERSION[0] == '3'
553
+ ClimateControl.modify(**SAUCE_ACCESS) do
554
+ @capabilities = options.capabilities
555
+ end
625
556
 
557
+ expect(@capabilities).to eq('browserName' => 'chrome',
558
+ 'browserVersion' => 'latest',
559
+ 'platformName' => 'Windows 10',
560
+ 'sauce:options' => {'build' => 'Sample Build Name',
561
+ 'capturePerformance' => true,
562
+ 'chromedriverVersion' => '71',
563
+ 'commandTimeout' => 2,
564
+ 'customData' => {'foo' => 'foo',
565
+ 'bar' => 'bar'},
566
+ 'extendedDebugging' => true,
567
+ 'idleTimeout' => 3,
568
+ 'maxDuration' => 300,
569
+ 'name' => 'Sample Test Name',
570
+ 'parentTunnel' => 'Mommy',
571
+ 'prerun' => prerun_caps,
572
+ 'priority' => 0,
573
+ 'public' => 'team',
574
+ 'recordLogs' => false,
575
+ 'recordScreenshots' => false,
576
+ 'recordVideo' => false,
577
+ 'screenResolution' => '10x10',
578
+ 'tags' => %w[foo bar foobar],
579
+ 'timeZone' => 'San Francisco',
580
+ 'tunnelIdentifier' => 'tunnelname',
581
+ 'videoUploadOnPass' => false,
582
+ 'username' => 'foo',
583
+ 'accessKey' => '123'})
584
+ end
585
+
586
+ it 'correctly generates capabilities for selenium object values' do
626
587
  caps = Selenium::WebDriver::Remote::Capabilities.chrome(accept_insecure_certs: true)
627
588
  browser_opts = Selenium::WebDriver::Chrome::Options.new(args: ['--foo'],
628
589
  page_load_strategy: 'eager')
629
- options = Options.chrome(selenium_options: [caps, browser_opts])
630
590
 
631
- expect(options.accept_insecure_certs).to eq true
632
- expect(options.page_load_strategy).to eq 'eager'
633
- expect(options.selenium_options.dig('goog:chromeOptions', 'args')).to eq ['--foo']
591
+ ClimateControl.modify BUILD_TAG: '', BUILD_NAME: 'TEMP BUILD', BUILD_NUMBER: '11' do
592
+ @options = Options.chrome(selenium_options: [caps, browser_opts])
593
+ end
594
+ expect(@options.accept_insecure_certs).to eq true
595
+ expect(@options.page_load_strategy).to eq 'eager'
596
+ expect(@options.selenium_options.dig('goog:chromeOptions', 'args')).to eq ['--foo']
634
597
 
635
598
  expected_caps = {'browserName' => 'chrome',
636
599
  'browserVersion' => 'latest',
637
600
  'platformName' => 'Windows 10',
638
601
  'acceptInsecureCerts' => true,
639
602
  'pageLoadStrategy' => 'eager',
640
- 'sauce:options' => {'build' => 'TEMP BUILD: 11'},
603
+ 'sauce:options' => {'build' => 'TEMP BUILD: 11',
604
+ 'username' => 'foo',
605
+ 'accessKey' => '123'},
641
606
  'goog:chromeOptions' => {'args' => ['--foo']}}
642
607
 
643
- expect(options.capabilities).to eq expected_caps
608
+ ClimateControl.modify(**SAUCE_ACCESS) do
609
+ expect(@options.capabilities).to eq expected_caps
610
+ end
644
611
  end
645
612
  end
646
613
  end