Skip to content

Commit 4497162

Browse files
committed
Slight refactor for uploading same file multiple times in .NET
1 parent d28fa64 commit 4497162

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

dotnet/test/common/FormHandlingTests.cs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -202,19 +202,16 @@ public void ShouldBeAbleToUploadTheSameFileTwice()
202202
inputFileWriter.WriteLine("Hello world");
203203
inputFileWriter.Close();
204204

205-
driver.Url = formsPage;
206-
IWebElement uploadElement = driver.FindElement(By.Id("upload"));
207-
Assert.IsTrue(string.IsNullOrEmpty(uploadElement.GetAttribute("value")));
208-
209-
uploadElement.SendKeys(inputFile.FullName);
210-
uploadElement.Submit();
205+
for (int i = 0; i < 2; ++i)
206+
{
207+
driver.Url = formsPage;
208+
IWebElement uploadElement = driver.FindElement(By.Id("upload"));
209+
Assert.IsTrue(string.IsNullOrEmpty(uploadElement.GetAttribute("value")));
211210

212-
driver.Url = formsPage;
213-
uploadElement = driver.FindElement(By.Id("upload"));
214-
Assert.IsTrue(string.IsNullOrEmpty(uploadElement.GetAttribute("value")));
211+
uploadElement.SendKeys(inputFile.FullName);
212+
uploadElement.Submit();
213+
}
215214

216-
uploadElement.SendKeys(inputFile.FullName);
217-
uploadElement.Submit();
218215
// If we get this far, then we're all good.
219216
}
220217

0 commit comments

Comments
 (0)