Search code examples
cookiesf#canopy-web-testing

Get access to httponly cookies with canopy


I need to clean session cookies during canopy tests. I dont see any way to do it documentation. Currently I managed to get to core.browser.Manage().Cookies which is a OpenQA.Selenium.Remote.RemoteCookieJar But I dont know how to remove the cookie using it. Also, reading cookie values for httponly cookies is also someting I need to do.


Solution

  • canopy is just a wrapper on top of Selenium Webdriver. You can access the current browser/driver with browser or core.browser like you show above.

    I believe that this should work for your first problem:

    browser.Manage().Cookies.DeleteAllCookies()
    

    For your second question, this should give you a string list of values for non secure cookies

    let httpCookieValues = 
        browser.Manage().Cookies.AllCookies
        |> List.ofSeq
        |> List.filter (fun cookie -> not cookie.Secure)
        |> List.map (fun cookie -> cookie.Value)