I am working on a project where we use frames and we have dozens of drag and drop options. As an automation tester I have been suffering with not being able to do drag and drop with code since they are on frames and finally I came across with this video on KZbin! Sir, you are a gift from my god to me, how the f* I could not find out that mouse actions work both for main and subframes. I have been searching for this solutions for months ahaha! Thanks, and I am already subscribed. Keep up the good work please..
@letcode Жыл бұрын
Glad u like it, thanks 👍
@krishnae5142 Жыл бұрын
Hi Koushik, How can we drag and drop elements between two windows ..I am able to drag an drop in the same window but not in 2 separate windows.Can you please suggest.
@letcode Жыл бұрын
Hi, not possible
@CatalogueAddict3 жыл бұрын
hey is there a difference with the dragAndDrop method in Playwright now it has been released ? Thanks
@letcode3 жыл бұрын
No major difference, new drag and drop method is a straight forward to do.
@grasiboy67613 жыл бұрын
@@letcode Sorry to ask, but i am a little bit confused what parameters (source, target) i should put into the page.dragAndDrop function. Do u have an example with correct source and target? Because if i want to put srcBound into it or an selector - these are not strings page.dragAndDrop(source, target[, options])# source # target #
@letcode3 жыл бұрын
@@grasiboy6761 you can pass the selector as string. For example in line no. 16 and 17 I have the selector. So you can pass that directly.
@R3V3R1 Жыл бұрын
I want to share. For those trying to follow this tutorial using react-beautiful-dnd, or maybe some other drag/drop libraries, you need to add the option "steps: 10" to the page.mouse.move() action. I believe this causes the move action to be performed slower so it doesn't leave slightly laggy components behind. await page.mouse.move(srcBound.x + srcBound.width / 2, srcBound.y + srcBound.height / 2) await page.mouse.down(); await page.mouse.move(dstBound.x + dstBound.width / 2, dstBound.y + dstBound.height / 2, {steps: 10}) await page.mouse.up();
@letcode Жыл бұрын
Appreciated, thanks for sharing ☺️
@i.am.sameer2 жыл бұрын
drag and drop in this example is working on X,Y coordinates and these coordinates probably are with respect to page and not frame. So I think it is as expected that frame doesnt support mouse move since solution is just mouse movement and not related to any particular webEelement ( I am just guessing :) )
@letcode2 жыл бұрын
Yeah may be ☺️
@rohanpatil7200 Жыл бұрын
Hi Sir, Is it possible to drag an image which is stored at my project / local storage? TIA
@letcode Жыл бұрын
Hi, that's not possible.
@lywatanak8594 Жыл бұрын
can have an example for drag and drop pin location on map brother?
@letcode Жыл бұрын
Not sure if that will work, but I will check.
@lywatanak8594 Жыл бұрын
@@letcode please help me a bit admin. I need your help.
@AnkitaSaha-fv1yz7 ай бұрын
Hi, Koushik, I am facing some problem in drag and drop I have done all the methods you have shown. Please hep me.
@letcode7 ай бұрын
What is the issue?
@Maxarlo-p1y Жыл бұрын
Hi koushik, Thanku for this video. It's really helpful. I am working in a project and one scenario is also related to drag and drop but these things is not working .Can you please share more things/url about drag and drop
@letcode Жыл бұрын
Hi, what is the issue?
@Maxarlo-p1y Жыл бұрын
@@letcode I have apply all those method which you have mention in this video but i am not able to drag the element and drop the element to another place
@letcode Жыл бұрын
There is also a direct method dragto can u check that.
@KumarS-cz1lh3 жыл бұрын
Great video Kaushik...just a question about the thing you hate with using if conditions....if the `#draggable` id is not there then you get null for `src`, true but then your `srcBound` would get this error: "Cannot read property 'boundingBox' of null" so I think there is no need for the if conditions, no? Please correct me if I am wrong as I have not looked at it too deeply. Thank you and please keep up the excellent work on Playwright Tutorials.
@letcode3 жыл бұрын
Yeah correct if element is not there then it wil be null. But while getting bounding box like x and y it can be also null. So to check that I'm using condition. Without condition u cannot get the x and y, typescript won't allowed as the return type is value or null.
@KumarS-cz1lh3 жыл бұрын
@@letcode Just trying to understand since I am writing something very similar following your tutorial.....so the "if" condition in your line number 18 (minute 9:36) is not necessary since if the "src" is null, playwright will throw an error by default when you try to get the boundingBox of null. But you are saying the "if" condition in line number 21 is necessary since even a not null "src" could have a null "srcBound"?
@letcode3 жыл бұрын
Both are necessary, I hope you are using typescript, try to execute with and without condition. You'll see the difference.
@letcode3 жыл бұрын
Ele can be null if there is no element. Element is there but it don't have bounding box (hidden element) then also null.
@KumarS-cz1lh3 жыл бұрын
@@letcode I am using Typescript...when I passed in a non existing element for `src` I get the "Cannot read property 'boundingBox' of null" error hence my assumption that the if condition is not necessary in line 18
@TestOneDAMSV Жыл бұрын
Can you please give an example for drag drop a file in the case of upload? I saw the upload example but it doesn't show dragdrop
@letcode Жыл бұрын
We cannot drag from window explore, that cannot be automated with playwright
@jluisblee2 жыл бұрын
You are the best, thanks
@letcode2 жыл бұрын
You're welcome!
@UralIslamov2 жыл бұрын
Hello, why drag and drop don't work in firefox?
@letcode2 жыл бұрын
In the recent version it will work
@punyaiathwale64832 жыл бұрын
Thanks for the video..it works
@letcode2 жыл бұрын
Welcome 👍
@akashk21903 жыл бұрын
Bro is there any other method for drag and drop in puppeteer
@letcode3 жыл бұрын
Not sure about puppeteer bro
@jluisblee2 жыл бұрын
Hello my friend, thanks for share your knowledge. Can you make a tutorial of playwright and cucumber with typescript? thanks in advance
@letcode2 жыл бұрын
Hello Jose, Sure, I'll do it.
@shaikmuneer2241 Жыл бұрын
I have only source element, I don't have target element, I need to drag source element to any desired location of the div page.....I'm unable to do this scenario.... can any one have suggestions
@letcode Жыл бұрын
You can get the source locator points and increase the points and pass it to the drag and drop method.
@shaikmuneer2241 Жыл бұрын
@@letcode increase the points: x and y co ordinates?
@letcode Жыл бұрын
@shaikmuneer2241 yes correct.
@akashk21903 жыл бұрын
Hey Koushik, Great work man and will pls say how to use this in Xpath not in CSS
@letcode3 жыл бұрын
Thanks bro. Instead of css you can pass xpath directly.
@akashk21903 жыл бұрын
@@letcode Thanks bro
@bafalo992 Жыл бұрын
is this TypeScript?
@letcode Жыл бұрын
Yes
@nareshrathnam2 жыл бұрын
I want this code java...help?
@letcode2 жыл бұрын
There is a Direct function for drag and drop u can check the documentation.