Twelve
Twelve

Reputation: 597

How to upload file in canopy?

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.

Upvotes: 1

Views: 462

Answers (1)

CaringDev
CaringDev

Reputation: 8551

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.

Upvotes: 1

Related Questions