testnow 0.0.9 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/lib/testnow/edge.rb CHANGED
@@ -1,34 +1,35 @@
1
- class MicrosoftEdge
2
-
3
- @private
4
- def edge_config
5
- @client = Selenium::WebDriver::Remote::Http::Default.new
6
- @client.timeout = 120
7
- @caps = Selenium::WebDriver::Remote::Capabilities.edge(:native_events => false,
8
- :acceptSslCerts => true)
9
-
10
- end
11
-
12
- @private
13
- def post_edge_config(driver)
14
- driver.manage.timeouts.implicit_wait = 30
15
- driver.manage.timeouts.page_load = 120
16
- end
17
-
18
- def launch_driver_edge
19
- self.edge_config
20
- driver = Selenium::WebDriver.for(:edge,
21
- :desired_capabilities => @caps,
22
- :http_client => @client)
23
- return driver
24
- end
25
-
26
- def launch_watir_edge
27
- self.edge_config
28
- browser = Watir::Browser.new(:edge,
29
- :desired_capabilities => @caps,
30
- :http_client => @client)
31
- self.post_edge_config(browser.driver)
32
- return browser
33
- end
1
+ class MicrosoftEdge
2
+
3
+ @private
4
+ def pre_config
5
+ @client = Selenium::WebDriver::Remote::Http::Default.new
6
+ @client.timeout = 120
7
+ @caps = Selenium::WebDriver::Remote::Capabilities.edge(:native_events => false,
8
+ :acceptSslCerts => true)
9
+
10
+ end
11
+
12
+ @private
13
+ def post_config(driver)
14
+ driver.manage.timeouts.implicit_wait = 30
15
+ driver.manage.timeouts.page_load = 120
16
+ end
17
+
18
+ def launch_driver_edge
19
+ self.pre_config
20
+ driver = Selenium::WebDriver.for(:edge,
21
+ :desired_capabilities => @caps,
22
+ :http_client => @client)
23
+ self.post_config(driver)
24
+ return driver
25
+ end
26
+
27
+ def launch_watir_edge
28
+ self.edge_config
29
+ browser = Watir::Browser.new(:edge,
30
+ :desired_capabilities => @caps,
31
+ :http_client => @client)
32
+ self.post_edge_config(browser.driver)
33
+ return browser
34
+ end
34
35
  end
@@ -1,53 +1,55 @@
1
- # module TestNow
2
- class Firefox
3
-
4
- #Firefox browser
5
- def launch_driver_firefox
6
- ENV['IS_UPA'] = "false" if ENV['IS_UPA'].nil?
7
- if ENV['IS_UPA']=="true"
8
- ENV['HAR_DIR'] = get_tmp_dir if ENV['HAR_DIR'].nil?
9
- puts "=>=>=> Your HAR (UPA) files will be created here : #{ENV['HAR_DIR']}"
10
- firebug = File.absolute_path(File.dirname(__FILE__)+"/../../data/firebug-2.0.13.xpi")
11
- net_export = File.absolute_path(File.dirname(__FILE__)+"/../../data/netExport-0.8.xpi")
12
- profile = Selenium::WebDriver::Firefox::Profile.new
13
- profile.add_extension(firebug)
14
- profile.add_extension(net_export)
15
- profile['extensions.firebug.currentVersion'] = "2.0.13"
16
- profile['extensions.firebug.allPagesActivation'] = "on"
17
- profile['extensions.firebug.defaultPanelName'] = "net"
18
- profile['extensions.firebug.net.enableSites'] = "true"
19
- profile['extensions.firebug.netexport.alwaysEnableAutoExport'] = "true"
20
- profile['extensions.firebug.netexport.showPreview'] = "false"
21
- profile['extensions.firebug.netexport.defaultLogDir'] = ENV['HAR_DIR'].to_s
22
- profile['extensions.firebug.netexport.defaultFileName'] = "upaReport.har"
23
- profile['extensions.firebug.netexport.jsonpCallback'] = "jsonCallback"
24
- @driver = Selenium::WebDriver.for :firefox, :profile => profile
25
- else
26
- @driver = Selenium::WebDriver.for :firefox
27
- end
28
- @driver.manage.timeouts.implicit_wait = 30
29
- @driver.manage.timeouts.page_load = 120
30
- @driver.manage.window.maximize
31
- @driver
32
- end
33
-
34
- def get_tmp_dir
35
- case RUBY_PLATFORM
36
- when /mswin|msys|mingw|cygwin|bccwin|wince|emc/
37
- return `echo %TEMP%`
38
- when /darwin|mac os/
39
- return "/tmp/"
40
- else
41
- return "/tmp/"
42
- end
43
- end
44
-
45
- def launch_watir_firefox
46
- browser = Watir::Browser.new
47
- browser.driver.manage.timeouts.implicit_wait = 30
48
- browser.driver.manage.timeouts.page_load = 120
49
- browser.driver.manage.window.maximize
50
- return browser
51
- end
52
-
1
+ # module TestNow
2
+ class Firefox
3
+
4
+ #Firefox browser
5
+ def launch_driver_firefox
6
+ caps = Selenium::WebDriver::Remote::Capabilities.firefox(marionette: false)
7
+ ENV['IS_UPA'] = "false" if ENV['IS_UPA'].nil?
8
+ if ENV['IS_UPA']=="true"
9
+ ENV['HAR_DIR'] = get_tmp_dir if ENV['HAR_DIR'].nil?
10
+ puts "=>=>=> Your HAR (UPA) files will be created here : #{ENV['HAR_DIR']}"
11
+ firebug = File.absolute_path(File.dirname(__FILE__)+"/../../data/firebug-2.0.13.xpi")
12
+ net_export = File.absolute_path(File.dirname(__FILE__)+"/../../data/netExport-0.8.xpi")
13
+ profile = Selenium::WebDriver::Firefox::Profile.new
14
+ profile.add_extension(firebug)
15
+ profile.add_extension(net_export)
16
+ profile['extensions.firebug.currentVersion'] = "2.0.13"
17
+ profile['extensions.firebug.allPagesActivation'] = "on"
18
+ profile['extensions.firebug.defaultPanelName'] = "net"
19
+ profile['extensions.firebug.net.enableSites'] = "true"
20
+ profile['extensions.firebug.netexport.alwaysEnableAutoExport'] = "true"
21
+ profile['extensions.firebug.netexport.showPreview'] = "false"
22
+ profile['extensions.firebug.netexport.defaultLogDir'] = ENV['HAR_DIR'].to_s
23
+ profile['extensions.firebug.netexport.defaultFileName'] = "upaReport.har"
24
+ profile['extensions.firebug.netexport.jsonpCallback'] = "jsonCallback"
25
+ driver = Selenium::WebDriver.for(:firefox, :profile => profile, :desired_cpabilities => caps)
26
+ else
27
+ driver = Selenium::WebDriver.for(:firefox, :desired_cpabilities => caps)
28
+ end
29
+ driver.manage.timeouts.implicit_wait = 30
30
+ driver.manage.timeouts.page_load = 120
31
+ driver.manage.window.maximize
32
+ driver
33
+ end
34
+
35
+ def get_tmp_dir
36
+ case RUBY_PLATFORM
37
+ when /mswin|msys|mingw|cygwin|bccwin|wince|emc/
38
+ return `echo %TEMP%`
39
+ when /darwin|mac os/
40
+ return "/tmp/"
41
+ else
42
+ return "/tmp/"
43
+ end
44
+ end
45
+
46
+ def launch_watir_firefox
47
+ caps = Selenium::WebDriver::Remote::Capabilities.firefox(marionette: false)
48
+ browser = Watir::Browser.new(:firefox, :desired_capabilities => caps)
49
+ browser.driver.manage.timeouts.implicit_wait = 30
50
+ browser.driver.manage.timeouts.page_load = 120
51
+ browser.driver.manage.window.maximize
52
+ return browser
53
+ end
54
+
53
55
  end
@@ -0,0 +1,31 @@
1
+ class FirefoxGecko
2
+
3
+ @private
4
+ def pre_config
5
+ caps = Selenium::WebDriver::Remote::Capabilities.firefox(marionette: true)
6
+ caps
7
+ end
8
+
9
+ @private
10
+ def post_config(driver)
11
+ driver.manage.timeouts.implicit_wait = 10
12
+ driver.manage.timeouts.page_load = 15
13
+ driver.manage.window.maximize
14
+ end
15
+
16
+ # Firefox Gecko Browser
17
+ def launch_driver_firefox_gecko
18
+ caps = self.pre_config
19
+ driver = Selenium::WebDriver.for(:firefox, :desired_capabilities => caps)
20
+ self.post_config(driver)
21
+ driver
22
+ end
23
+
24
+ def launch_watir_firefox_gecko
25
+ caps = self.pre_config
26
+ browser = Watir::Browser.new(:firefox, :desired_capabilities => caps)
27
+ self.post_config(browser.driver)
28
+ browser
29
+ end
30
+
31
+ end
data/lib/testnow/ie.rb CHANGED
@@ -1,46 +1,46 @@
1
- class IE
2
-
3
- @private
4
- def ie_config
5
- @client = Selenium::WebDriver::Remote::Http::Default.new
6
- @client.timeout = 120
7
- @caps = Selenium::WebDriver::Remote::Capabilities.ie('ie.ensureCleanSession' => true,
8
- :javascript_enabled => true,
9
- :http_client => @client,
10
- :native_events => false,
11
- :acceptSslCerts => true)
12
- end
13
-
14
- @private
15
- def set_ie_config(driver)
16
- driver.manage.timeouts.implicit_wait = 90
17
- driver.manage.timeouts.page_load = 120
18
- if ENV['RESOLUTION'].nil?
19
- driver.manage.window.size = Selenium::WebDriver::Dimension.new(1366,768)
20
- elsif ENV['RESOLUTION'].downcase == "max"
21
- driver.manage.window.maximize
22
- else
23
- res = ENV['RESOLUTION'].split('x')
24
- driver.manage.window.size = Selenium::WebDriver::Dimension.new(res.first.to_i, res.last.to_i)
25
- end
26
- end
27
-
28
- def launch_driver_ie
29
- self.ie_config
30
- driver = Selenium::WebDriver.for(:ie,
31
- :desired_capabilities => @caps,
32
- :http_client => @client)
33
- self.set_ie_config(driver)
34
- return driver
35
- end
36
-
37
- def launch_watir_ie
38
- self.ie_config
39
- browser = Watir::Browser.new(:ie,
40
- :desired_capabilities => @caps,
41
- :http_client => @client)
42
- self.set_ie_config(browser.driver)
43
- return browser
44
- end
45
-
1
+ class IE
2
+
3
+ @private
4
+ def ie_config
5
+ @client = Selenium::WebDriver::Remote::Http::Default.new
6
+ @client.timeout = 120
7
+ @caps = Selenium::WebDriver::Remote::Capabilities.ie('ie.ensureCleanSession' => true,
8
+ :javascript_enabled => true,
9
+ :http_client => @client,
10
+ :native_events => false,
11
+ :acceptSslCerts => true)
12
+ end
13
+
14
+ @private
15
+ def set_ie_config(driver)
16
+ driver.manage.timeouts.implicit_wait = 90
17
+ driver.manage.timeouts.page_load = 120
18
+ if ENV['RESOLUTION'].nil?
19
+ driver.manage.window.size = Selenium::WebDriver::Dimension.new(1366,768)
20
+ elsif ENV['RESOLUTION'].downcase == "max"
21
+ driver.manage.window.maximize
22
+ else
23
+ res = ENV['RESOLUTION'].split('x')
24
+ driver.manage.window.size = Selenium::WebDriver::Dimension.new(res.first.to_i, res.last.to_i)
25
+ end
26
+ end
27
+
28
+ def launch_driver_ie
29
+ self.ie_config
30
+ driver = Selenium::WebDriver.for(:ie,
31
+ :desired_capabilities => @caps,
32
+ :http_client => @client)
33
+ self.set_ie_config(driver)
34
+ return driver
35
+ end
36
+
37
+ def launch_watir_ie
38
+ self.ie_config
39
+ browser = Watir::Browser.new(:ie,
40
+ :desired_capabilities => @caps,
41
+ :http_client => @client)
42
+ self.set_ie_config(browser.driver)
43
+ return browser
44
+ end
45
+
46
46
  end
data/lib/testnow/opera.rb CHANGED
@@ -1,42 +1,42 @@
1
- class Opera
2
-
3
- @private
4
- def opera_config
5
- @client = Selenium::WebDriver::Remote::Http::Default.new
6
- @client.timeout = 180 # seconds
7
- @service = Selenium::WebDriver::Chrome::Service.new("/usr/local/bin/operadriver", 48923)
8
- @service.start
9
- @cap = Selenium::WebDriver::Remote::Capabilities.chrome('operaOptions' => {'binary' => "#{get_binary_path}", 'args' => ["--ignore-certificate-errors"]})
10
- end
11
-
12
- # Opera browser
13
- def launch_driver_opera
14
- self.opera_config
15
- @driver = Selenium::WebDriver.for(:remote, :url => @service.uri, :desired_capabilities => @cap, :http_client => @client)
16
- @driver.manage.timeouts.implicit_wait = 30
17
- @driver.manage.window.maximize
18
- @driver.manage.timeouts.page_load = 120
19
- return @driver
20
- end
21
-
22
- def launch_watir_opera
23
- self.opera_config
24
- browser = Watir::Browser.new(:remote, :url => @service.uri, :desired_capabilities => @cap, :http_client => @client)
25
- browser.driver.manage.timeouts.implicit_wait = 30
26
- browser.driver.manage.window.maximize
27
- browser.driver.manage.timeouts.page_load = 120
28
- return browser
29
- end
30
-
31
-
32
- def get_binary_path
33
- case RUBY_PLATFORM
34
- when /mswin|msys|mingw|cygwin|bccwin|wince|emc/
35
- return "NEED TO FIND WINDOWS BINARY LOCATION"
36
- when /darwin|mac os/
37
- return "/Applications/Opera.app/Contents/MacOS/Opera"
38
- else
39
- return "/usr/bin/opera"
40
- end
41
- end
1
+ class Opera
2
+
3
+ @private
4
+ def opera_config
5
+ @client = Selenium::WebDriver::Remote::Http::Default.new
6
+ @client.timeout = 180 # seconds
7
+ @service = Selenium::WebDriver::Chrome::Service.new("/usr/local/bin/operadriver", 48923)
8
+ @service.start
9
+ @cap = Selenium::WebDriver::Remote::Capabilities.chrome('operaOptions' => {'binary' => "#{get_binary_path}", 'args' => ["--ignore-certificate-errors"]})
10
+ end
11
+
12
+ # Opera browser
13
+ def launch_driver_opera
14
+ self.opera_config
15
+ @driver = Selenium::WebDriver.for(:remote, :url => @service.uri, :desired_capabilities => @cap, :http_client => @client)
16
+ @driver.manage.timeouts.implicit_wait = 30
17
+ @driver.manage.window.maximize
18
+ @driver.manage.timeouts.page_load = 120
19
+ return @driver
20
+ end
21
+
22
+ def launch_watir_opera
23
+ self.opera_config
24
+ browser = Watir::Browser.new(:remote, :url => @service.uri, :desired_capabilities => @cap, :http_client => @client)
25
+ browser.driver.manage.timeouts.implicit_wait = 30
26
+ browser.driver.manage.window.maximize
27
+ browser.driver.manage.timeouts.page_load = 120
28
+ return browser
29
+ end
30
+
31
+
32
+ def get_binary_path
33
+ case RUBY_PLATFORM
34
+ when /mswin|msys|mingw|cygwin|bccwin|wince|emc/
35
+ return "NEED TO FIND WINDOWS BINARY LOCATION"
36
+ when /darwin|mac os/
37
+ return "/Applications/Opera.app/Contents/MacOS/Opera"
38
+ else
39
+ return "/usr/bin/opera"
40
+ end
41
+ end
42
42
  end
