Created
November 15, 2010 02:56
-
-
Save jasonporritt/676364 to your computer and use it in GitHub Desktop.
File upload testing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[When("I choose a photo to upload")] | |
public void UploadImageFor() | |
{ | |
// Where Browser is your current Browser object | |
var fileUpload = Browser.FileUpload(x => x.Name == "Photo"); | |
var assembly = Assembly.GetExecutingAssembly(); | |
var fileStream = assembly.GetManifestResourceStream(assembly.GetName().Name + ".TestData.image.jpg"); | |
var fileData = new byte[fileStream.Length]; | |
fileStream.Read(fileData, 0, fileData.Length); | |
var filePath = Path.GetTempFileName(); | |
var tempFile = File.Create(filePath); | |
tempFile.Write(fileData, 0, fileData.Length); | |
tempFile.Close(); | |
fileUpload.Set(filePath); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment