question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[C#]Cant't get wrappedDriver from an element using PageFactory

See original GitHub issue

When elements are located using PageFactory there seems to be an issue with casting element to IWrapsDriver, although it works pretty good with elements found by FindElement(s).

In my case I’m trying to get wrappedDriver inside following extension method
public static bool SelectDropdownOptionByText(this IWebElement element, string optionText).

Here to be more specific: private static IWebDriver GetDriverFromElement(IWebElement element) { return ((IWrapsDriver)element).WrappedDriver; }

Error says:

Additional information: Unable to cast transparent proxy to type ‘OpenQA.Selenium.Internal.IWrapsDriver’.

BTW:Is this NOT implemented or as designed?

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

5reactions
robertfaheymoonpigcommented, Mar 9, 2016

It’s useful for IWebElement extension methods

E.g.

public static IWebElement WaitForElement(this IWebElement element)
        {
            var driver = ((IWrapsDriver)element).WrappedDriver;

            new WebDriverWait(driver, TimeSpan.FromSeconds(60)).Until((d) => element.Displayed);

            return element;
        }
1reaction
jimevanscommented, Jan 19, 2016

The proxy object created by the .NET PageFactory implementation does not proxy the IWrapsDriver interface. It’s unclear how that interface would be useful from a page object, which should have a reference to the driver anyway.

Read more comments on GitHub >

github_iconTop Results From Across the Web

[C#]Cant't get wrappedDriver from an element using ... - GitHub
When elements are located using PageFactory there seems to be an issue with casting element to IWrapsDriver, although it works pretty good ...
Read more >
Getting WebDriver from IWebElement - Stack Overflow
I can't cast my element to RemoteWebElement, as I'm using PageFactory to initialize page with IWebElements and it is of type OpenQA.Selenium.
Read more >
Page Object Model (POM) With Page Factory | Selenium Tutorial
First, we need to find the web elements by annotation @FindBy in page classes. Then initialize the elements using initElements() when ...
Read more >
Selenium: java/CHANGELOG | Fossies
As a special service "Fossies" has tried to format the requested text file into HTML format (style: standard) with prefixed line numbers.
Read more >
Selenium Java Changelog - GitHub
[grid] Grid is ready when Nodes are up and have availability. ... if the default isn't there * Pass Options.ime() through to the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found