@@ -257,28 +257,13 @@ async function dragDiagramToShowAndClick(
257257  const  targetElement  =  browser . $ ( selector ) ; 
258258
259259  let  elementPosition  =  await  targetElement . getLocation ( ) ; 
260-   let  elementSize  =  await  targetElement . getSize ( ) ; 
261260
262261  const  DRAG_INCREMENT  =  100 ; 
263262
264263  let  diagramBackgroundPosition  =  await  browser 
265264    . $ ( Selectors . DataModelPreview ) 
266265    . getLocation ( ) ; 
267266
268-   // Distance from the origin of the diagram to the center of the element. 
269-   function  getDistanceToElementCenter ( )  { 
270-     return  Math . abs ( 
271-       Math . floor ( 
272-         elementPosition . x  +  elementSize . width  /  2  -  diagramBackgroundPosition . x 
273-       )  + 
274-         Math . floor ( 
275-           elementPosition . y  + 
276-             elementSize . height  /  2  - 
277-             diagramBackgroundPosition . y 
278-         ) 
279-     ) ; 
280-   } 
281- 
282267  async  function  attemptClick ( )  { 
283268    try  { 
284269      // In the diagram the buttons on nodes will return true for `isClickable` and `isDisplayed` 
@@ -291,13 +276,11 @@ async function dragDiagramToShowAndClick(
291276    return  true ; 
292277  } 
293278
279+   let  dragAndClickAttempts  =  0 ; 
280+ 
294281  // Drag in increments as the diagram can be large, and we can't drag off of the page in one go. 
295-   while  ( 
296-     ! ( await  attemptClick ( ) )  && 
297-     getDistanceToElementCenter ( )  >  DRAG_INCREMENT  *  4 
298-   )  { 
282+   while  ( ! ( await  attemptClick ( ) ) )  { 
299283    elementPosition  =  await  targetElement . getLocation ( ) ; 
300-     elementSize  =  await  targetElement . getSize ( ) ; 
301284
302285    diagramBackgroundPosition  =  await  browser 
303286      . $ ( Selectors . DataModelPreview ) 
@@ -342,6 +325,13 @@ async function dragDiagramToShowAndClick(
342325      . perform ( ) ; 
343326
344327    await  browser . waitForAnimations ( Selectors . DataModelPreview ) ; 
328+ 
329+     dragAndClickAttempts -- ; 
330+     if  ( dragAndClickAttempts  >  20 )  { 
331+       throw  new  Error ( 
332+         `Could not drag the diagram to show and click the element with selector ${ selector }  . Attempted to reposition and click ${ dragAndClickAttempts }   times.` 
333+       ) ; 
334+     } 
345335  } 
346336
347337  return  elementPosition ; 
@@ -962,7 +952,8 @@ describe('Data Modeling tab', function () {
962952      ) ; 
963953
964954      // Add two fields to the collection. 
965-       await  browser . clickVisible ( 
955+       await  dragDiagramToShowAndClick ( 
956+         browser , 
966957        Selectors . DataModelCollectionAddFieldBtn ( 'test.testCollection-one' ) 
967958      ) ; 
968959
0 commit comments