2017-12-18 42 views
0

以前は、ドライバを別のユーザーとして実行するために、次のコードを使用していました。 DesiredCapabilities is obsoleteと私はこの作業を保つために何をすべきかわからない: DesiredCapabilitiesは廃止されました

public static IWebDriver RunIEAsDifferentUser(string User,string Password) 
    { 

     var capabilitiesInternet = DesiredCapabilities.InternetExplorer(); 
     capabilitiesInternet.SetCapability("ignoreProtectedModeSettings", true); 
     capabilitiesInternet.SetCapability("EnsureCleanSession ", true); 
     RunAs("C:\\Exlporer/IEDriverServer.exe", User, Password); 
     _webdriverIE = new RemoteWebDriver(new Uri("http://localhost:5555/"), capabilitiesInternet, TimeSpan.FromSeconds(300)); 
     return _webdriverIE; 

    } 
    public static void RunAs(string path, string username, string password) 
    { 
     ProcessStartInfo myProcess = new ProcessStartInfo(path); 
     myProcess.UserName = username; 
     myProcess.Password = MakeSecureString(password); 
     myProcess.UseShellExecute = false; 
     myProcess.LoadUserProfile = true; 
     myProcess.Verb = "runas"; 
     myProcess.Domain = "DOM001"; 
     Process.Start(myProcess); 
    } 

    public static SecureString MakeSecureString(string text) 
    { 
     SecureString secure = new SecureString(); 
     foreach (char c in text) 
     { 
      secure.AppendChar(c); 
     } 

     return secure; 
    } 

は、私は警告を取得していますということです。

問題のある行は:_webdriverIE = new RemoteWebDriver(new Uri("http://localhost:5555/"), capabilitiesInternet, TimeSpan.FromSeconds(300)); InternetExplorerOptions caps = new InternetExplorerOptions();に変更しようとしました。 残念ながら、RemoteWebDriverは現在Icapabilitiesしか受け付けていません。

答えて

3

溶液をInternetExplorerOptionsクラスのToCapabilites方法を使用し、Javaリモートサーバ又はグリッドで使用する場合、警告メッセージ

の端部にあります。

InternetExplorerOptions options = new InternetExplorerOptions(); 
options.AddAdditionalCapability("ignoreProtectedModeSettings", true); 
options.AddAdditionalCapability("EnsureCleanSession", true); 
_webdriverIE = new RemoteWebDriver(new Uri("http://localhost:5555/"), options.ToCapabilities(), TimeSpan.FromSeconds(300)); 
+0

ちょっと感謝しています。 :-) –

関連する問題