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

Python Support? #87

Open
kiebak3r opened this issue Jun 29, 2023 · 13 comments
Open

Python Support? #87

kiebak3r opened this issue Jun 29, 2023 · 13 comments

Comments

@kiebak3r
Copy link

Does this currently support python?

Integrated into my test suite & cannot get it to find the element, it times out..

I can see JS uses driver.findElement where as the python equivelant is driver.find_element

Is python supported or am i doing something wrong?!

Any help would be great.

Log:
--> POST /session/eea7fcc4-e676-4209-9c24-dbbd1eb3a4da/element
[HTTP] {"using":"css selector","value":"[id="com.yourdolphin.easyreader:id/intro_welcome_skip_button"]"}
[debug] [AndroidUiautomator2Driver@9e45 (eea7fcc4)] Calling AppiumDriver.findElement() with args: ["css selector","[id="com.yourdolphin.easyreader:id/intro_welcome_skip_button"]","eea7fcc4-e676-4209-9c24-dbbd1eb3a4da"]
[AppiumDriver@0a01] Plugins which can handle cmd 'findElement': element-wait
[AppiumDriver@0a01] Plugin element-wait is now handling cmd 'findElement'
| Waiting to find element with css selector strategy for [id="com.yourdolphin.easyreader:id/intro_welcome_skip_button"] selector[HTTP] --> GET /session/bf4942bf-5ca8-4b62-aed4-fafeadf612c3/timeouts
[HTTP] {}
[debug] [AppiumDriver@0a01] Encountered internal error running command: NoSuchDriverError: A session is either terminated or not started
[debug] [AppiumDriver@0a01] at asyncHandler (C:\Users\kieba\AppData\Roaming\npm\node_modules\appium\node_modules@appium\base-driver\lib\protocol\protocol.js:315:15)
[debug] [AppiumDriver@0a01] at C:\Users\kieba\AppData\Roaming\npm\node_modules\appium\node_modules@appium\base-driver\lib\protocol\protocol.js:518:15
[debug] [AppiumDriver@0a01] at Layer.handle [as handle_request] (C:\Users\kieba\AppData\Roaming\npm\node_modules\appium\node_modules\express\lib\router\layer.js:95:5)
[debug] [AppiumDriver@0a01] at next (C:\Users\kieba\AppData\Roaming\npm\node_modules\appium\node_modules\express\lib\router\route.js:144:13)
[debug] [AppiumDriver@0a01] at Route.dispatch (C:\Users\kieba\AppData\Roaming\npm\node_modules\appium\node_modules\express\lib\router\route.js:114:3)
[debug] [AppiumDriver@0a01] at Layer.handle [as handle_request] (C:\Users\kieba\AppData\Roaming\npm\node_modules\appium\node_modules\express\lib\router\layer.js:95:5)
[debug] [AppiumDriver@0a01] at C:\Users\kieba\AppData\Roaming\npm\node_modules\appium\node_modules\express\lib\router\index.js:284:15
[debug] [AppiumDriver@0a01] at param (C:\Users\kieba\AppData\Roaming\npm\node_modules\appium\node_modules\express\lib\router\index.js:365:14)
[debug] [AppiumDriver@0a01] at param (C:\Users\kieba\AppData\Roaming\npm\node_modules\appium\node_modules\express\lib\router\index.js:376:14)
[debug] [AppiumDriver@0a01] at Function.process_params (C:\Users\kieba\AppData\Roaming\npm\node_modules\appium\node_modules\express\lib\router\index.js:421:3)
[debug] [AppiumDriver@0a01] at next (C:\Users\kieba\AppData\Roaming\npm\node_modules\appium\node_modules\express\lib\router\index.js:280:10)
[debug] [AppiumDriver@0a01] at logger (C:\Users\kieba\AppData\Roaming\npm\node_modules\appium\node_modules\morgan\index.js:144:5)
[debug] [AppiumDriver@0a01] at Layer.handle [as handle_request] (C:\Users\kieba\AppData\Roaming\npm\node_modules\appium\node_modules\express\lib\router\layer.js:95:5)
[debug] [AppiumDriver@0a01] at trim_prefix (C:\Users\kieba\AppData\Roaming\npm\node_modules\appium\node_modules\express\lib\router\index.js:328:13)
[debug] [AppiumDriver@0a01] at C:\Users\kieba\AppData\Roaming\npm\node_modules\appium\node_modules\express\lib\router\index.js:286:9
[debug] [AppiumDriver@0a01] at Function.process_params (C:\Users\kieba\AppData\Roaming\npm\node_modules\appium\node_modules\express\lib\router\index.js:346:12)
[debug] [AppiumDriver@0a01] at next (C:\Users\kieba\AppData\Roaming\npm\node_modules\appium\node_modules\express\lib\router\index.js:280:10)
[debug] [AppiumDriver@0a01] at jsonParser (C:\Users\kieba\AppData\Roaming\npm\node_modules\appium\node_modules\body-parser\lib\types\json.js:113:7)
[debug] [AppiumDriver@0a01] at Layer.handle [as handle_request] (C:\Users\kieba\AppData\Roaming\npm\node_modules\appium\node_modules\express\lib\router\layer.js:95:5)
[debug] [AppiumDriver@0a01] at trim_prefix (C:\Users\kieba\AppData\Roaming\npm\node_modules\appium\node_modules\express\lib\router\index.js:328:13)
[debug] [AppiumDriver@0a01] at C:\Users\kieba\AppData\Roaming\npm\node_modules\appium\node_modules\express\lib\router\index.js:286:9
[debug] [AppiumDriver@0a01] at Function.process_params (C:\Users\kieba\AppData\Roaming\npm\node_modules\appium\node_modules\express\lib\router\index.js:346:12)
[HTTP] <-- GET /session/bf4942bf-5ca8-4b62-aed4-fafeadf612c3/timeouts 404 26 ms - 3231
[HTTP]
× Waiting to find element with css selector strategy for [id="com.yourdolphin.easyreader:id/intro_welcome_skip_button"] selector
[AppiumDriver@0a01] Command 'findElement' was not handled by the following behaviours or plugins, even though they were registered to handle it: ["default"]. The command was handled by these: ["element-wait"].
[debug] [AndroidUiautomator2Driver@9e45 (eea7fcc4)] Encountered internal error running command: NoSuchElementError: Time out after waiting for element [id="com.yourdolphin.easyreader:id/intro_welcome_skip_button"] for 10000 ms
[debug] [AndroidUiautomator2Driver@9e45 (eea7fcc4)] at C:\Users\kieba.appium\node_modules\appium-wait-plugin\lib\element.js:73:23
[debug] [AndroidUiautomator2Driver@9e45 (eea7fcc4)] at Generator.throw ()
[debug] [AndroidUiautomator2Driver@9e45 (eea7fcc4)] at rejected (C:\Users\kieba.appium\node_modules\appium-wait-plugin\lib\element.js:6:65)
[HTTP] <-- POST /session/eea7fcc4-e676-4209-9c24-dbbd1eb3a4da/element 404 10020 ms - 540

