我是硒的新手.在运行(调试)我的selenium测试(在C#中)时,我得到“在此上下文中不支持获取透明代理的运行时类型”,因此没有找到任何Web元素.
我使用过“Selenium.Support.PageObjects”& PageFactory用于定位和初始化Web元素.
任何人都可以帮助我吗?
以下是我的代码片段:
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); } } }