|
17 | 17 | # specific language governing permissions and limitations
|
18 | 18 | # under the License.
|
19 | 19 | import os
|
| 20 | +import errno |
20 | 21 | import subprocess
|
21 | 22 | from subprocess import PIPE
|
22 | 23 | import time
|
@@ -54,22 +55,32 @@ def start(self):
|
54 | 55 | Starts the ChromeDriver Service.
|
55 | 56 |
|
56 | 57 | :Exceptions:
|
57 |
| - - WebDriverException : Raised either when it can't start the service |
58 |
| - or when it can't connect to the service |
| 58 | + - WebDriverException : Raised either when it cannot find the |
| 59 | + executable, when it does not have permissions for the |
| 60 | + executable, or when it cannot connect to the service. |
| 61 | + - Possibly other Exceptions in rare circumstances (OSError, etc). |
59 | 62 | """
|
60 | 63 | env = self.env or os.environ
|
61 | 64 | try:
|
62 | 65 | self.process = subprocess.Popen([
|
63 | 66 | self.path,
|
64 | 67 | "--port=%d" % self.port] +
|
65 | 68 | self.service_args, env=env, stdout=PIPE, stderr=PIPE)
|
66 |
| - except: |
67 |
| - raise WebDriverException( |
68 |
| - "'" + os.path.basename(self.path) + "' executable needs to be \ |
69 |
| - available in the path. Please look at \ |
70 |
| - http://docs.seleniumhq.org/download/#thirdPartyDrivers \ |
71 |
| - and read up at \ |
72 |
| - https://github.com/SeleniumHQ/selenium/wiki/ChromeDriver") |
| 69 | + except OSError as err: |
| 70 | + docs_msg = "Please see " \ |
| 71 | + "https://sites.google.com/a/chromium.org/chromedriver/home" |
| 72 | + if err.errno == errno.ENOENT: |
| 73 | + raise WebDriverException( |
| 74 | + "'%s' executable needs to be in PATH. %s" % ( |
| 75 | + os.path.basename(self.path), docs_msg) |
| 76 | + ) |
| 77 | + elif err.errno == errno.EACCES: |
| 78 | + raise WebDriverException( |
| 79 | + "'%s' executable may have wrong permissions. %s" % ( |
| 80 | + os.path.basename(self.path), docs_msg) |
| 81 | + ) |
| 82 | + else: |
| 83 | + raise |
73 | 84 | count = 0
|
74 | 85 | while not utils.is_connectable(self.port):
|
75 | 86 | count += 1
|
|
0 commit comments