我有一个用 F# 编写的 selenium UI 测试(使用 canopy selenium nuget 包)。我有一个定义页面选择器和辅助函数的模块。页面模块由测试模块调用。在测试模块中,我调用了一个名为“handlemobimodals()”的函数,该函数运行四个子函数(if/else 代码块),用于查找页面上是否存在元素并单击它(如果存在)。
我面临的问题是,当在测试中第二次调用“handlemobimodals()”函数时,我得到一个堆栈溢出异常(WebDriver 进程由于 StackOverflowException 而终止),就在它的第一个子函数被调用之后.
该函数第一次运行完全正常(在测试早期从另一个函数间接调用),但在测试中直接调用时第二次失败。我对 F# 很陌生,我无法弄清楚我是如何在我的测试中导致递归的,正如 stackoverflow 异常所暗示的那样。
任何见解将不胜感激。
页面模块的片段:
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()
来自测试模块的片段(注意在 LoginforPathAs 函数中调用了 handleMobiModals 函数的第一个实例,该函数在同一页面定义模块中定义):
module_sometest
open some_page
"Test 001: Log in and do something" &&& fun _ ->
newBrowser platform
loginForPathAs user1
displayed quicknoteSendButton
click quicknoteSendButton
handleMobiModals ()
displayed "Subscribe"
注意:为了简单明了,对片段进行了编辑。