Skip to content

Fixed All SwiftLint Linting Warnings & Errors#60

Merged
vimscientist69 merged 22 commits intomasterfrom
fix/fix-all-linting-warnings
Aug 15, 2025
Merged

Fixed All SwiftLint Linting Warnings & Errors#60
vimscientist69 merged 22 commits intomasterfrom
fix/fix-all-linting-warnings

Conversation

@vimscientist69
Copy link

@vimscientist69 vimscientist69 commented Aug 15, 2025

Reason

Reason for creating this PR: resolves #53

Tech Details List

  1. Fixed all linting errors and warnings
  2. Refactored PostExecuteSyncRequest and PostExecuteAsyncRequest to PostExecuteRequest

Tasks:

  • Fixed all linting errors and warnings
  • Refactored PostExecuteSyncRequest and PostExecuteAsyncRequest to PostExecuteRequest

Un-important tasks:

No unimportant tasks

Links:

ISSUE-53
closes/resolves #53

Testing

Steps:

  1. Run required commands to test all the code modified by this PR
# unit tests
# integration tests
npm run test
# procs / testing logic
  1. Further testing can be done by following the notes in TESTING-QA

Output:

Output from running tests:

❯ swift test
Building for debugging...
[1/1] Write swift-version--58304C5D6DBC2206.txt
Build complete! (0.22s)
Test Suite 'All tests' started at 2025-08-15 13:34:33.607.
Test Suite 'All tests' passed at 2025-08-15 13:34:33.613.
         Executed 0 tests, with 0 failures (0 unexpected) in 0.000 (0.007) seconds
◇ Test run started.
↳ Testing Library Version: 124.4
↳ Target Platform: arm64e-apple-macos14.0
◇ Suite "Chrome Driver Find Element Tests" started.
◇ Suite "Chrome Driver Set Attribute" started.
◇ Suite "Chrome Driver Element Handles" started.
◇ Suite "Chrome Driver Special Keys" started.
◇ Suite "Chrome Driver Drag and Drop Integration Tests" started.
◇ Suite "Chrome Driver Start Tests" started.
◇ Suite "Chrome Driver Javascript Sync" started.
◇ Suite "Chrome Driver Find Elements Tests" started.
◇ Test "Get Element By CSS Selector" started.
◇ Suite "Chrome Driver Property Integration Tests" started.
◇ Test "Get Property" started.
◇ Test "Tab Should Cycle Input Elements Focus" started.
◇ Test "Click Button" started.
◇ Suite "Chrome Driver Navigation Tests" started.
◇ Test "Set Attribute" started.
◇ Test "Start & Stop" started.
◇ Test "Get Elements CSS Elements" started.
◇ Test "Test sync Javascript Execution" started.
◇ Test "Get Navigation Title" started.
◇ Test "Drag Element To Another (JavaScript)" started.
◇ Passing 1 argument input → ("return `${1 + 2}`", "3") to "Test sync Javascript Execution"
✔ Test "Get Navigation Title" passed after 5.569 seconds.
◇ Test "Wait Until Element Exists" started.
✔ Test "Set Attribute" passed after 5.846 seconds.
✔ Suite "Chrome Driver Set Attribute" passed after 5.847 seconds.
✔ Test "Get Property" passed after 6.183 seconds.
◇ Test "Set Property" started.
✔ Test "Get Element By CSS Selector" passed after 8.414 seconds.
◇ Test "Get Element By XPath" started.
◇ Passing 1 argument input → ("return `${5 - 3}`", "2") to "Test sync Javascript Execution"
✔ Test "Drag Element To Another (JavaScript)" passed after 11.795 seconds.
◇ Test "Drag Element To Another (WebDriver Actions API)" started.
✔ Test "Set Property" passed after 6.967 seconds.
✔ Suite "Chrome Driver Property Integration Tests" passed after 13.150 seconds.
✔ Test "Click Button" passed after 13.651 seconds.
◇ Test "Double Click Button" started.
✔ Test "Start & Stop" passed after 16.209 seconds.
✔ Suite "Chrome Driver Start Tests" passed after 16.209 seconds.
error : noSuchElement, message: no such element: Unable to locate element: {"method":"css selector","selector":"#asyncAddElement"}
  (Session info: chrome=102.0.5005.61)
