Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception transitioning to view in new context #53

Closed
jvervaec opened this issue Jul 8, 2015 · 5 comments
Closed

Exception transitioning to view in new context #53

jvervaec opened this issue Jul 8, 2015 · 5 comments
Assignees
Labels

Comments

@jvervaec
Copy link
Member

jvervaec commented Jul 8, 2015

Given
Synq.after(someElement::click)
.expect(transition().to(new View()).inNewContext())
.waitUpTo(10, ChronoUnit.SECONDS);

Throws
com.redhat.darcy.ui.DarcyException: Cannot find contexts of type: interface com.redhat.darcy.ui.api.FindableElementContext
at com.redhat.darcy.webdriver.internal.TargetedWebDriverParentContext.findByView(TargetedWebDriverParentContext.java:112)
at com.redhat.darcy.webdriver.internal.DelegatingWebContext.findByView(DelegatingWebContext.java:356)
at com.redhat.darcy.webdriver.WebDriverBrowser.lambda$29(WebDriverBrowser.java:317)
at com.redhat.darcy.webdriver.WebDriverBrowser$$Lambda$64/1060042118.get(Unknown Source)
at com.redhat.darcy.webdriver.WebDriverBrowser.attemptAndGet(WebDriverBrowser.java:342)
at com.redhat.darcy.webdriver.WebDriverBrowser.findByView(WebDriverBrowser.java:317)
at com.redhat.darcy.ui.By$ByView.find(By.java:520)
at com.redhat.darcy.web.internal.AbstractWebSelection.contextOfType(AbstractWebSelection.java:43)
at com.redhat.darcy.ui.api.ContextSelection.elementContext(ContextSelection.java:44)
at com.redhat.darcy.ui.internal.NewContextTransitionEvent.(NewContextTransitionEvent.java:36)
at com.redhat.darcy.ui.internal.SimpleTransitionEvent.inNewContext(SimpleTransitionEvent.java:57)
at com.redhat.darcy.ui.internal.SimpleTransitionEvent.inNewContext(SimpleTransitionEvent.java:47)

@alechenninger
Copy link
Member

This is due to Browser implementing ElementContext and Findable separately, but not FindableElementContext ... which is an unfortunate consequence of Java being Java. In ContextSelection, we need a type that is both Findable and a Context and so I need to create a separate type for this. So even though FindableElementContext is exactly equivalent to a type which implements Findable and ElementContext ... alas they are not castable in the eyes of Lord Java :).

Quick solution is to make Browsers and Frames implement FindableElementContext. But this is making me wonder if all Contexts should be considered Findable, so gimme a night to ponder on that.

@alechenninger
Copy link
Member

As a side note, different inheritance models (like the one that golang uses, which essentially is built in "duck typing" as opposed to explicit inheritance) don't have this problem, for the programming language designer in you :).

@alechenninger
Copy link
Member

I'm going to mess around with making all Contexts Findable and see how that goes. If I get lost down the rabbit hole I will do the quick but not as clean solution.

@alechenninger
Copy link
Member

Fixed in #54

Making all Contexts Findable definitely turned into a bit of a mess :). The webdriver module has a lot of implementations of Contexts to divide responsibilities and making all of them follow the contract of Findable is a little messy... for not much gain, since nothing ever uses that API in those implementations.

@alechenninger
Copy link
Member

The real fix was here btw darcy-framework/darcy-web@f3b0604

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants