Skip to content

Element.dragAndDrop(), Driver.dragAndDrop(), Element.rect() Implemented#59

Merged
vimscientist69 merged 5 commits intomasterfrom
feat/drag-element-to-another-procedure
Aug 14, 2025
Merged

Element.dragAndDrop(), Driver.dragAndDrop(), Element.rect() Implemented#59
vimscientist69 merged 5 commits intomasterfrom
feat/drag-element-to-another-procedure

Conversation

@vimscientist69
Copy link

@vimscientist69 vimscientist69 commented Aug 14, 2025

Reason

Reason for creating this pull request: resolves #58

Tech Details List

  1. A dragAndDrop(to: Element) method on Element, that drags one element to another by first moving cursor to self, click and hold left mouse button while moving the cursor to to, and then releasing the left mouse button.
    1. rect() method on Element with integration tests, to move the source element to the middle of the target element.
  2. Working integration tests to test the drag functionality
  3. Driver.dragAndDrop() method; when the source element is draggable, use JavaScript to drag the element to the target element - so that JavaScript event listeners gets triggered, else use the Element.dragAndDrop(), a method that uses WebDriver Actions API mouse actions.

Tasks:

  • A dragAndDrop(to: Element) method on Element, that drags one element to another by first moving cursor to self, click and hold left mouse button while moving the cursor to to, and then releasing the left mouse button.
  • rect() method on Element with integration tests, to move the source element to the middle of the target element.
  • Working integration tests to test the drag functionality
  • Driver.dragAndDrop() method; when the source element is draggable, use JavaScript to drag the element to the target element - so that JavaScript event listeners gets triggered, else use the Element.dragAndDrop(), a method that uses WebDriver Actions API mouse actions.

Un-important tasks:

Links:

ISSUE-58
closes/resolves #58

Testing

Steps:

  1. Run required commands to test all the code modified by this PR
# unit tests
# integration tests
npm run compose:build-and-up
swift build
swift test --filter "ChromeDriverDragAndDropIntegrationTests"
swift test --filter "ChromeDriverElementHandleIntegrationTests"

# procs / testing logic
  1. Further testing can be done by following the notes in TESTING-QA

Output:

❯ swift build
swift test --filter "ChromeDriverDragAndDropIntegrationTests"
swift test --filter "ChromeDriverElementHandleIntegrationTests"

[1/1] Planning build
Building for debugging...
[1/1] Write swift-version--58304C5D6DBC2206.txt
Build complete! (1.61s)
[1/1] Planning build
Building for debugging...
[1/1] Write swift-version--58304C5D6DBC2206.txt
Build complete! (1.56s)
Test Suite 'Selected tests' started at 2025-08-14 14:27:53.816.
Test Suite 'swift-webdriverPackageTests.xctest' started at 2025-08-14 14:27:53.822.
Test Suite 'swift-webdriverPackageTests.xctest' passed at 2025-08-14 14:27:53.822.
         Executed 0 tests, with 0 failures (0 unexpected) in 0.000 (0.000) seconds
Test Suite 'Selected tests' passed at 2025-08-14 14:27:53.822.
         Executed 0 tests, with 0 failures (0 unexpected) in 0.000 (0.006) seconds
◇ Test run started.
↳ Testing Library Version: 124.4
↳ Target Platform: arm64e-apple-macos14.0
◇ Suite "Chrome Driver Drag and Drop Integration Tests" started.
◇ Test "Drag Element To Another" started.
✔ Test "Drag Element To Another" passed after 2.750 seconds.
◇ Test "Set Property" started.
✔ Test "Set Property" passed after 2.609 seconds.
✔ Suite "Chrome Driver Drag and Drop Integration Tests" passed after 5.359 seconds.
✔ Test run with 2 tests passed after 5.359 seconds.
Building for debugging...
[1/1] Write swift-version--58304C5D6DBC2206.txt
Build complete! (0.19s)
Test Suite 'Selected tests' started at 2025-08-14 14:27:59.931.
Test Suite 'swift-webdriverPackageTests.xctest' started at 2025-08-14 14:27:59.937.
Test Suite 'swift-webdriverPackageTests.xctest' passed at 2025-08-14 14:27:59.937.
         Executed 0 tests, with 0 failures (0 unexpected) in 0.000 (0.000) seconds
Test Suite 'Selected tests' passed at 2025-08-14 14:27:59.937.
         Executed 0 tests, with 0 failures (0 unexpected) in 0.000 (0.006) seconds
◇ Test run started.
↳ Testing Library Version: 124.4
↳ Target Platform: arm64e-apple-macos14.0
◇ Suite "Chrome Driver Element Handles" started.
◇ Test "Click Button" started.
✔ Test "Click Button" passed after 2.661 seconds.
◇ Test "Double Click Button" started.
✔ Test "Double Click Button" passed after 2.803 seconds.
◇ Test "Drag Element To Another" started.
✔ Test "Drag Element To Another" passed after 2.913 seconds.
◇ Test "Get Element Attributes" started.
✔ Test "Get Element Attributes" passed after 2.470 seconds.
◇ Test "Get Element Rect" started.
✔ Test "Get Element Rect" passed after 2.541 seconds.
◇ Test "Clear Element" started.
✔ Test "Clear Element" passed after 2.676 seconds.
◇ Test "Send Key" started.
✔ Test "Send Key" passed after 2.741 seconds.
◇ Test "Get Screenshot" started.
✔ Test "Get Screenshot" passed after 2.623 seconds.
◇ Test "Fail any operation if element becomes stale" started.
error : staleElementReference, message: stale element reference: element is not attached to the page document
  (Session info: chrome=102.0.5005.61)
✔ Test "Fail any operation if element becomes stale" passed after 5.719 seconds.
✔ Suite "Chrome Driver Element Handles" passed after 27.153 seconds.
✔ Test run with 9 tests passed after 27.154 seconds.

Testing QA

Make sure to start required services with npm run compose:build-and-up

…quest to webdriver api

Code is untested. Code can compile. Refactored action types from double click request source file to its own source file
…lement and driver methods

Integration test for `Element.dragAndDrop()` implemented and passed as expected. `dragAndDrop()` webdriver method is a dynamic method that can either use javascript when element is draggable to drag element and fire off javascript event listeners, or use `Element.dragAndDrop()` when element is not draggable to use webdriver actions API instead.
…tegration test for drag and drop element to another element method
@vimscientist69 vimscientist69 self-assigned this Aug 14, 2025
@vimscientist69 vimscientist69 merged commit 60cf633 into master Aug 14, 2025
1 of 2 checks passed
@vimscientist69 vimscientist69 deleted the feat/drag-element-to-another-procedure branch August 14, 2025 20:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature -> Drag Element To Another

1 participant