error : noSuchElement, message: no such element: Unable to locate element: {"method":"css selector","selector":"#asyncAddElement"}
  (Session info: chrome=102.0.5005.61)
✔ Test "Wait Until Element Exists" passed after 13.059 seconds.
✔ Suite "Chrome Driver Navigation Tests" passed after 18.628 seconds.
◇ Passing 1 argument input → ("return `${3 * 4}`", "12") to "Test sync Javascript Execution"
✔ Test "Drag Element To Another (WebDriver Actions API)" passed after 7.242 seconds.
✔ Suite "Chrome Driver Drag and Drop Integration Tests" passed after 19.037 seconds.
✔ Test "Get Elements CSS Elements" passed after 22.753 seconds.
◇ Test "Get Elements By XPath" started.
◇ Passing 1 argument input → ("return `${10 / 2}`", "5") to "Test sync Javascript Execution"
✔ Test "Tab Should Cycle Input Elements Focus" passed after 23.081 seconds.
✔ Suite "Chrome Driver Special Keys" passed after 23.081 seconds.
✔ Test "Get Element By XPath" passed after 17.576 seconds.
◇ Test "Get Element By Link Text" started.
✔ Test "Get Elements By XPath" passed after 3.492 seconds.
◇ Test "Get Elements By Link Text" started.
✔ Test "Double Click Button" passed after 12.801 seconds.
◇ Test "Drag Element To Another" started.
◇ Passing 1 argument input → ("return `Hello, ` + \'World!\'", "Hello, World!") to "Test sync Javascript Execution"
✔ Test "Get Elements By Link Text" passed after 3.100 seconds.
◇ Test "Get Elements By Partial Link Text" started.
✔ Test "Drag Element To Another" passed after 3.605 seconds.
◇ Test "Get Element Attributes" started.
✔ Test "Get Element By Link Text" passed after 5.894 seconds.
◇ Test "Get Element By Partial Link" started.
◇ Passing 1 argument input → ("localStorage.setItem(\'user\', \'John\'); return localStorage.getItem(\'user\')", "John") to "Test sync Javascript Execution"
✔ Test "Get Element Attributes" passed after 3.125 seconds.
◇ Test "Get Element Rect" started.
✔ Test "Get Elements By Partial Link Text" passed after 5.602 seconds.
◇ Test "Get Elements By Tag Name" started.
✔ Test "Get Element By Partial Link" passed after 3.556 seconds.
◇ Test "Get Element By TagName" started.
◇ Passing 1 argument input → ("localStorage.setItem(\'token\', \'abc123\'); return localStorage.getItem(\'token\')", "abc123") to "Test sync Javascript Execution"
✔ Test "Get Elements By Tag Name" passed after 3.035 seconds.
✔ Suite "Chrome Driver Find Elements Tests" passed after 37.984 seconds.
✔ Test "Get Element By TagName" passed after 3.081 seconds.
✔ Suite "Chrome Driver Find Element Tests" passed after 38.522 seconds.
✔ Test "Get Element Rect" passed after 6.349 seconds.
◇ Test "Clear Element" started.
◇ Passing 1 argument input → ("sessionStorage.setItem(\'session\', \'active\'); return sessionStorage.getItem(\'session\')", "active") to "Test sync Javascript Execution"
✔ Test "Clear Element" passed after 2.988 seconds.
◇ Test "Send Key" started.
◇ Passing 1 argument input → ("let arr = [1, 2, 3]; arr.push(4); return arr.join(\',\')", "1,2,3,4") to "Test sync Javascript Execution"
✔ Test "Send Key" passed after 2.906 seconds.
◇ Test "Get Screenshot" started.
◇ Passing 1 argument input → ("let obj = { name: \'Alice\', age: 25 }; obj.age = 26; return `${obj.age}`", "26") to "Test sync Javascript Execution"
✔ Test "Get Screenshot" passed after 3.015 seconds.
◇ Test "Fail any operation if element becomes stale" started.
◇ Passing 1 argument input → ("document.body.innerHTML = \'<p>Hello, World!</p>\'; return document.body.innerText", "Hello, World!") to "Test sync Javascript Execution"
✔ Test "Test sync Javascript Execution" passed after 52.074 seconds.
◇ Test "Test async Javascript Execution" started.
◇ Passing 1 argument input → ("var callback = arguments[arguments.length - 1];\nsetTimeout(function() { callback(\'Hello from async JavaScript\'); }, 2000);", "Hello from async JavaScript") to "Test async Javascript Execution"
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.820 seconds.
✔ Suite "Chrome Driver Element Handles" passed after 54.265 seconds.
✔ Test "Test async Javascript Execution" passed after 4.548 seconds.
◇ Test "Throws `javascript error` if JS fails" started.
error : javascriptError, message: javascript error: Test Error
  (Session info: chrome=102.0.5005.61)
✔ Test "Throws `javascript error` if JS fails" passed after 2.680 seconds.
✔ Suite "Chrome Driver Javascript Sync" passed after 59.302 seconds.
✔ Test run with 31 tests passed after 59.303 seconds.

Output from running npm run lint:

╰─❯ npm run lint
❯ npm run lint

> swiftwebdriver@1.0.0 lint
> swiftlint .

Linting Swift files at paths .
Linting 'SeleniumSwiftExampleTests.swift' (1/89)
Linting 'Main.swift' (2/89)
Linting 'ChromeDriverSetAttributeIntegrationTests.swift' (3/89)
Linting 'ChromeDriverElementHandleIntegrationTests.swift' (4/89)
Linting 'ChromeDriverSpecialKeysIntegrationTests.swift' (5/89)
Linting 'ChromeDriverFindElementIntegrationTests.swift' (6/89)
Linting 'ChromeDriverPropertyIntegrationTests.swift' (7/89)
Linting 'ChromeDriverDragAndDropIntegrationTests.swift' (8/89)
Linting 'ChromeDriverFindElementsIntegrationTests.swift' (9/89)
Linting 'ChromeDriverNavigationIntegrationTests.swift' (10/89)
Linting 'ChromeDriverStartTests.swift' (11/89)
Linting 'ChromeDriverIntegrationTestsBase.swift' (12/89)
Linting 'ChromeDriverJavascriptIntegrationTests.swift' (13/89)
Linting 'CSSSelector.swift' (14/89)
Linting 'LocatorSelector.swift' (15/89)
Linting 'LocatorType.swift' (16/89)
Linting 'Element.swift' (18/89)
Linting 'ElementRect.swift' (17/89)
Linting 'Elements.swift' (19/89)
Linting 'Driver.swift' (20/89)
Linting 'ChromeDriver.swift' (21/89)
Linting 'ChromeDriverElementDragAndDropper.swift' (22/89)
Linting 'ChromeOptions.swift' (23/89)
Linting 'GetNavigationResponse.swift' (24/89)
Linting 'PostNavigationBackResponse.swift' (25/89)
Linting 'PostNavigationForwardResponse.swift' (26/89)
Linting 'GetNavigationTitleResponse.swift' (28/89)
Linting 'PostNavigationResponse.swift' (27/89)
Linting 'PostNavigationRefreshResponse.swift' (29/89)
Linting 'ResponseType.swift' (30/89)
Linting 'GetElementAttributeResponse.swift' (31/89)
Linting 'GetElementTextResponse.swift' (32/89)
Linting 'GetElementNameResponse.swift' (33/89)
Linting 'GetElementRectResponse.swift' (34/89)
Linting 'PostElementByIdResponse.swift' (35/89)
Linting 'PostElementClearResponse.swift' (36/89)
Linting 'GetElementPropertyNameResponse.swift' (37/89)
Linting 'PostElementsResponse.swift' (38/89)
Linting 'GetElementNamePropertyResponse.swift' (39/89)
Linting 'PostElementSendValueResponse.swift' (40/89)
Linting 'PostElementResponse.swift' (41/89)
Linting 'GetScreenShotResponse.swift' (42/89)
Linting 'GetElementScreenShotResponse.swift' (43/89)
Linting 'PostElementsByIdResponse.swift' (44/89)
Linting 'GetElementSelectedResponse.swift' (45/89)
Linting 'GetSessionActiveElementResponse.swift' (46/89)
Linting 'DeleteSessionResponse.swift' (47/89)
Linting 'StatusResponse.swift' (48/89)
Linting 'NewSessionResponse.swift' (49/89)
Linting 'PostExecuteResponse.swift' (50/89)
Linting 'PostNavigationForwardRequest.swift' (51/89)
Linting 'APIClient.swift' (52/89)
Linting 'GetNavigationRequest.swift' (53/89)
Linting 'PostNavigationBackRequest.swift' (54/89)
Linting 'PostNavigationRequest.swift' (55/89)
Linting 'PostNavigationRefreshRequest.swift' (56/89)
Linting 'GetNavigationTitleRequest.swift' (57/89)
Linting 'PostElementSendValueRequest.swift' (58/89)
Linting 'PostElementsRequest.swift' (60/89)
Linting 'PostElementClickResponse.swift' (59/89)
Linting 'GetElementScreenShotRequest.swift' (61/89)
Linting 'PostElementClearRequest.swift' (62/89)
Linting 'GetElementNameRequest.swift' (63/89)
Linting 'PostElementDoubleClickRequest.swift' (64/89)
Linting 'PostElementByIdRequest.swift' (65/89)
Linting 'PostElementsByIdRequest.swift' (66/89)
Linting 'ElementsTypes.swift' (67/89)
Linting 'PostElementClickRequest.swift' (68/89)
Linting 'PostElementDragAndDropRequest.swift' (69/89)
Linting 'GetElementTextRequest.swift' (70/89)
Linting 'PostElementRequest.swift' (71/89)
Linting 'GetElementAttributeRequest.swift' (72/89)
Linting 'GetElementRectRequest.swift' (73/89)
Linting 'GetElementPropertyNameRequest.swift' (74/89)
Linting 'GetSessionActiveElementRequest.swift' (75/89)
Linting 'GetElementNamePropertyRequest.swift' (76/89)
Linting 'GetScreenShotRequest.swift' (77/89)
Linting 'GetElementSelectedRequest.swift' (78/89)
Linting 'DeleteSessionRequest.swift' (79/89)
Linting 'NewSessionRequest.swift' (80/89)
Linting 'StatusRequest.swift' (81/89)
Linting 'PostExecuteRequest.swift' (82/89)
Linting 'DevToolTypes.swift' (83/89)
Linting 'RequestType.swift' (84/89)
Linting 'AnyEncodable.swift' (85/89)
Linting 'ActionsPayload.swift' (86/89)
Linting 'WebDriverError.swift' (87/89)
Linting 'WebDriver.swift' (88/89)
Linting 'SeleniumError.swift' (89/89)
Done linting! Found 0 violations, 0 serious in 89 files.

