How to long press on text in scrollview

can any one help me to find solution,how to long press on text in iOS simulator and after long press on text how to access web view elements and select copy selected

Here I am unable to get the locations for text
please find below screen shots

try:

   // Java
    public boolean longTapElement_XCTest(MobileElement el) {
        try {
            JavascriptExecutor js = (JavascriptExecutor) driver;
            HashMap<String, String> tapObject = new HashMap<String, String>();
            tapObject.put("element", el.getId());
            js.executeScript("mobile:touchAndHold", tapObject);
            return true;
        } catch (Exception e) {
            return false;
        }
    }
1 Like

Thank you @Aleksei

after long press on text I have to select copy option but I am unable to inspect copy elements through Appium inspector.please help me how to select copy option

@nandini you can’t. you can use 2 workarounds (as i know):

  1. add image recognition. minus is you need to specify images with each resolution you use
  2. tap relative to longTapped. also can work only with specified screen resolution and will be hard when it changes

Thank you @Aleksei. can you please provide me sample code for add image recognition. minus is you need to specify images with each resolution you use…

@nandini it is long story and many code. i am using openCV with java-client api.