gpt4 book ai didi

c# - 在此上下文中不支持获取透明代理的运行时类型

转载 作者:太空狗 更新时间:2023-10-29 21:26:46 24 4
gpt4 key购买 nike

我是 Selenium 的新手。在运行(调试)我的 selenium 测试(在 C# 中)时,我得到“在此上下文中不支持获取透明代理的运行时类型”,因此没有找到任何 Web 元素。

我使用“Selenium.Support.PageObjects”和 PageFactory 来定位和初始化网络元素。

谁能帮我解决这个问题?

下面是我的代码片段:

using OpenQA.Selenium;
using OpenQA.Selenium.Support.PageObjects;

namespace TestFramework
{
public class TestClass: TestBase
{

public TestClass(Driver driver): base(driver) { }

[FindsBy(How = How.XPath, Using = "//div[@class='modal-footer']/button[@title='Yes']")]
public IWebElement YesButton { get; set; }

[FindsBy(How = How.XPath, Using = "//div[@class='modal-footer']/button[@title='No']")]
public IWebElement NoButton { get; set; }


public void ClickYesButton()
{
YesButton.Click();
}
public void ClickNoButton(int timeout = ConfigMT.DefaultTimeout)
{
NoButton.Click();
}

}
}

TestBase 类是:

using OpenQA.Selenium;
using OpenQA.Selenium.Support.PageObjects;
using OpenQA.Selenium.Support.UI;

namespace TestFramework
{

public class TestBase
{

protected IWebDriver Driver { get; set; }

public Page(Driver driver)
{
this.Driver = driver;
PageFactory.InitElements(this.Driver, this);
}

}
}

最佳答案

根据这个答案底部的线程,这似乎是 VS 调试器中的错误。

提到的解决方法是转到 Debug>Options>Debugging>General 并单击复选框以Use the legacy C# and VB expressions evaluators

虽然这对我有用,但不幸的是,如果您正在尝试这样做,您仍然无法检查元素上的方法或属性。

https://social.msdn.microsoft.com/Forums/vstudio/en-US/7f4e2bca-91dd-4919-8cbe-0adff2021ce8/debugging-transparent-proxy-objects-not-working-anymore-in-visual-studio-2015?forum=vsdebug

关于c# - 在此上下文中不支持获取透明代理的运行时类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37404978/

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