Selenium - 初始化RemoteWebDriver时使用InternetExplorerOptions()

时间:2017-09-22 18:31:03

标签: java selenium selenium-iedriver

我试图让IE在通过Selenium网格初始化远程驱动程序时启动每个会话。此

    SqlCommand cmd = new SqlCommand(@"OPEN SYMMETRIC KEY KeyCodesKey DECRYPTION BY CERTIFICATE KeyCodes; 
    insert into keyfile(encrypted_key1, encrypted_key2, startingkeydate) values (EncryptByKey(Key_GUID('KeyCodesKey'),"+key1.ToString()+@"), EncryptByKey(Key_GUID('KeyCodesKey'), "+key2.ToString()+@"), CURRENT_TIMESTAMP)", cx);
    cx.Open(); 
    int success = cmd.ExecuteNonQuery();
    cx.Close()

无效,IE正在使用上一次测试中的cookie启动每个新测试,这会导致问题。我正在尝试实现这个

DesiredCapabilities caps = null;
caps = DesiredCapabilities.internetExplorer();
caps.setCapability(InternetExplorerDriver.IE_ENSURE_CLEAN_SESSION, true);
WebDriver driver = new RemoteWebDriver(new URL("http://10.10.22.126:5555/wd/hub"), caps);

here所述,但我无法弄清楚如何将其用作远程驱动程序而非本地驱动程序。谢谢!

1 个答案:

答案 0 :(得分:2)

您可以通过以下方式将选项设置为功能:

InternetExplorerOptions ieOptions = new InternetExplorerOptions()
         .destructivelyEnsureCleanSession();
capabilities.setCapability("se:ieOptions", ieOptions); 

InternetExplorerOptions类将此功能的常量定义为:

private final static String IE_OPTIONS = "se:ieOptions";