C# Click()方法不支持IE上使用selenium的.Net应用程序

C# Click()方法不支持IE上使用selenium的.Net应用程序,c#,selenium-webdriver,C#,Selenium Webdriver,源代码: <div class="dropdown-toggle" id="clientBtnDropDown" data-toggle="dropdown" aria-expanded="false" role="button" aria-haspopup="true" onclick="ga(&quot;send&quot;, {&quot;hitType&quot; : &quot;event&quot;,&quot;event

源代码:

<div class="dropdown-toggle" id="clientBtnDropDown" data-toggle="dropdown" aria-expanded="false" role="button" aria-haspopup="true" onclick="ga(&quot;send&quot;, {&quot;hitType&quot; : &quot;event&quot;,&quot;eventCategory&quot; : &quot;Client button&quot;,&quot;eventAction&quot; : &quot;click&quot;,&quot;eventLabel&quot; : &quot;Client access&quot;});ga(&quot;t2.send&quot;, {&quot;hitType&quot; : &quot;event&quot;,&quot;eventCategory&quot; : &quot;Client button&quot;,&quot;eventAction&quot; : &quot;click&quot;,&quot;eventLabel&quot; : &quot;Client access&quot;});"><a href="#" class="btn btn-primary">Client access</a></div>

工作流程:当我点击链接按钮(客户端访问)时,它会弹出一个窗口,这是一个登录窗口(框架),我们可以在其中输入用户id和密码

但每当我尝试通过selenium执行时,我都会收到错误消息,单击按钮

我写的代码:

driver.findElement(By.Id(“clientBtnDropDown”)。单击()

在这里,它抛出的错误类似于不支持单击方法


我是否做错了什么,或者是否有其他方法?

您需要
driver.FindElement
。注意“Find”中的大写字母。

我猜Id是DIV标签。其中,实际锚定标记位于Div标记内。我建议您使用Xpath或CSS选择器并直接查找“Client access”元素

driver.FindElement(By.CssSelector(.btn.btn-primary)).Click();

运气不好,如果我使用CSSlocator,则会出现错误“WebDriver.dll中发生类型为“OpenQA.Selenium.ElementNotVisibleException”的未处理异常”。我尝试了两种方法driver.FindElement(By.CssSelector(“.btn.btn primary”)。单击();driver.FindElement(By.CssSelector(“div#clientBtnDropDown>a”)。单击();好的,试试Xpath,但直接在你的按钮上,建议多个项目。我正试图为你找到解决办法。您可能已经尝试了By.LinkText或By.PartialText。如果没有,请尝试,因为它只是一个锚定标签。在执行所有这些操作之前,请确保元素在页面上可见并已启用