硒IWebElement的属性和方法的一部分不适用于壁虎驱动程序

问题描述 投票:1回答:1

我以前的问题似乎沉默了,所以我想发布一个新问题,并删除我的旧问题。我正在用C#为网站编写测试,使用chrome驱动程序时代码运行完美,但是当我尝试使用geckodriver运行相同代码时,事情开始出错。

这里是日志信息

Error Message: Exception has been thrown by the target of an invocation.
Stacktrace:       
       at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
       at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
       at SeleniumExtras.PageObjects.WebElementProxy.Invoke(MethodInfo targetMethod, Object[] args)
    --- End of stack trace from previous location where exception was thrown ---
       at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
       at System.Reflection.DispatchProxyGenerator.Invoke(Object[] args)
       at generatedProxy_1.get_Displayed()
       at testAuto.Framework.Pages.Dashboard.DashboardPage.Logged_in() in "Path to code file":line 350

“代码文件路径”是代码所在文件的路径。

这里是指示错误的代码

public void Logged_in()
{           
    Assert.True(LogOut.Displayed);
}

查找代码的注销按钮

[FindsBy(How = How.CssSelector, Using = "a[href *= '/Private/Logout']")]
private IWebElement LogOut;

注销按钮的相应HTML部分

<ul>
  <li>
    <a href="/Private/Logout.aspx" target="_self">
      Log out
    </a>
  </li>
<ul>

我无法控制html部分,因此建议您使用此方法。此外,在执行该声明之前,我有代码等待页面完全加载。 geckodriver的版本是0.23.0更多信息:我试图解析样式值,但“ GetAttribute()”也陷入了类似的异常。这是日志文件

Error Message: Exception has been thrown by the target of an invocation.
Stacktrace:
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
   at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
   at SeleniumExtras.PageObjects.WebElementProxy.Invoke(MethodInfo targetMethod, Object[] args)
   --- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Reflection.DispatchProxyGenerator.Invoke(Object[] args)
   at generatedProxy_1.GetAttribute(String )
   at testAuto.Framework.Helper.IsElemVisible(IWebElement element) in "Path to code file":line 107
   at testAuto.Implementation.dashboardSpec.Verify_log_in() in "Path to code file":line 120
c# selenium-webdriver geckodriver
1个回答
0
投票

您对此有任何解决方案吗?

© www.soinside.com 2019 - 2024. All rights reserved.