Open ryuwfn opened 4 years ago
@spyoungtech I'm sorry to bother you, but could you give me some advice for my problem? thanks very much.
Could you provide the full traceback of the error? I suspect this is an issue with the appium driver not supporting that condition.
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.
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😊
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.
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.
@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
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 implementedBut 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.