Executes the Selenium Manager Binary. Args: args: the components of the command being executed. Returns: The log string containing the driver location.
(args: list[str])
| 127 | |
| 128 | @staticmethod |
| 129 | def _run(args: list[str]) -> dict: |
| 130 | """Executes the Selenium Manager Binary. |
| 131 | |
| 132 | Args: |
| 133 | args: the components of the command being executed. |
| 134 | |
| 135 | Returns: |
| 136 | The log string containing the driver location. |
| 137 | """ |
| 138 | command = " ".join(args) |
| 139 | logger.debug("Executing process: %s", command) |
| 140 | try: |
| 141 | if sys.platform == "win32": |
| 142 | completed_proc = subprocess.run(args, capture_output=True, creationflags=subprocess.CREATE_NO_WINDOW) |
| 143 | else: |
| 144 | completed_proc = subprocess.run(args, capture_output=True) |
| 145 | stdout = completed_proc.stdout.decode("utf-8").rstrip("\n") |
| 146 | stderr = completed_proc.stderr.decode("utf-8").rstrip("\n") |
| 147 | output = json.loads(stdout) if stdout != "" else {"logs": [], "result": {}} |
| 148 | except Exception as err: |
| 149 | raise WebDriverException(f"Unsuccessful command executed: {command}") from err |
| 150 | |
| 151 | SeleniumManager._process_logs(output["logs"]) |
| 152 | result = output["result"] |
| 153 | if completed_proc.returncode: |
| 154 | raise WebDriverException( |
| 155 | f"Unsuccessful command executed: {command}; code: {completed_proc.returncode}\n{result}\n{stderr}" |
| 156 | ) |
| 157 | return result |
| 158 | |
| 159 | @staticmethod |
| 160 | def _process_logs(log_items: list[dict]): |