@saikrishna321
Copy link
Member

@kiebak3r

Does this currently support python? Yes. It's client agnostic. As the implementation is done on server side.

For some reason, your session gets terminated.

[debug] [AppiumDriver@0a01] Encountered internal error running command: NoSuchDriverError: A session is either terminated or not started

I also see the element is not present after the entire timeout is completed

× Waiting to find element with css selector strategy for [id="com.yourdolphin.easyreader:id/intro_welcome_skip_button"] selector
[AppiumDriver@0a01] Command 'findElement' was not handled by the following behaviours or plugins, even though they were registered to handle it: ["default"]. The command was handled by these: ["element-wait"].
[debug] [AndroidUiautomator2Driver@9e45 (eea7fcc4)] Encountered internal error running command: NoSuchElementError: Time out after waiting for element [id="com.yourdolphin.easyreader:id/intro_welcome_skip_button"] for 10000 ms
[debug] [AndroidUiautomator2Driver@9e45 (eea7fcc4)] at C:\Users\kieba.appium\node_modules\appium-wait-plugin\lib\element.js:73:23
[debug] [AndroidUiautomator2Driver@9e45 (eea7fcc4)] at Generator.throw ()
[debug] [AndroidUiautomator2Driver@9e45 (eea7fcc4)] at rejected (C:\Users\kieba.appium\node_modules\appium-wait-plugin\lib\element.js:6:65)
[HTTP] <-- POST /session/eea7fcc4-e676-4209-9c24-dbbd1eb3a4da/element 404 10020 ms - 540

