Does uploadFileWithDragAndDrop work on phones?

Hi,

I have successfully used uploadFileWithDragAndDrop while testing an application via a web browser (Chrome & FireFox), for example …

def filePath = GlobalVariable.UploadFilePathvar + ‘one.jpg’

WebUI.uploadFileWithDragAndDrop(findTestObject(‘Object Repository/Page_Camden QA (4)/span_Browse. or drag’), filePath)

When I use TestOps and try and run the test on an phone rather than a browser (I’ve tried iphone, samsung,goolge) it fails …

Reason:
com.kms.katalon.core.exception.StepFailedException: Unable to click on object ‘Object Repository/Page_Camden QA (4)/span_Browse. or drag’
at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.stepFailed(WebUIKeywordMain.groovy:64)

Has anybody ever to got it to work on a phone?
Is there another way of doing this?
Am I just dumb?

i don’t think it is the locator I am using as the html for both the website and phone are identical in that respect.
It may be that on a phone browsing for a file has an additional step and uploadFileWithDragAndDrop doesn’t account foe that?


Hi @barry.reid ,

Thank you for your concern. In terms of your issue, I will scope it down into 3 main potential causes:

  1. The performances of web browser versus emulator are different; therefore, there might be some timing problem when loading the items. It means when the test is running on the phone, the element has not been loaded / clickable yet. I will suggest that you should add some delays for the test to run by WebUI.waitForElementClickable, WebUI.waitForElementVisible, Delay or Thread.sleep().

  2. After you try the first suggestion but still does not work, it can be the scrolling issue due to the difference in display screen. Follow this document if needed.

  3. It is acknowledged that this is the common error with automation testing tool when we cannot find the element because the Xpath is duplicated somewhere or too general. To deal with this, you can help optimize it by providing a better XPath which means to be unique. Your HTML Xpath is recommended to contain unique Id field.
    There is one workaround that you can try by adding POM Builder extension in Google so that it can automatically copy your Xpath under the best format. Then, you can provide it to the test case.

  4. After all if you still do not find any ways helpful, please try to find the object by other things such as: CSS Selector, ALT Identifier, .etc.

In the long run, our team will plan to publish a post to propose suggestions for your problem and relevant ones. We will let you know then.

Hope these suggestions can help your issue. Thank you!

2 Likes

Thank you for the suggestions, most of which I have tried before. I added again a WebUI.waitForElementClickable & WebUI.waitForElementVisible. As you can see from the results, the element is visible and clickable, then the next step says it is not able to click. I’ve also added a screenshot taken as the test runs, you can clearly see the file upload control, you also see a message at the top saying ‘no files selected’ maybe this is the issue as it finds the file every time in web browser


Hi,

Have you tried the option 3 and 4? If you have tried them and not been able to solve problem yet, I will ask for investigation internally and get back to you soon.

Best.

Hi,
Yes I have tried options 3 and 4, in fact I had tried everything you have suggested before I posted on this forum. I do not think the problem is that the element can not be found, as the screenshot above shows, it is visible and clickable, then the very next step says it is not clickable.
I am far from being an expert in this but it looks to me that a mobile device handles a file upload slightly differently that a web browser. Has anyone every got uploadFileWithDragAndDrop to work on a mobile device?

I remember encountering a similar issue when I was working on a mobile app testing project a while back. We were also using Katalon and had trouble getting uploadFileWithDragAndDrop to work on phones. After some research and experimentation, we discovered that the method doesn’t work on mobile browsers due to the way drag-and-drop events are handled on mobile devices.
We ended up using a different approach we found on https://zumroad.com/tech and it’s using the Appium library to upload files to the app directly instead of through the browser. This allowed us to bypass the drag-and-drop functionality and upload files successfully on both Android and iOS devices.

Thanks for the reply. I had my suspicions it would not work, for the very same reasons. I even raised a support issue with Katalon themselves but they were unable to confirm one way or the other. It is a bit disappointing that Katalon themselves don’t know how their plug-ins work but members of the community do.
Thanks again for your reply

@mulidfatima

The below site you shared didn’t have any details about mobile upload. Could you please share the exact URL or the details of the solution that worked out for you. Thanks …

@barry.reid

Have you got any solution regarding mobile browser upload, If so please share the details. Thanks …

Hi,

I did not share the link with the ‘working solution’ for mobile browser upload. mulidfatima did. I could not find any useful information in the link either so as yet have no workable solution, nor does Kalaton if you ask them :slight_smile: