selenium_tor 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2e1fe6540f9a3fdb5709dd88c4594a453052aec00f00423e39f69664ec8d27e1
4
- data.tar.gz: a0a8a23354f5c0bad149baf6d0b043e72f64845b142921492c72d6565e8120da
3
+ metadata.gz: 484a1e6197b2ab0ad98ed6ccff6591db30094e87a3b51fb517c15f2531b9c76f
4
+ data.tar.gz: 180f09296eaf38cfe25b435f9126c9ae84e7fa123421bf9ec649d4d82d128e41
5
5
  SHA512:
6
- metadata.gz: c74beaf4a2c71a66fb4cbee34f9896c483308b684b99ebcb12e653c983d7be6e4486d6ea8c177096d01243d2eb5f275044d308ef9f602bf56c760be2ffcb6022
7
- data.tar.gz: 633ca399c16169d4f9d0a48b12fb4781a1c68fa4e49e121454db26d14bea1bef0770ef1d82e1cb700ffe1124d353ed7070e8830290a9e4796b3458d74a62492c
6
+ metadata.gz: d88198513d5606df47bc7a5917c2384320f9a855877498994d72a0e6c2a71118c226340df00cd8c8892bd1bad63010ab59cb71856e757c98a306dd1414bf164f
7
+ data.tar.gz: '01954638cb9ffc19275acd528cd19326d77604f2570cecd1ce2eb1afd41a130812246d57c9db8cb05ffa960c94e96d1213545d70565528f24260b92548e26677'
data/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  ## master (unreleased)
2
2
 
