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.
- checksums.yaml +4 -4
- data/.rubocop.yml +12 -6
- data/CHANGES.md +12 -0
- data/LICENSE.txt +1 -1
- data/README.md +11 -87
- data/Rakefile +8 -6
- data/lib/sauce_bindings/capybara_session.rb +0 -3
- data/lib/sauce_bindings/errors.rb +7 -0
- data/lib/sauce_bindings/logger.rb +20 -0
- data/lib/sauce_bindings/options.rb +22 -4
- data/lib/sauce_bindings/session.rb +92 -18
- data/lib/sauce_bindings/version.rb +1 -1
- data/lib/sauce_bindings.rb +8 -0
- data/sauce_bindings.gemspec +6 -6
- data/spec/integration/desktop_spec.rb +25 -5
- data/spec/spec_helper.rb +39 -1
- data/spec/unit/capybara_session_spec.rb +10 -20
- data/spec/unit/deprecated_options_spec.rb +479 -456
- data/spec/unit/options_spec.rb +120 -153
- data/spec/unit/session_spec.rb +437 -84
- metadata +30 -28
data/spec/unit/options_spec.rb
CHANGED
@@ -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
|
-
|
79
|
-
|
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
|
-
|
84
|
-
|
85
|
-
|
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
|
-
|
90
|
-
|
91
|
-
|
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
|
-
|
107
|
-
|
84
|
+
expect(options.selenium_options.dig('ms:edgeOptions', 'args')).to eq ['-foo']
|
85
|
+
end
|
108
86
|
|
109
|
-
|
110
|
-
|
87
|
+
it 'does not accept incorrect Selenium Options class' do
|
88
|
+
browser_opts = Selenium::WebDriver::Chrome::Options.new
|
111
89
|
|
112
|
-
|
113
|
-
|
90
|
+
expect { Options.edge(selenium_options: browser_opts) }.to raise_exception(ArgumentError)
|
91
|
+
end
|
114
92
|
|
115
|
-
|
116
|
-
|
117
|
-
|
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
|
-
|
120
|
-
|
97
|
+
expect(options.browser_version).to eq '99'
|
98
|
+
end
|
121
99
|
|
122
|
-
|
123
|
-
|
100
|
+
it 'does not accept incorrect Selenium Capabilities class' do
|
101
|
+
browser_opts = Selenium::WebDriver::Remote::Capabilities.chrome(browser_version: '99')
|
124
102
|
|
125
|
-
|
126
|
-
|
103
|
+
expect { Options.edge(selenium_options: browser_opts) }.to raise_exception(ArgumentError)
|
104
|
+
end
|
127
105
|
|
128
|
-
|
129
|
-
|
130
|
-
|
106
|
+
it 'accepts base configurations' do
|
107
|
+
options = Options.edge(custom_data: {foo: 'bar'})
|
108
|
+
options.tags = %w[foo bar]
|
131
109
|
|
132
|
-
|
133
|
-
|
134
|
-
|
110
|
+
expect(options.custom_data).to eq(foo: 'bar')
|
111
|
+
expect(options.tags).to eq %w[foo bar]
|
112
|
+
end
|
135
113
|
|
136
|
-
|
137
|
-
|
138
|
-
|
114
|
+
it 'accepts vdc configurations' do
|
115
|
+
options = Options.edge(browser_version: '42.0')
|
116
|
+
options.page_load_strategy = 'eager'
|
139
117
|
|
140
|
-
|
141
|
-
|
142
|
-
|
118
|
+
expect(options.browser_version).to eq '42.0'
|
119
|
+
expect(options.page_load_strategy).to eq 'eager'
|
120
|
+
end
|
143
121
|
|
144
|
-
|
145
|
-
|
146
|
-
|
122
|
+
it 'accepts valid configurations' do
|
123
|
+
options = Options.edge(edgedriver_version: '99')
|
124
|
+
options.selenium_version = '3.14'
|
147
125
|
|
148
|
-
|
149
|
-
|
150
|
-
|
126
|
+
expect(options.selenium_version).to eq '3.14'
|
127
|
+
expect(options.edgedriver_version).to eq '99'
|
128
|
+
end
|
151
129
|
|
152
|
-
|
153
|
-
|
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
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
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
|
-
|
570
|
-
|
571
|
-
|
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
|
-
|
632
|
-
|
633
|
-
|
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
|
-
|
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
|