Testing QA

Nothing here.

@vimscientist69 vimscientist69 self-assigned this Aug 15, 2025
…ation test services, build package and run tests

Also added `npm run compose:up:integration-services` script to startup and wait for docker-compose services required for running integration tests to be healthy.
@vimscientist69 vimscientist69 force-pushed the fix/fix-all-linting-warnings branch from d688844 to 43137db Compare August 15, 2025 18:22
@vimscientist69 vimscientist69 merged commit 2b80410 into master Aug 15, 2025
1 of 2 checks passed
@vimscientist69 vimscientist69 deleted the fix/fix-all-linting-warnings branch August 15, 2025 19:37
vimscientist69 added a commit that referenced this pull request Dec 19, 2025
* fix: fixed some linting errors

* fix: fixed some linting errors

* fix: fixed some linting errors

* docs(Element): added documentation for all exposed public symbols

* docs(Element,ElementRect): added documentation

* docs(APIClient): added docs for public symbols

* docs(ElementTypes): added documents for public symbols

* docs(PostElementDoubleClickRequest): added documentation for public symbols

* docs(DevToolTypes): added documentation for namespace

* docs(AnyEncodable): documentation added

* refactor(PostExecuteRequest): refactored to only one struct, added documentation

* docs(ChromeDriverElementDragAndDropper): added documentation, fixed linting errors

* docs(Element): documented find element protocol

* refactor(PostElementDragAndDropRequest): refactored body property getter method

* docs(PostElementDragAndDropRequest): added documentation

* docs(SeleniumError): added documentation

* docs(WebDriver): added documentation

* docs(ActionsPayload): added documentation

* fix(ActionsPayload): fixed property names too short

* docs(GetElementRectRequest): added documentation, fixed no implicit access control levels set

* fix: fixed all linting errors

* feat(package.json): added test script to start up all required integration test services, build package and run tests

Also added `npm run compose:up:integration-services` script to startup and wait for docker-compose services required for running integration tests to be healthy.
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.

Refactor -> Fix all swiftlint issues

1 participant