webdriver-firefox 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ # Copyright (c) 2013 Solano Labs All Rights Reserved
2
+
3
+ require 'selenium/webdriver'
4
+
5
+ require 'webdriver-firefox/port_pool'
6
+ require 'webdriver-firefox/no_lock_firefox_bridge'
7
+ require 'webdriver-firefox/no_lock_driver'
@@ -0,0 +1,44 @@
1
+ # This file subject to Apache License 2.0; see LICENSE.txt
2
+
3
+ module Selenium
4
+ module WebDriver
5
+ class Driver
6
+ class << self
7
+ def for(browser, opts = {})
8
+ listener = opts.delete(:listener)
9
+
10
+ bridge = case browser
11
+ when :firefox, :ff
12
+ Firefox::Bridge.new(opts)
13
+ when :firefox_tddium
14
+ pool = ::NoLockFirefox::PortPool.new
15
+ opts[:port] = pool.find_free_port
16
+ ::NoLockFirefox::NoLockFirefoxBridge.new(opts)
17
+ when :remote
18
+ Remote::Bridge.new(opts)
19
+ when :ie, :internet_explorer
20
+ IE::Bridge.new(opts)
21
+ when :chrome
22
+ Chrome::Bridge.new(opts)
23
+ when :android
24
+ Android::Bridge.new(opts)
25
+ when :iphone
26
+ IPhone::Bridge.new(opts)
27
+ when :opera
28
+ Opera::Bridge.new(opts)
29
+ when :phantomjs
30
+ PhantomJS::Bridge.new(opts)
31
+ when :safari
32
+ Safari::Bridge.new(opts)
33
+ else
34
+ raise ArgumentError, "unknown driver: #{browser.inspect}"
35
+ end
36
+
37
+ bridge = Support::EventFiringBridge.new(bridge, listener) if listener
38
+
39
+ new(bridge)
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,29 @@
1
+ # This file subject to Apache License 2.0; see LICENSE.txt
2
+
3
+ module NoLockFirefox
4
+ class NoLockFirefoxBridge < Selenium::WebDriver::Firefox::Bridge
5
+ class FakeLock
6
+ def initialize(*args)
7
+ end
8
+
9
+ def locked
10
+ yield
11
+ end
12
+ end
13
+
14
+ class NoLockLauncher < Selenium::WebDriver::Firefox::Launcher
15
+ private
16
+
17
+ def find_free_port
18
+ end
19
+
20
+ def socket_lock
21
+ @socket_lock ||= FakeLock.new
22
+ end
23
+ end
24
+
25
+ def create_launcher(port, profile)
26
+ NoLockLauncher.new Selenium::WebDriver::Firefox::Binary.new, port, profile
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,54 @@
1
+ # Copyright (c) 2013 Solano Labs All Rights Reserved
2
+
3
+ require 'socket'
4
+
5
+ module NoLockFirefox
6
+ class PortPool
7
+ HOST = "127.0.0.1"
8
+ START_PORT = 24576
9
+
10
+ def initialize(path=nil)
11
+ @path_ports = path
12
+ @path_ports ||= "/tmp/webdriver-firefox.ports.json"
13
+ @random = Random.new
14
+ end
15
+
16
+ def find_free_port
17
+ probed = nil
18
+
19
+ tid = ENV.fetch('TDDIUM_TID', 0).to_i
20
+
21
+ range = 256*tid
22
+ index = @random.rand(256)
23
+ limit = START_PORT+256*(tid+1)
24
+
25
+ timeout = Time.now+90
26
+
27
+ while Time.now < timeout do
28
+ port = START_PORT+range+index
29
+ while port < limit do
30
+ probed = probe_port(port)
31
+ if probed then
32
+ probed.close
33
+ return port
34
+ end
35
+ port += 1
36
+ Kernel.sleep(0.1)
37
+ end
38
+ end
39
+
40
+ raise "unable to find open port in reasonable time"
41
+ end
42
+
43
+ def probe_port(port)
44
+ begin
45
+ s = TCPServer.new(HOST, port)
46
+ s.close_on_exec = true
47
+ # ChildProcess.close_on_exec s
48
+ return s
49
+ rescue SocketError, Errno::EADDRINUSE => e
50
+ return nil
51
+ end
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,5 @@
1
+ # Copyright (c) 2013 Solano Labs All Rights Reserved
2
+
3
+ module WebdriverFirefox
4
+ VERSION = '0.0.5'
5
+ end
metadata ADDED
@@ -0,0 +1,81 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: webdriver-firefox
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 0
8
+ - 5
9
+ version: 0.0.5
10
+ platform: ruby
11
+ authors:
12
+ - Solano Labs
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2013-08-19 00:00:00 -07:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: selenium-webdriver
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ segments:
29
+ - 0
30
+ version: "0"
31
+ type: :runtime
32
+ version_requirements: *id001
33
+ description: Lockless Support for Webdriver and Firefox
34
+ email:
35
+ - info@solanolabs.com
36
+ executables: []
37
+
38
+ extensions: []
39
+
40
+ extra_rdoc_files: []
41
+
42
+ files:
43
+ - lib/webdriver-firefox.rb
44
+ - lib/webdriver-firefox/no_lock_driver.rb
45
+ - lib/webdriver-firefox/no_lock_firefox_bridge.rb
46
+ - lib/webdriver-firefox/port_pool.rb
47
+ - lib/webdriver-firefox/version.rb
48
+ has_rdoc: true
49
+ homepage: http://www.solanolabs.com/
50
+ licenses: []
51
+
52
+ post_install_message:
53
+ rdoc_options: []
54
+
55
+ require_paths:
56
+ - lib
57
+ required_ruby_version: !ruby/object:Gem::Requirement
58
+ none: false
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ segments:
63
+ - 0
64
+ version: "0"
65
+ required_rubygems_version: !ruby/object:Gem::Requirement
66
+ none: false
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ segments:
71
+ - 0
72
+ version: "0"
73
+ requirements: []
74
+
75
+ rubyforge_project: tddium
76
+ rubygems_version: 1.3.7
77
+ signing_key:
78
+ specification_version: 3
79
+ summary: WebdriverFirefox
80
+ test_files: []
81
+