serhatbolsu / robotframework-appiumlibrary

AppiumLibrary is an appium testing library for RobotFramework
Apache License 2.0
403 stars 291 forks source link

Use of tap in appiumlibrary #237

Closed aryalakshmi closed 2 years ago

aryalakshmi commented 5 years ago

Hi,

I am unable to use Tap in appiumlibrary for webelements in robot framework. Can you please suggest some examples on how to use it.

Thanks, Arya

aryalakshmi commented 5 years ago

I am using appium 1.8.2-beta. i get below error when using Tap code: Tap selector

value":"-[NSNull floatValue]: unrecognized selector sent to instance 0x1d583d9b0\n\n(\n\t0 CoreFoundation 0x00000001a589beb8 + 252\n\t1 libobjc.A.dylib 0x00000001a4a6da40 objc_exception_throw + 56\n\t2 CoreFoundation 0x00000001a57b4d04 + 0\n\t3 CoreFoundation 0x00000001a58a17b8 + 1412\n\t4 CoreFoundation 0x00000001a58a345c _CF_forwarding_prep_0 + 92\n\t5 WebDriverAgentLib 0x000000010226f740 -[FBAppiumGestureItem coordinatesWithOptions:error:] + 1056\n\t6 WebDriverAgentLib 0x000000010226ee64 -[FBAppiumGestureItem initWithActionItem:application:atPosition:offset:error:] + 472\n\t7 WebDriverAgentLib 0x0000000102271e94 -[FBAppiumActionsSynthesizer eventPathsWithAction:error:] + 1328\n\t8 WebDriverAgentLib 0x00000001022729c8 -[FBAppiumActionsSynthesizer synthesizeWithError:] + 984\n\t9 ...

[MJSONWP] Encountered internal error running command: Error: An unknown server-side error occurred while processing the command

aryalakshmi commented 5 years ago

I have written the below code sinppet to execute a javascript and then call it inside the robotframework. from appium import webdriver def test_tap(app, action): print "Hi" app.execute_script(action)

app is the appiumsession id and action is document.querySelectorAll("element")[0].tap();

The code returns error unicode' object has no attribute execute_script. Has anyone seen this before?

yst8493182 commented 5 years ago

The IOS device you should be testing? You can modify robotframework-appiumlibrary source,Add method tap_for_ios to _touch.py($Python Path/site-packages/AppiumLibrary/keywords/_touch.py)

document:

    def tap_for_ios(self,locator,x_offset=0, y_offset=0, count=1)):
        el = self._element_find(locator, True, True)
        params=dict()
        params["x"]= float(x_offset)
        params["y"]= float(y_offset)
        params["element"]=el.id
        application = self._current_application()
        application.execute_script("mobile: tap", params);
aryalakshmi commented 5 years ago

thanks a lot. will this work for webview also? i assume we need to give coordinates for webview click also right?

serhatbolsu commented 5 years ago

@yst8493182 if this applies to all , do you have a pull request ?

serhatbolsu commented 2 years ago

Please check #363 for new tap implementation