Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/variables/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 无法使用Selenium C选择元素#_C#_Selenium_Selenium Webdriver - Fatal编程技术网

C# 无法使用Selenium C选择元素#

C# 无法使用Selenium C选择元素#,c#,selenium,selenium-webdriver,C#,Selenium,Selenium Webdriver,对于突出显示的文本(这是一个按钮),我无法通过XPath、CssSelector、ClassName等找到元素。具有以下代码: driverChrome.SwitchTo().DefaultContent(); driverChrome.SwitchTo().Frame(0); IWebElement optionsGear = driverChrome.FindElement(By.CssSelector("html body div#app.d2l-typography div#root-w

对于突出显示的文本(这是一个按钮),我无法通过XPath、CssSelector、ClassName等找到元素。具有以下代码:

driverChrome.SwitchTo().DefaultContent();
driverChrome.SwitchTo().Frame(0);
IWebElement optionsGear = driverChrome.FindElement(By.CssSelector("html body div#app.d2l-typography div#root-wrapper div.main-wrapper div.root div.main div.navigation-container div.nav-header div.options-header div.overall-options-container div.options-dropdown button.button.overall-options"));
optionsGear.Click();

有什么建议或想法吗?

发现隐式等待解决了问题:driverChrome.Manage().Timeouts().ImplicitWait=TimeSpan.FromSeconds(10)

这可能不是页面中唯一的iframe吗?尝试通过id而不是索引来切换它;driverChrome.SwitchTo().Frame(左窗格);但是得到同样的结果。但是,我可以在浏览器控制台中正确执行代码:document.getElementsByClassName(“总体选项”)[0]。单击()以便。。。如果您尝试使用
driverChrome.SwitchTo().Frame(“iFrameResizer0”)?不,不是。