0

enter image description here

Currently I am working on a webpage which has rappid js components. I am trying to achieve dragging and dropping of elements from the palette as seen in the screenshot to the grid. The element I drag from the palette can identified using its model id. The minute I drop the element a copy of it gets created on the grid its model id changes.The id seen in the dom also gets added dynamically. There will be multiple elements on the grid which have the same attributes as seen in the screenshot.

How to find this element uniquely and dynamically?

I have tried using Sikuli, but it doesn't help as there will be multiple similar looking elements. I can get all the elements on the grid using findElements() but no way to compare the recently dropped element. All I am trying to achieve is finding the element uniquely after it is dropped on the grid so that I can further perform operations on it.

Can we reverse the process of finding an element? from the location of the mouse cursor find the element?

enter image description here

0

I am not sure my solution will be effective enough from performance point of view, however this might be a work around unless you find the better one:

You should introduce a data structure that would store ids of elements which are currently in your workspace (say it will be called trivial object repository). Than after you have added next item to the screen, you do the following:

  1. Get ids of all the elements which are on your workspace
  2. Examine if the elements from step 1 exist in your trivial object repository item by item
  3. If item does not exist then it is new one. You can you this id to interact with that new item. Do not forget to add it to trivial object repository after you have detected it.
0

Looks like all your elements have id attributes. It may be possible to get a list of elements before the drop and save them. After the drop, get the list of elements again and check the one that is not in the earlier list.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.