How to upload file in canopy?

461 Views Asked by At

I have an upload file input on page. How can I test this element in canopy? How to set path to file in input? I tried standard '<<' operator but it doesn't seem to be working in this case.

1

There are 1 best solutions below

0
CaringDev On

Setting the file upload input to the full name of the file should be all you need. The following works for me:

#r "../packages/Selenium.WebDriver.2.48.2/lib/net40/WebDriver.dll"
#r "../packages/Selenium.Support.2.48.2/lib/net40/WebDriver.Support.dll"
#r "../packages/canopy.0.9.43/lib/canopy.dll"

open canopy
open System.IO

// I copied chromedriver.exe next to the script file
chromeDir <- __SOURCE_DIRECTORY__

start chrome
url "https://encodable.com/uploaddemo/"
let fileToUpload = FileInfo(Path.Combine(__SOURCE_DIRECTORY__, __SOURCE_FILE__))
"#uploadname1" << fileToUpload.FullName
click "#uploadbutton"

I'm not affiliated with encodable.com in any way. Please use your own service for testing.

Related Questions in F#