Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

obtaining the runtime type of a transparent proxy is not supported in this context

Tags:

c#

selenium

I am new to selenium. While running (debugging) my selenium tests (in C#), I am getting "obtaining the runtime type of a transparent proxy is not supported in this context" and due to this none of the web elements are found.

I have used "Selenium.Support.PageObjects" & PageFactory to locate and initialize web elemements.

Can anyone help me out from this?

Below is snippet of my code:

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();
        }

    }
}

And TestBase class is:

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);
    }

}
}
like image 540
Dalip Kumar Avatar asked May 24 '16 05:05

Dalip Kumar


1 Answers

According to this thread at the bottom of this answer, this appears to be a bug in the VS debugger.

A workaround mentioned is to go to Debug>Options>Debugging>General and click the checkbox to Use the legacy C# and VB expressions evaluators

While this worked for me, you still won't be able to check methods or properties on the element if that's what you're trying to do unfortunately.

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

like image 109
mrfreester Avatar answered Oct 26 '22 18:10

mrfreester