我是 F# Canopy 的新手,正在测试在https://www.treasurydirect.gov/GA-FI/FedInvest/selectSecurityPriceDate.htm的输入框中输入日期。运行下面的 Canopy 代码时,我收到一个“用户未处理”异常,说明“canopy.types.ConaopyElementNotFoundException: 'can't find element id=priceDate.month'”虽然可以在页面源中看到该元素以及用于 Chrome 的 Selenium Page Object Generator 和 Selenium Object Finder 扩展。似乎对于某些页面对象,Canopy 无法识别这些元素……或者我遗漏了一些东西。有什么想法吗?
open System
open canopy
open canopy.runner.classic
open canopy.configuration
open canopy.classic
[<EntryPoint>]
let main argv =
canopy.configuration.chromeDir <- System.AppContext.BaseDirectory
//start an instance of chrome
start chrome
"testing UST prices" &&& fun _ ->
//this is an F# function body, it's whitespace enforced
//go to url
url "https://www.treasurydirect.gov/GA-FI/FedInvest/selectSecurityPriceDate.htm"
click "id=priceDate.month"
"id=priceDate.month" << "3"
click "id=priceDate.day"
"id=priceDate.day" << "31"
click "id=priceDate.year"
"id=PriceDate.year" << "2020"
click "Show Prices"
click "CSV Format"
//run all tests
run()
printfn "press [enter] to exit"
System.Console.ReadLine() |> ignore
quit()
0