1414# KIND, either express or implied. See the License for the
1515# specific language governing permissions and limitations
1616# under the License.
17+ import json
1718import logging
1819import subprocess
1920import sys
@@ -70,14 +71,20 @@ def driver_location(self, browser: str) -> str:
7071 if browser == "ie" :
7172 browser = "iexplorer"
7273
73- binary , flag , browser = str (self .get_binary ()), "--browser" , browser
74- result = self .run ((binary , flag , browser ))
74+ binary , browser_flag , browser , output_flag , output = (
75+ str (self .get_binary ()),
76+ "--browser" ,
77+ browser ,
78+ "--output" ,
79+ "json" ,
80+ )
81+ result = self .run ((binary , browser_flag , browser , output_flag , output ))
7582 executable = result .split ("\t " )[- 1 ].strip ()
7683 logger .debug (f"Using driver at: { executable } " )
7784 return executable
7885
7986 @staticmethod
80- def run (args : Tuple [str , str , str ]) -> str :
87+ def run (args : Tuple [str , str , str , str , str ]) -> str :
8188 """
8289 Executes the Selenium Manager Binary.
8390 :Args:
@@ -89,8 +96,13 @@ def run(args: Tuple[str, str, str]) -> str:
8996 completed_proc = subprocess .run (args , stdout = subprocess .PIPE , stderr = subprocess .PIPE )
9097 stdout = completed_proc .stdout .decode ("utf-8" ).rstrip ("\n " )
9198 stderr = completed_proc .stderr .decode ("utf-8" ).rstrip ("\n " )
99+ output = json .loads (stdout )
100+ result = output ["result" ]["message" ]
92101 if completed_proc .returncode :
93- raise SeleniumManagerException (f"Selenium manager failed for: { command } .\n { stdout } { stderr } " )
102+ raise SeleniumManagerException (f"Selenium manager failed for: { command } .\n { result } { stderr } " )
94103 else :
95- # selenium manager exited 0 successfully, parse the executable path from stdout.
96- return stdout .split ("\t " )[- 1 ].strip ()
104+ # Selenium Manager exited 0 successfully, return executable path and print warnings (if any)
105+ for item in output ["logs" ]:
106+ if item ["level" ] == "WARN" :
107+ logger .warning (item ["message" ])
108+ return result
0 commit comments