Search code examples
f#canopy-web-testing

Why am I getting stackoverflow exception when calling a function twice?


I have a selenium UI test written with F# (using canopy selenium nuget package). I have a module that defines page selectors and helper functions. The page module is called by a test module. Within the test module, I am calling a function called 'handlemobimodals()', which runs four sub functions (if/else code blocks) that look for the existence of an element on a page and click on it, if it exists.

The problem I'm facing is that when the 'handlemobimodals()' function is called for a second time within the test, I get a Stack Overflow Exception (WebDriver Process is terminated due to StackOverflowException), right after its first sub function is called.

The function runs completely fine for the first time (called indirectly from another function earlier in the test), but fails the second time when called directly in the test. I'm pretty new to F# and I can't figure out how I'm causing a recursion in my test as the stackoverflow exception suggests.

Any insights would be greatly appreciated.

Snippet from Page Module:

module some_page

    let isOKGotItDisplayed () =
      isDisplayed <| "div.action-button.dismiss-overlay"

    let clickOKGotit() = 
      if isOKGotItDisplayed() = true then
        click "OK, GOT IT"
        describe "OK, Got It clicked"
      else describe "Got nothing"

    let isGoToSearchDisplayed() =
      isDisplayed <| "button:contains('Go to Search')"

    let clickGoToSearch() = 
      if isGoToSearchDisplayed() = true then
        click "button:contains('Go to Search')"
        describe "go search button clicked"
      else describe "Got nothing"

    let isSkipDisplayed() =
      isDisplayed <| "#uploadPhotos > div.continue.skip"

    let clickSkip() = 
      if isSkipDisplayed() = true then
        click "Skip"
        describe "Skip link clicked"
      else describe "Got nothing"

    let mobiOkayGotItDisplayed () =
      isDisplayed <| "Okay, got it"

    let mobiOKGotit() =
      if mobiOkayGotItDisplayed() = true then
        click "Okay, got it"
        describe "Okay, got it"
      else describe "Got nothing"

    let handleMobiModals() = 
      clickSkip()
      clickOKGotit()
      clickGoToSearch()
      mobiOKGotit()


    loginForPathAs user =
       username << "somename"
       paswword << "somepassword"
       handleMobiModals()

Snippet from Test Module (note the first instance of the handleMobiModals function is called in the LoginforPathAs function, which is defined in the same page definition module):

module_sometest

open some_page

      "Test 001: Log in and do something" &&& fun _ ->
         newBrowser platform
         loginForPathAs user1     
         displayed  quicknoteSendButton
         click quicknoteSendButton
         handleMobiModals ()
         displayed "Subscribe"

Note: Snippets are edited for simplicity and clarity.


Solution

  • This issue appears to have resolved itself. I believe my most recent auto-update for Chrome fixed the problem.