You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Get wrong browser object for non top view in hierarchy #132
class AirgunBrowser(Browser):
def wait_for_element(...):
return super(AirgunBrowser, self).wait_for_element(...)
Then we do:
class MyView(View):
def is_displayed(self):
return self.browser.wait_for_element(...)
class MyOtherView(View):
class MyTab(Tab):
view = MyView()
In result when we call view we have wrong browser object type in its is_displayed method: self.browser == BrowserParentWrapper not AirgunBrowser that will get us to super(type, obj): obj must be an instance or subtype of type exception in wait_for_element method
So basically we want to extend wait_for_element with one extra argument. To avoid copy pasting entire method body we just call super() and extend result with our stuff.
For top-level views calls to wait_for_element() via self.browser.wait_for_element() work ok, but for nested structure like the one @oshtaier provided - it fails on super() call (obj must be an instance or subtype of type), as self.browser for all nested views is BrowserParentWrapper, not the Browser itself.
Using it through self.root_browser.wait_for_element() works, but that doesn't sound like a right option to use root browser for every overwritten method to me.
Is that expected behavior and we aren't supposed to extend any browser's method or that's an issue with BrowserParentWrapper proxy implementation?
this change may necessitate a structural shift for wrapping browsers and locator using objects to sort out,
its possible we cant get around it before the new year
please also show the use-case you want to implement, due the nature of the issue (structural) it may be easier in the short term to find a different way to implement the use-case simply to avoid having to sort out the underlying issue in a timely manner
@RonnyPfannschmidt Perhaps a custom super wrapper that "unwraps" the underlying browser from its wrapping would do. Instead of super(MyBrowser, self) one would call something like self.super(MyBrowser) and it would:
Figure the unwrapped object
call super(...) with it
Rewrap it again with the current wrapper.
And then the use would be like with normal super.
Reacted by Mike Shriver, Eugene Zapolsky and Dmitry Misharov
Actually not. The base Browser was designed as an immutable set of operations which other components rely on.
If specific things are needed, you can:
add new methods that implement specific things in your browser subclass
request a backwards-compatible change in WT browser method (add a parameter or whatever).
use an existing hook in plugin class
add a new hook into the Plugin class and add the hook calls in the particular browser methods, that way extensions altering the behaviour of the browser can be done without harming vanilla browser's behaviour.
Reacted by Mike Shriver, Eugene Zapolsky, Dmitry Misharov and Milan Falešník
Activity
abalakh commentedon Dec 18, 2018
So basically we want to extend
wait_for_elementwith one extra argument. To avoid copy pasting entire method body we just callsuper()and extend result with our stuff.For top-level views calls to wait_for_element() via
self.browser.wait_for_element()work ok, but for nested structure like the one @oshtaier provided - it fails onsuper()call (obj must be an instance or subtype of type), asself.browserfor all nested views isBrowserParentWrapper, not theBrowseritself.Using it through
self.root_browser.wait_for_element()works, but that doesn't sound like a right option to use root browser for every overwritten method to me.Is that expected behavior and we aren't supposed to extend any browser's method or that's an issue with
BrowserParentWrapperproxy implementation?RonnyPfannschmidt commentedon Dec 18, 2018
widgetastic.core/src/widgetastic/browser.py
Lines 833 to 853 in f39a87f
RonnyPfannschmidt commentedon Dec 18, 2018
this change may necessitate a structural shift for wrapping browsers and locator using objects to sort out,
its possible we cant get around it before the new year
right now i don't have a idea for a solution
RonnyPfannschmidt commentedon Dec 18, 2018
please also show the use-case you want to implement, due the nature of the issue (structural) it may be easier in the short term to find a different way to implement the use-case simply to avoid having to sort out the underlying issue in a timely manner
oshtaier commentedon Dec 18, 2018
@RonnyPfannschmidt actually that was real use case.
I did it here:
https://github.com/SatelliteQE/airgun/pull/263/files#diff-b5de464875aa71a973dee2e139a855c9R130
but teammates said proper comment that it will be necessary to fix all (>50) places where we have not top level view.
mfalesni commentedon Dec 21, 2018
@RonnyPfannschmidt Perhaps a custom super wrapper that "unwraps" the underlying browser from its wrapping would do. Instead of
super(MyBrowser, self)one would call something likeself.super(MyBrowser)and it would:super(...)with itAnd then the use would be like with normal super.
mfalesni commentedon Jan 3, 2019
Actually not. The base
Browserwas designed as an immutable set of operations which other components rely on.If specific things are needed, you can: