WKZombie icon indicating copy to clipboard operation
WKZombie copied to clipboard

Cannot check reference equality of functions; operands here have types 'Action<HTMLElement>' and '(Result<[HTMLElement]>) -> ()'

Open phirestalker opened this issue 7 years ago • 3 comments

get the error above for the following code

` func enterContests() { open(URL(string: "https://prizegrab.com")!) >>> get(by: .XPathQuery("//a[@class='login-link']")) >>> click(then: .wait(1.5)) >>> get(by: .id("login-with-email")) >>> click(then: .wait(1.5)) >>> get(by: .id("login-email")) >>> setAttribute("value", value: username.stringValue) >>> get(by: .id("login-password")) >>> setAttribute("value", value: pass.stringValue) >>> get(by: .XPathQuery("//div[contains(@class,'form-login')]/form")) >>> submit(then: .wait(3)) >>> get(by: .contains("href", "/logout")) === handleResult }

func handleResult(_ result: Result<[HTMLElement]>) {
    switch result {
    case .success(let value): errors = "no errors"
    case .error(let error): errors = error.debugDescription
    }
}

` the line ===handleResult is the offending line

I'm not sure what I did wrong

phirestalker avatar Jun 19 '17 02:06 phirestalker

same problem here

        var url: URL!
        url = URL(string: "http://example.com")
        self.browser.open(then: .wait(10.0))(url)
    >>* get(by: .id("UserName"))
    >>> setAttribute("value", value: "xyz")
    >>* get(by: .id("Password"))
    >>> setAttribute("value", value: "abc")
    >>* get(by: .class("submitBtn"))
    >>> click(then: .wait(5.0))
    >>* get(by: .name("body"))
    === { (result: Result<[HTMLTableRow]>) in
            print(result)
        }

aaronfranco avatar Jan 26 '18 14:01 aaronfranco

I also get this error, using the example code: has this error been fixed?

Innoviox avatar Sep 13 '18 15:09 Innoviox

This is not an error in the library it is working as intended. If you look at the error it is stating that you do not have the correct type in the result function. The last get function in your chain is returning a HTMLElement and in your result function you are putting an array of HTMLElement ( [ HTMLElement] ) if you remove the syntax for an array then the error should go away. For other people that are having similar issues, make sure to put the correct type in your result function based off what the last action in your chain is returning.

Rballesteros avatar Feb 16 '19 22:02 Rballesteros