0

I want to automate Drag and in my angular app.

So I tried this code like in the protractor documentation browser.actions(). dragAndDrop(element1, element2). perform();

But it is not working for me.

My image description here

I need drag this S to the Read color area

xpath for S - var element1 = element(by.xpath('/html/body/app-root/app-dashboard-layout/div/app-create-new-workflow/div/div/div/div/div/div/div[2]/div/mat-tab-group/div/mat-tab-body[1]/div/div/div[1]/div[1]/app-element-pallete/div/div/div[1]/div[1]/button'))

xpath for Red color - var element2 = element(by.xpath('//*[@id="form"]'))

Can anyone help me to resolve that issue?

kithmi
  • 85
  • 2
  • 9
  • Does this answer your question? [How to simulate a drag and drop action in protractor?](https://stackoverflow.com/questions/25664551/how-to-simulate-a-drag-and-drop-action-in-protractor) – Sergey Pleshakov Mar 25 '20 at 13:43

1 Answers1

0

Try to do with Mouse actions

await browser.actions().mouseDown(element to drag).perform();
await browser.actions().mouseMove(destination to drop).perform();
await browser.actions().mouseUp(destination to drop).perform();

https://www.protractortest.org/#/api?view=webdriver.WebDriver.prototype.actions

Bharath Kumar S
  • 1,410
  • 2
  • 10
  • 29