Skip to content

Commit

Permalink
Fix MTE-4030 - drag and drop flaky tests (#23961)
Browse files Browse the repository at this point in the history
  • Loading branch information
dragosb01 authored Dec 27, 2024
1 parent 8099fa3 commit 360b1de
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -205,10 +205,12 @@ private extension BaseTestCase {
func dragAndDrop(dragElement: XCUIElement, dropOnElement: XCUIElement) {
var nrOfAttempts = 0
mozWaitForElementToExist(dropOnElement)
dragElement.press(forDuration: 1.5, thenDragTo: dropOnElement)
let startCoordinate = dragElement.coordinate(withNormalizedOffset: CGVector(dx: 0, dy: 0))
let endCoordinate = dropOnElement.coordinate(withNormalizedOffset: CGVector(dx: 0.5, dy: 0.5))
startCoordinate.press(forDuration: 2.0, thenDragTo: endCoordinate)
mozWaitForElementToExist(dragElement)
// Repeat the action in case the first drag and drop attempt was not successful
while dragElement.isLeftOf(rightElement: dropOnElement) && nrOfAttempts < 4 {
while dragElement.isLeftOf(rightElement: dropOnElement) && nrOfAttempts < 5 {
dragElement.press(forDuration: 1.5, thenDragTo: dropOnElement)
nrOfAttempts = nrOfAttempts + 1
mozWaitForElementToExist(dragElement)
Expand Down

0 comments on commit 360b1de

Please sign in to comment.