22{
33 using NLog ;
44 using System ;
5+ using System . Diagnostics ;
56 using System . IO ;
67 using System . IO . Compression ;
78 using System . Net ;
@@ -18,6 +19,8 @@ public static class WebDriverManager
1819
1920 private static string zip { get ; set ; } = null ;
2021
22+ private static bool isNew { get ; set ; } = false ;
23+
2124 /// <summary>
2225 /// Build browser driver download URL from mock using config parameters
2326 /// </summary>
@@ -35,7 +38,7 @@ private static string BuildUrl(string baseUrl, string release, string version, s
3538 . Replace ( "<version>" , version )
3639 . Replace ( "<architecture>" , architecture ) ;
3740 }
38- catch ( Exception ex )
41+ catch ( Exception ex )
3942 {
4043 hLog . Error ( ex , "Error occurred during building browser driver archive download URL" ) ;
4144 throw new WebDriverManagerException ( "Error occurred during building browser driver archive download URL" , ex ) ;
@@ -53,7 +56,7 @@ private static void PrepareCatalogs(string path)
5356 if ( ! Directory . Exists ( path ) )
5457 Directory . CreateDirectory ( path ) ;
5558 }
56- catch ( Exception ex )
59+ catch ( Exception ex )
5760 {
5861 hLog . Error ( ex , "Error occurred during browser driver catalog preparation" ) ;
5962 throw new WebDriverManagerException ( "Error occurred during browser driver catalog preparation" , ex ) ;
@@ -71,7 +74,7 @@ private static string ZipFileName(string hreflink)
7174 {
7275 return Path . GetFileName ( hreflink ) ;
7376 }
74- catch ( Exception ex )
77+ catch ( Exception ex )
7578 {
7679 hLog . Error ( ex , "Error occurred during getting browser driver archive name" ) ;
7780 throw new WebDriverManagerException ( "Error occurred during getting browser driver archive name" , ex ) ;
@@ -129,7 +132,10 @@ public static void Unzip(WebDriverManagerConfig config)
129132 }
130133 }
131134 }
135+ isNew = true ;
132136 }
137+ else
138+ isNew = false ;
133139 }
134140 catch ( Exception ex )
135141 {
@@ -193,5 +199,37 @@ public static void UpdatePath(string variable)
193199 throw new WebDriverManagerException ( "Error occurred during updating PATH environment variable" , ex ) ;
194200 }
195201 }
202+
203+ /// <summary>
204+ /// Install application from file
205+ /// </summary>
206+ /// <param name="command">Installation command</param>
207+ public static void Install ( string command )
208+ {
209+ try
210+ {
211+ if ( File . Exists ( desticationFile ) && isNew )
212+ {
213+ ProcessStartInfo startInfo = new ProcessStartInfo
214+ {
215+ UseShellExecute = false ,
216+ WindowStyle = ProcessWindowStyle . Hidden ,
217+ FileName = desticationFile ,
218+ Arguments = command
219+ } ;
220+ Process process = new Process
221+ {
222+ StartInfo = startInfo
223+ } ;
224+ process . Start ( ) ;
225+ process . WaitForExit ( ) ;
226+ }
227+ }
228+ catch ( Exception ex )
229+ {
230+ hLog . Error ( ex , $ "Error occurred during application installation from file '{ desticationFile } ' using command '{ command } '") ;
231+ throw new WebDriverManagerException ( $ "Error occurred during application installation from file '{ desticationFile } ' using command '{ command } '", ex ) ;
232+ }
233+ }
196234 }
197235}
0 commit comments