@kiebak3r
Copy link
Author

kiebak3r commented Jul 2, 2023

Do you have any recommendations on how to proceed?

If I remove the plug-in and add say a 10 second sleep timer, then the element is located and interacted with, then re adding the plug in and removing the sleep timer I get this error.

Thanks for your previous comment and any further advice would be great

@saikrishna321
Copy link
Member

Can you share the code snippet and also fulllogs as gist please @kiebak3r

@kiebak3r
Copy link
Author

kiebak3r commented Jul 2, 2023

@saikrishna321
Copy link
Member

saikrishna321 commented Jul 2, 2023

Thanks @kiebak3r will look into it!

I notice client is sending css-selector and server is converting the request to android-matcher.

@KazuCocoa any idea?

@KazuCocoa
Copy link

What's the client version? Usually Appium Python client won't do the conversion. It is selenium client's behavior.
Potentially Selenium client changed some method names so appium client need to update as same

@kiebak3r
Copy link
Author

kiebak3r commented Jul 2, 2023

Currently running;

Appium-Python-Client - 2.7.1
selenium - 4.1.5
Appium Server - Appium v2.0.0-rc.3
Driver - [email protected]

@saikrishna321
Copy link
Member

saikrishna321 commented Jul 3, 2023

@KazuCocoa In this line https://gist.github.com/kiebak3r/b918fc5b67c9208a5c12dd0019ef9b1f#file-without-plugin-txt-L174 the client is first sending with css-selector as locator strategy later UI2Driver is sending 'android uiautomator' as strategy to server - https://gist.github.com/kiebak3r/b918fc5b67c9208a5c12dd0019ef9b1f#file-without-plugin-txt-L178

I see UIA2 is doing this parsing - https://github.com/appium/appium-uiautomator2-driver/blob/master/lib/css-converter.js#L293-L308 Do you know why we decided this approach?

@KazuCocoa
Copy link

Python client sends css selector only when the find_element specifies it as https://github.com/appium/python-client/blob/fb8415edf11e5f7302e24df5c3354c0c69fe8776/appium/webdriver/webdriver.py#L379-L409
The id to css selector conversion is in the parent Selenium Python client behavior, appium client override them.

Do you know why we decided this approach?

We haven't provided CSS selector (and had no plant to support it in the native implementation side). Instead, to support the syntax, Dan added the conversion in the JS layer to use existing method in the native layer but to support CSS syntax only

@KazuCocoa
Copy link

Hm, latest https://github.com/SeleniumHQ/selenium/blob/b94159e08c5d45130ffa4cbe290d77fd6290a2d1/py/selenium/webdriver/remote/webdriver.py#L713 looks not break the existing behavior. I need to run the python client to see the behavior

@kiebak3r
Copy link
Author

kiebak3r commented Jul 5, 2023

Any further update on this?

I will mention I did some more testing & noticed that the structure used in the original gist continues to not work -
https://gist.github.com/kiebak3r/b918fc5b67c9208a5c12dd0019ef9b1f

But if I change the structure to use unit test framework then it works??
https://gist.github.com/kiebak3r/7268e6b9c2e061e02d7c0521eaffb96d

Any indication to why this might be the case?!

@saikrishna321
Copy link
Member

I'm not a python person. @KazuCocoa can help

@KazuCocoa
Copy link

I haven't figured this out yet but maybe python's resolving dependency stuff...

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

3 participants