thebrowsercompany / swift-webdriver

A Swift library for communicating with WebDriver (Appium/WinAppDriver) endpoints
BSD 3-Clause "New" or "Revised" License
105 stars 3 forks source link

Remove starting WinAppDriver.exe as a manual step in the GitHub Actions workflow #46

Closed tristanlabelle closed 1 year ago

tristanlabelle commented 1 year ago

We found that using ShellExecute reliably starts WinAppDriver.exe in on the GitHub CI machines (with Windows server), so we should migrate to that and not start WinAppDriver in the CI yaml but rather in the test code.

Depends on #45

jeffdav commented 1 year ago

It's strange, because sometimes I see this:

==========================================
POST /session HTTP/1.1
Accept: */*
Accept-Encoding: deflate, gzip
Accept-Language: en
Connection: keep-alive
Content-Length: 102
Content-Type: application/json;charset=UTF-8
Host: 127.0.0.1:4723
Json: content-encoding
User-Agent: webdriver-swiftPackageTests.xctest (unknown version) curl/7.77.0

HTTP/1.1 500 Internal Error
Content-Length: 133
Content-Type: application/json

{"status":13,"value":{"error":"unknown error","message":"An unknown error occurred in the remote end while processing the command."}}

Where we try to initialize the session, but it hangs for a long time. Eventually it times out, and we see above that WAD sent back error 13.

I added the following code to retry the session creation:

        let session = retryUntil(1.0) {
            let sessionId: String
            do {
                sessionId = try send(newSessionRequest).sessionId
                return Session(in: self, id: sessionId)
            } catch let error as WebDriverError where error.status == .unknownError {
                print("-> Unknown Error: \(error)"); fflush(stdout)
                return nil
            } catch {
                print("-> Catch-all Error: \(error)"); fflush(stdout)
                return nil
            }
        }

But I don't get the error 13. What I see from the test window is this:

Test Suite 'SessionTests' started at 2023-08-05 12:47:26.340
-> (re)trying...
-> Catch-all Error: Error Domain=NSURLErrorDomain Code=-1001 "(null)"
-> (re)trying...
PS C:\Users\jeffd\src\webdriver-swift>

Notice we got the catch all error, not the WebDriverError, and it doesn't have a useful description (though I think -1001 is timeout). We retry the session, and I see in the WAD window that it succeeds the 2nd time, but the test process still dies for reasons I haven't been able to discern.

jeffdav commented 1 year ago

This is done in webdriver-swift.