From 360b1debde4cc00bd4412549ccd8233a25876a35 Mon Sep 17 00:00:00 2001 From: dragosb01 <134391433+dragosb01@users.noreply.github.com> Date: Fri, 27 Dec 2024 16:10:07 +0200 Subject: [PATCH] Fix MTE-4030 - drag and drop flaky tests (#23961) --- .../Tests/XCUITests/DragAndDropTests.swift | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/firefox-ios/firefox-ios-tests/Tests/XCUITests/DragAndDropTests.swift b/firefox-ios/firefox-ios-tests/Tests/XCUITests/DragAndDropTests.swift index 6ae3b2ed9c0d..072889480dcc 100644 --- a/firefox-ios/firefox-ios-tests/Tests/XCUITests/DragAndDropTests.swift +++ b/firefox-ios/firefox-ios-tests/Tests/XCUITests/DragAndDropTests.swift @@ -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)