有没有人在 Intranet 或启用“兼容性视图”的站点上调试(即 IE 不集中)时成功单击标签?EnableNativeEvents
我已经尝试了/ RequireWindowFocus
/EnablePersistentHover
我能想到的每一种组合(RequireWindowFocus
只需挂起浏览器),发送一个 js 片段来点击没有任何效果。
这里Process.Start
模拟失去焦点,例如在遇到断点时。
Windows 7 x64、IE 10 x86、WebDriver 2.33.0.0、IEDriverServer Win32 2.33.0
[Test]
public void CompatibilityViewLabel()
{
var options = new InternetExplorerOptions
{
EnableNativeEvents = false,
//RequireWindowFocus = true,
//EnablePersistentHover = true,
};
var driver = new InternetExplorerDriver(options);
driver.Navigate().GoToUrl("http://www.w3schools.com/tags/tryit.asp?filename=tryhtml_label");
var filter = (byte[])Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Internet Explorer\BrowserEmulation\ClearableListData").GetValue("UserFilter");
if (filter == null || !Encoding.Unicode.GetString(filter).Contains("w3schools.com"))
Assert.Fail("Click Compatibility View icon and retest.");
driver.SwitchTo().Frame("iframeResult");
var input = driver.FindElement(By.Id("male"));
var label = driver.FindElement(By.CssSelector("label[for='male']"));
Process.Start("cmd");
label.Click();
//driver.ExecuteScript("arguments[0].click()", label);
Assert.IsTrue(input.Selected);
}