3
+ ## [0.1.2] - 2023-11-20
4
+
5
+ * Breaking change: change constant names in Tor namespace - see README
6
+
7
+ ### New features
8
+
9
+ * Added Tor::Profile and lock file patch for Selenium < 4.16 see [Selenium #11576](https://github.com/SeleniumHQ/selenium/issues/11576)
10
+ * Add tests for NoScript extension
11
+
3
12
  ## [0.1.1] - 2023-11-19
4
13
 
5
14
  * Rename gem from selenium-tor, yanked previous versions
data/README.md CHANGED
@@ -34,37 +34,43 @@ puts driver.title
34
34
  ```
35
35
  The driver will not be instantiated until a connection to the Tor network is made. If the network is inaccessible for any reason a `TorNetworkError` will result.
36
36
 
37
- The `Selenium::WebDriver::Tor` namespace is used by `Driver` and `Options`. Otherwise Selenium's `Selenium::WebDriver::Firefox` namespace is used.
37
+ The `Selenium::WebDriver::Tor` namespace is used for `Driver`, `Options` and `Profile`. Otherwise Selenium's `Selenium::WebDriver::Firefox` namespace is used.
38
38
 
39
39
  Remote functionality is not tested, but will be if Selenium provide a Tor Browser Docker container for Selenium Grid.
40
40
 
41
- A number of constants are set during driver initialization based upon values found in the Tor Browser Bundle (TBB) root directory (see below). These include:
41
+ A number of constants are set during driver initialization based upon values found in the Tor Browser Bundle (TBB) root directory - see below. These include:
42
42
  ```ruby
43
43
  Tor::TBB_DIR # path to the TBB root directory
44
44
  Tor::TBB_BROWSER_DIR # path to the 'Browser' directory in the above
45
- Tor::TOR_BROWSER_BINARY_PATH # path to the binary
46
- Tor::TOR_BROWSER_VERSION # the version installed, e.g. "13.0.1", note: driver.capabilities.browser_version returns the Firefox version Tor Browser is based on
45
+ Tor::TBB_BINARY_PATH # path to the binary
46
+ Tor::TBB_PROFILE_DIR # path to the default profile directory
47
+ Tor::TBB_EXTENSIONS_DIR # path to the 'extensions' directory in the above
48
+ Tor::TBB_VERSION #
49
+ the version installed, e.g. "13.0.1", note: driver.capabilities.browser_version returns the Firefox version Tor Browser is based on
47
50
  ```
48
51
 
49
52
  ## Dependencies and configuration
50
53
 
51
- As with Firefox browser, Geckodriver needs to be installed and in your PATH.
54
+ As with Firefox browser, `geckodriver` needs to be installed and in your PATH.
52
55
 
53
- The gem needs to know the location of the Tor Browser Bundle (TBB). This can be installed from the Tor Project [downloads page](https://www.torproject.org/download/). The download package archive must be extracted and the root TBB directory (called `tor-browser`) placed somewhere on your system. By default it is assumed to be in the current user's HOME directory. An alternative location can be set via the env var `TOR_BROWSER_ROOT_DIR` - e.g. `export TOR_BROWSER_ROOT_DIR=/home/<user>/Downloads`. The Tor Browser binary location is *automatically set* by reference to this directory, so there is no need to do this:
56
+ The gem needs to know the location of the Tor Browser Bundle (TBB). This can be installed from the Tor Project [downloads page](https://www.torproject.org/download/). The download package archive must be extracted and the root TBB directory (named "tor-browser") placed somewhere on your system. By default it is assumed to be in the current user's HOME directory. An alternative location can be set via the env var `TOR_BROWSER_ROOT_DIR` - e.g. `export TOR_BROWSER_ROOT_DIR=/home/<user>/Downloads`. The Tor Browser binary location is *automatically set* by reference to this directory, so there is no need to do this:
54
57
  ```ruby
55
58
  options.binary = '/some/path/to/tor_firefox_binary' # UNNECESSARY
56
59
  ```
60
+
61
+ The location of the TBB is not expected to change during execution.
62
+
57
63
  Tor Selenium is tested on **Linux only** right now.
58
64
 
59
65
  ## Testing
60
66
 
61
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests.
67
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `bundle exec rake` to run the tests.
62
68
 
63
69
  Tests are run in headless mode by default. If you want to see what the browser is doing you can do this:
64
70
 
65
- $ export RUN_HEADED_TESTS=1 && rake
71
+ $ export RUN_HEADED_TESTS=1 && bundle exec rake
66
72
 
67
- If you find tests are failing with `TorNetworkError` and a timeout message, check you have no other Tor Browser processes running. The process to look for is called `firefox.real`. You may also want to check the Tor network is actually up, it isn't always..
73
+ If you find tests are failing with `TorNetworkError` and a timeout message, check you have no other Tor Browser processes running. The process to look for is called "firefox.real". You may also want to check the Tor network is actually up, it isn't always..
68
74
 
69
75
  ## Development
70
76
 
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Selenium
4
+ module WebDriver
5
+ module Firefox
6
+ # patched class
7
+ class Profile
8
+ alias old_delete_lock_files delete_lock_files
9
+
10
+ def delete_lock_files(directory)
11
+ %w[.parentlock parent.lock lock].each do |name| # 'lock' file missing from Selenium < 4.16
12
+ FileUtils.rm_f File.join(directory, name)
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
data/lib/tor/options.rb CHANGED
@@ -11,8 +11,10 @@ module Selenium
11
11
  DEFAULT_TBB_DIR = File.join Dir.home, 'tor-browser'
12
12
  Tor::TBB_DIR = ENV.fetch('TOR_BROWSER_ROOT_DIR', nil) || DEFAULT_TBB_DIR
13
13
  Tor::TBB_BROWSER_DIR = File.join Tor::TBB_DIR, 'Browser'
14
- Tor::TOR_BROWSER_BINARY_PATH = File.join Tor::TBB_BROWSER_DIR, 'firefox'
15
- Tor::TOR_BROWSER_VERSION = JSON.parse(File.read(File.join(Tor::TBB_BROWSER_DIR, 'tbb_version.json')))['version']
14
+ Tor::TBB_BINARY_PATH = File.join Tor::TBB_BROWSER_DIR, 'firefox'
15
+ Tor::TBB_PROFILE_DIR = File.join Tor::TBB_BROWSER_DIR, *%w[TorBrowser Data Browser profile.default]
16
+ Tor::TBB_EXTENSIONS_DIR = File.join Tor::TBB_PROFILE_DIR, 'extensions'
17
+ Tor::TBB_VERSION = JSON.parse(File.read(File.join(Tor::TBB_BROWSER_DIR, 'tbb_version.json')))['version']
16
18
 
17
19
  def initialize(log_level: nil, **opts)
18
20
  super(log_level: log_level, **tor_options.merge(opts))
@@ -22,7 +24,7 @@ module Selenium
22
24
  private
23
25
 
24
26
  def tor_options
25
- { binary: TOR_BROWSER_BINARY_PATH, prefs: PREFS }
27
+ { binary: TBB_BINARY_PATH, prefs: PREFS }
26
28
  end
27
29
 
28
30
  def do_start_tor_browser_script_stuff
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'selenium-webdriver'
4
+ require_relative 'options'
5
+ require_relative '../firefox_driver_lock_file_patch' unless
6
+ Gem::Version.new(Selenium::WebDriver::VERSION) > Gem::Version.new('4.15')
7
+
8
+ module Selenium
9
+ module WebDriver
10
+ module Tor
11
+ # subclass
12
+ class Profile < Firefox::Profile
13
+ end
14
+ end
15
+ end
16
+ end
data/lib/tor/version.rb CHANGED
@@ -3,7 +3,7 @@
3
3
  module Selenium
4
4
  module WebDriver
5
5
  module Tor
6
- VERSION = '0.1.1'
6
+ VERSION = '0.1.2'
7
7
  end
8
8
  end
9
9
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: selenium_tor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - MatzFan
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-11-19 00:00:00.000000000 Z
11
+ date: 2023-11-20 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Selenium extension for Tor Browser
14
14
  email:
@@ -26,6 +26,7 @@ files:
26
26
  - README.md
27
27
  - Rakefile
28
28
  - lib/driver.rb
29
+ - lib/firefox_driver_lock_file_patch.rb
29
30
  - lib/mixin.rb
30
31
  - lib/options.rb
31
32
  - lib/selenium_tor.rb
@@ -34,6 +35,7 @@ files:
34
35
  - lib/tor/driver_not_yet_connected_to_tor_network.rb
35
36
  - lib/tor/options.rb
36
37
  - lib/tor/prefs.rb
38
+ - lib/tor/profile.rb
37
39
  - lib/tor/version.rb
38
40
  - selenium_tor.gemspec
39
41
  - sig/tor.rbs