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

conditions.element_contains_value((MobileBy.IOS_PREDICATE, "name = 'login'"), text_='login')(context.behave_driver) Exception: Message: Method is not implemented #80

Open
ryuwfn opened this issue May 26, 2020 · 5 comments

Comments

@ryuwfn
Copy link

ryuwfn commented May 26, 2020

Hi, all,
I'm a QA, When I find your the project, I so surprise, so good project.
I am using python+appium+behave, And when I use the Class:
conditions.element_contains_value, like this:
conditions.element_contains_value((MobileBy.IOS_PREDICATE, "name = 'login'"), text_='login')(context.behave_driver)
I get an Exception:
selenium.common.exceptions.WebDriverException: Message: Method is not implemented

But when I use class: conditions.element_contains_text, like this:
conditions.element_contains_text((MobileBy.IOS_PREDICATE, "name = 'login'"), text_='login')(context.behave_driver)
It's OK.

So Why? And how can I use the Class: conditions.element_contains_value?
Thanks a lot.

@ryuwfn ryuwfn changed the title conditions.element_contains_text((MobileBy.IOS_PREDICATE, "name = 'login'"), text_='login')(context.behave_driver) Exception: Message: Method is not implemented conditions.element_contains_value((MobileBy.IOS_PREDICATE, "name = 'login'"), text_='login')(context.behave_driver) Exception: Message: Method is not implemented May 26, 2020
@ryuwfn
Copy link
Author

ryuwfn commented May 27, 2020

@spyoungtech I'm sorry to bother you, but could you give me some advice for my problem?
thanks very much.

@spyoungtech
Copy link
Owner

Could you provide the full traceback of the error? I suspect this is an issue with the appium driver not supporting that condition.

@ryuwfn
Copy link
Author

ryuwfn commented May 28, 2020

I use your import behave_webdriver as my project driver: context.behave_driver = behave_webdriver.Remote('http://127.0.0.1:4723/wd/hub', desired_caps), but I'm working on the mobile iOS APP UI automation. I think your Library to serve for Web and API automation, is it right?

I know I will meet some problems, like this. But I find your Library make the behave(BDD) so simple, so surprise idea. So I want use your Library for my mobile APP UI automation.

for the issue:
Today I add breakpoint and debug the code, and I find code goto below screenshot, when I add the line: self._w3c = False, the code conditions.element_contains_value((MobileBy.IOS_PREDICATE, "name = 'login'"), text_='login')(context.behave_driver) will be work.
image

My understanding is: driver think my appium-mobile support w3c(Is it Web standard?) , so execute_script("return (%s).apply(null, arguments);" % getAttribute_js, self, name), but appium-mobile device can't run the js, So pop Exception: Message: Method is not implemented. is it right?

And final question: I don't want change the selenium Library, so can I tell driver my element._w3c = False in my script? where I can set the element._w3c = False in my script?

a long comment, I'm sorry to bother you, Thanks very much😊

@spyoungtech
Copy link
Owner

spyoungtech commented May 28, 2020

I see. I think your understanding is correct. The driver you are using is not reporting as a w3c compliant driver (some browsers, for example, are not w3c compliant, either!). It's true that this library was written with browser automation in mind, but should be usable anywhere selenium is used.

My guess is that the element's ._w3c attribute actually comes from whether or not the driver used to fetch that element has .w3c attribute True. You could potentially subclass the behave driver to override its own self.w3c value.

See relevant selenium source

To make sure this .w3c attribute is always True you could subclass the driver and make a special property for this.

class MyRemoteDriver(behave_webdriver.Remote):
    @property
    def w3c(self):
        return True

    @w3c.setter
    def w3c(self, new_value):
        # don't let w3c be reassigned to a new value
        return

...

context.behave_driver = MyRemoteDriver('http://127.0.0.1:4723/wd/hub', desired_caps)

Part of the potential danger here is that, evidently, this method you want to use relies on w3c compliance for correct behavior in at least some case. If you're okay with the possibility of unwanted behavior, this seems reasonable. This may also cause odd behavior or errors in other places where methods need to know whether the driver is w3c compliant.

Hope this helps.

@ryuwfn
Copy link
Author

ryuwfn commented May 29, 2020

@spyoungtech Thanks, You are awesome. I see. I will try to use your advice.
By the way, How do you make the code has color in github comment? I haven't searched answer from Internet 😶
thx

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

No branches or pull requests

2 participants