data/lib/testnow/version CHANGED
@@ -1 +1 @@
1
- 0.0.9
1
+ 0.1.0
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: testnow
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kaushal Rupani
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-12-04 00:00:00.000000000 Z
11
+ date: 2016-12-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -91,11 +91,10 @@ files:
91
91
  - lib/testnow/chrome.rb
92
92
  - lib/testnow/edge.rb
93
93
  - lib/testnow/firefox.rb
94
+ - lib/testnow/firefox_gecko.rb
94
95
  - lib/testnow/ie.rb
95
96
  - lib/testnow/opera.rb
96
97
  - lib/testnow/version
97
- - spec/spec_helper.rb
98
- - spec/testnow/testnow_spec.rb
99
98
  homepage: https://github.com/krupani/testnow
100
99
  licenses:
101
100
  - MIT
@@ -117,11 +116,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
117
116
  version: '0'
118
117
  requirements: []
119
118
  rubyforge_project:
120
- rubygems_version: 2.5.1
119
+ rubygems_version: 2.6.8
121
120
  signing_key:
122
121
  specification_version: 4
123
122
  summary: 'TestNow gem : Automate in a BDD + Cross Browser style'
124
123
  test_files:
125
- - spec/spec_helper.rb
126
- - spec/testnow/testnow_spec.rb
127
124
  - Rakefile
data/spec/spec_helper.rb DELETED
@@ -1,5 +0,0 @@
1
- require 'rspec'
2
- require 'testnow'
3
- require 'testnow/firefox'
4
- require 'rspec/matchers'
5
- include TestNow
@@ -1,48 +0,0 @@
1
- require 'spec_helper'
2
-
3
-
4
- describe "Test TestNow" do
5
- it "should start chrome" do
6
- ENV['BROWSER']='chrome'
7
- driver = TestNow.init
8
- expect(driver).to be_an_instance_of Selenium::WebDriver::Driver
9
- expect(driver.inspect.to_s.downcase).to include("chrome")
10
- driver.quit
11
- end
12
-
13
- it "should start opera" do
14
- ENV['BROWSER']='opera'
15
- driver = TestNow.init
16
- expect(driver).to be_an_instance_of Selenium::WebDriver::Driver
17
- expect(driver.inspect.to_s.downcase).to include("chrome")
18
- driver.quit
19
- end
20
-
21
- it "should start firefox when BROWSER is set" do
22
- ENV['BROWSER']='firefox'
23
- driver = TestNow.init
24
- expect(driver).to be_an_instance_of Selenium::WebDriver::Driver
25
- expect(driver.inspect.to_s.downcase).to include("firefox")
26
- driver.quit
27
- end
28
-
29
- it "should start firefox as default when BROWSER is not set" do
30
- driver = TestNow.init
31
- expect(driver).to be_an_instance_of Selenium::WebDriver::Driver
32
- expect(driver.inspect.to_s.downcase).to include("firefox")
33
- driver.quit
34
- end
35
-
36
- it "should start firefox with UPA config when HAR_DIR is set" do
37
- ENV['HAR_DIR']="/Users/KaushalRupani/Downloads/"
38
- ENV['IS_UPA']="true"
39
- `rm -f $HAR_DIR*.har`
40
- driver = TestNow.init
41
- expect(driver).to be_an_instance_of Selenium::WebDriver::Driver
42
- expect(driver.inspect.to_s.downcase).to include("firefox")
43
- sleep(5)
44
- driver.get("http://google.com")
45
- expect(`ls $HAR_DIR*.har`).to_not be_nil
46
- driver.quit
47
- end
48
- end