Skip to content

Commit ac2d132

Browse files
committed
Refactor the README for readability and consistency
1 parent 0b10cb8 commit ac2d132

1 file changed

Lines changed: 33 additions & 35 deletions

File tree

README.md

Lines changed: 33 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
11
# tor-browser-selenium [![Build Status](https://app.travis-ci.com/webfp/tor-browser-selenium.svg?branch=main)](https://app.travis-ci.com/webfp/tor-browser-selenium)
22

33

4-
A Python library to automate Tor Browser with Selenium.
4+
A Python library to automate Tor Browser with Selenium WebDriver.
55

6-
## Installation
6+
## 📦 Installation
77

88
```
99
pip install tbselenium
1010
```
1111

1212
Download `geckodriver` v0.31.0 from the [geckodriver releases page](https://github.com/mozilla/geckodriver/releases/) and add it to PATH.
1313

14-
## Basic usage
14+
## 🚀 Usage
15+
16+
Download and extract [Tor Browser](https://www.torproject.org/projects/torbrowser.html.en), and pass its path when you initialize `TorBrowserDriver`.
17+
18+
1519
### Using with system `tor`
1620

1721
`tor` needs to be installed (`apt install tor`) and running on port 9050.
@@ -23,8 +27,8 @@ with TorBrowserDriver("/path/to/tor-browser/") as driver:
2327
```
2428

2529
### Using with `Stem`
26-
First, make sure you have `Stem` installed (`pip install stem`).
27-
The following will start a new `tor` process using `Stem`. It will not use the `tor` installed on your system.
30+
You can use `Stem` to start a new tor process programmatically, and connect to it from `tor-browser-selenium`. Make sure you have `Stem` installed: `pip install stem`:
31+
2832

2933
```python
3034
import tbselenium.common as cm
@@ -39,55 +43,49 @@ with TorBrowserDriver(tbb_dir, tor_cfg=cm.USE_STEM) as driver:
3943
tor_process.kill()
4044
```
4145

42-
`tor-browser-selenium` does not download the Tor Browser for you.
43-
You should [download](https://www.torproject.org/projects/torbrowser.html.en)
44-
and extract, and pass its path when you initialize `TorBrowserDriver`.
4546

46-
47-
48-
## Examples
47+
## 💡 Examples
4948
Check the [examples](https://github.com/webfp/tor-browser-selenium/tree/master/examples) to discover different ways to use `tor-browser-selenium`
50-
* [check_tpo.py](https://github.com/webfp/tor-browser-selenium/tree/master/examples/check_tpo.py): Visit check.torproject.org website and print the network status message
51-
* [headless.py](https://github.com/webfp/tor-browser-selenium/tree/master/examples/headless.py): Headless visit and screenshot of check.torproject.org using XVFB
49+
* [check_tpo.py](https://github.com/webfp/tor-browser-selenium/tree/master/examples/check_tpo.py): Visit the `check.torproject.org` website and print the network status message
50+
* [headless.py](https://github.com/webfp/tor-browser-selenium/tree/master/examples/headless.py): Headless visit and screenshot of check.torproject.org using [PyVirtualDisplay](https://pypi.org/project/PyVirtualDisplay/)
5251
* [onion_service.py](https://github.com/webfp/tor-browser-selenium/blob/main/examples/onion_service.py): Search using DuckDuckGo's Onion service
53-
* [parallel.py](https://github.com/webfp/tor-browser-selenium/tree/master/examples/parallel.py): Visit check.torproject.org with 3 browsers running in parallel
52+
* [parallel.py](https://github.com/webfp/tor-browser-selenium/tree/master/examples/parallel.py): Visit `check.torproject.org`` with 3 browsers running in parallel
5453
* [screenshot.py](https://github.com/webfp/tor-browser-selenium/tree/master/examples/screenshot.py): Take a screenshot
55-
* [stem_simple.py](https://github.com/webfp/tor-browser-selenium/tree/master/examples/stem_simple.py): Using Stem to start the Tor process
56-
* [stem_adv.py](https://github.com/webfp/tor-browser-selenium/tree/master/examples/stem_adv.py): Using Stem with more advanced configuration
54+
* [stem_simple.py](https://github.com/webfp/tor-browser-selenium/tree/master/examples/stem_simple.py): Use Stem to start a `tor` process
55+
* [stem_adv.py](https://github.com/webfp/tor-browser-selenium/tree/master/examples/stem_adv.py): Use Stem to launch `tor` with more advanced configuration
5756

5857

5958

60-
## Test and development
59+
## 🛠️ Test and development
6160

62-
Browse the [existing tests](https://github.com/webfp/tor-browser-selenium/tree/main/tbselenium/test) to find out about different ways you can use `tor-browser-selenium`.
61+
* Browse the [existing tests](https://github.com/webfp/tor-browser-selenium/tree/main/tbselenium/test) to find out about different ways you can use `tor-browser-selenium`.
6362

64-
For development and testing first install the necessary Python packages:
63+
* For development and testing first install the necessary Python packages:
64+
`pip install -r requirements-dev.txt`
6565

66-
`pip install -r requirements-dev.txt`
66+
* Install the `xvfb` package by running `apt-get install xvfb` or using your distro's package manager.
6767

68-
Install the `xvfb` package by running `apt-get install xvfb` or using your distro's package manager.
68+
* Run the following to launch the tests:
6969

70-
Run the following to launch the tests:
70+
`./run_tests.py /path/to/tor-browser/`
7171

72-
`./run_tests.py /path/to/tor-browser/`
73-
74-
By default, tests will be run using `Xvfb`, so the browser window will not be visible.
72+
* By default, tests will be run using `Xvfb`, so the browser window will not be visible.
7573
You may disable `Xvfb` by setting the `NO_XVFB` environment variable:
7674

77-
`export NO_XVFB=1`
75+
`export NO_XVFB=1`
7876

7977

8078
### Running individual tests
81-
First, export the path to Tor Browser folder in the `TBB_PATH` environment variable.
79+
* First, export the path to Tor Browser folder in the `TBB_PATH` environment variable.
8280

8381
`export TBB_PATH=/path/to/tbb/tor-browser/`
8482

85-
Then, use `py.test` to launch the tests you want, e.g.:
83+
* Then, use `py.test` to launch the tests you want, e.g.:
8684

8785
* `py.test tbselenium/test/test_tbdriver.py`
8886
* `py.test tbselenium/test/test_tbdriver.py::TBDriverTest::test_should_load_check_tpo`
8987

90-
Note that the directory pointed by `TBB_PATH` should contain the A custom `start-tor binary can
88+
9189
### Using a custom `geckodriver`
9290
A custom `geckodriver` binary can be set via the `executable_path` argument:
9391

@@ -101,18 +99,18 @@ You can redirect the logs to `/dev/null` by passing the `tbb_logfile_path` initi
10199
TorBrowserDriver(..., tbb_logfile_path='/dev/null')
102100
```
103101

104-
## Compatibility
102+
## ⚙️ Compatibility
105103

106104
Warning: **Windows and macOS are not supported.**
107105

108106
[Tested](https://travis-ci.org/webfp/tor-browser-selenium) with the following Tor Browser versions on Ubuntu:
109107

110-
* 12.0.7
111-
* 12.5a7
108+
* **Stable**: 12.0.7
109+
* **Alpha**: 12.5a7
112110

113111
If you need to use a different version of Tor Browser, [view the past test runs](https://travis-ci.org/webfp/tor-browser-selenium) to find out the compatible `selenium` and `geckodriver` versions.
114112

115-
## Troubleshooting
113+
## 🔧 Troubleshooting
116114

117115
Solutions to potential issues:
118116

@@ -128,7 +126,7 @@ Solutions to potential issues:
128126
* `driver.get_cookies()` returns an empty list. This is due to Private Browsing Mode (PBM), which Selenium uses under the hood. See [#79](https://github.com/webfp/tor-browser-selenium/issues/79) for a possible solution.
129127
* WebGL is not supported in the headless mode started with `headless=True` due to a Firefox bug ([#1375585](https://bugzilla.mozilla.org/show_bug.cgi?id=1375585)). To enable WebGL in a headless setting, use `pyvirtualdisplay` following the [headless.py](https://github.com/webfp/tor-browser-selenium/tree/master/examples/headless.py) example.
130128

131-
## Reference
129+
## 📚 Reference
132130
Please use the following reference if you use `tor-browser-selenium` in your academic publications.
133131

134132
```
@@ -141,5 +139,5 @@ Please use the following reference if you use `tor-browser-selenium` in your aca
141139
}
142140
```
143141

144-
## Credits
142+
## 🙌 Credits
145143
We greatly benefited from the [tor-browser-bundle-testsuite](https://gitlab.torproject.org/tpo/applications/tor-browser-bundle-testsuite) and [tor-browser-selenium](https://github.com/isislovecruft/tor-browser-selenium) projects.

0 commit comments

Comments
 (0)