gpt4 book ai didi

c# - Selenium WebDriver 在兼容模式下单击带有 InternetExplorerDriver 的标签

转载 作者:太空宇宙 更新时间:2023-11-03 16:10:35 26 4
gpt4 key购买 nike

有没有人在 Intranet 或启用“兼容性 View ”的站点上调试时(即 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);
}

最佳答案

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

关于c# - Selenium WebDriver 在兼容模式下单击带有 InternetExplorerDriver 的标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17613205/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com