stuartjay
stuartjay

Reputation: 47

Uploading a file that is stored on the internet - "path is not absolute" error

I have a Selenium test running with ChromeDriver, that uploads a video file by using SendKeys to provide a path to the file element, circumventing the dialog box.

Driver.FindElement(By.Id("videoFile")).SendKeys("C:\src\TestFiles\testvideo.mp4");

I'm in the process of moving our build boxes to the cloud to save time/money/effort, but this means that using locally-stored files is no longer sustainable, so I've moved them to a website.

I've tried to replace the local path with the full http path, but am getting the below error

error: unknown error: path is not absolute: https://example.cloudfront.net/999/testvideo.mp4

This process works when I do it manually through the dialog box, so I'm not sure what I'm missing.

Any help would be greatly appreciated.

Upvotes: 1

Views: 903

Answers (1)

Saifur
Saifur

Reputation: 16201

Try

Driver.FindElement(By.Id("videoFile")).SendKeys(@"string filepath");

@ marks the string as a verbatim string literal - anything in the string that would normally be interpreted as an escape sequence is ignored.

See this enter image description here

Upvotes: 1

Related Questions