testnow 0.1.0 → 0.1.1

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.
@@ -1,35 +1,35 @@
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
1
+ class MicrosoftEdge
2
+
3
+ @private
4
+ def pre_config
5
+ @client = Selenium::WebDriver::Remote::Http::Default.new
6
+ @client.read_timeout = 120
7
+ @caps = Selenium::WebDriver::Remote::Capabilities.edge(:native_events => false,
8
+ :acceptSslCerts => true)
9
+ end
10
+
11
+ @private
12
+ def post_config(driver)
13
+ driver.manage.timeouts.implicit_wait = 30
14
+ driver.manage.timeouts.page_load = 120
15
+ end
16
+
17
+ def launch_driver_edge
18
+ self.pre_config
19
+ driver = Selenium::WebDriver.for(:edge,
20
+ :desired_capabilities => @caps,
21
+ :http_client => @client)
22
+ self.post_config(driver)
23
+ return driver
24
+ end
25
+
26
+ def launch_watir_edge
27
+ self.pre_config
28
+ browser = Watir::Browser.new(:edge,
29
+ :desired_capabilities => @caps,
30
+ :http_client => @client)
31
+ self.post_config(browser.driver)
32
+ return browser
33
+ end
34
+
35
35
  end
@@ -1,55 +1,55 @@
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
-
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
+
55
55
  end
@@ -1,31 +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
-
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
31
  end
@@ -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.read_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
@@ -1,42 +1,46 @@
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 pre_config
5
+ @client = Selenium::WebDriver::Remote::Http::Default.new
6
+ @client.read_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
+ @private
13
+ def post_config(driver)
14
+ driver.manage.timeouts.implicit_wait = 30
15
+ driver.manage.window.maximize
16
+ driver.manage.timeouts.page_load = 120
17
+ end
18
+
19
+ # Opera browser
20
+ def launch_driver_opera
21
+ self.pre_config
22
+ driver = Selenium::WebDriver.for(:remote, :url => @service.uri, :desired_capabilities => @cap, :http_client => @client)
23
+ self.post_config(driver)
24
+ return driver
25
+ end
26
+
27
+ # Opera browser
28
+ def launch_watir_opera
29
+ self.pre_config
30
+ browser = Watir::Browser.new(:remote, :url => @service.uri, :desired_capabilities => @cap, :http_client => @client)
31
+ self.post_config(browser.driver)
32
+ return browser
33
+ end
34
+
35
+ @private
36
+ def get_binary_path
37
+ case RUBY_PLATFORM
38
+ when /mswin|msys|mingw|cygwin|bccwin|wince|emc/
39
+ return "NEED TO FIND WINDOWS BINARY LOCATION"
40
+ when /darwin|mac os/
41
+ return "/Applications/Opera.app/Contents/MacOS/Opera"
42
+ else
43
+ return "/usr/bin/opera"
44
+ end
45
+ end
42
46
  end
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.1.1
@@ -0,0 +1,5 @@
1
+ require 'rspec'
2
+ require 'testnow'
3
+ require 'testnow/firefox'
4
+ require 'rspec/matchers'
5
+ include TestNow
@@ -0,0 +1,48 @@
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