2

有没有人在 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);
}
4

3 回答 3

0

该页面格式错误,它有两个正文元素,您要查找的元素位于第二个正文中。尝试使用不同的页面。

于 2013-07-19T10:41:05.030 回答
0

你应该尝试把:

WebDriverWait wait = new WebDriverWait(driver, new TimeSpan(0,0,5));
wait.Until(drv => drv.FindElement(By.Id("male"));

在 label.click() 之前;

于 2013-07-22T08:54:56.447 回答
0

在https://code.google.com/p/selenium/issues/detail?id=5977提交了一个错误,在http://jsbin.com/ijaqog提交了示例页面

于 2013-07-23T09:58:52.500 回答