I have an automated test with Selenium in C# which uploads files through an Input element in a drag-and-drop area.
Since my Chrome was updated to v75 (now v76) this is no longer working well. Everytime a file is uploaded all previously uploaded files are uploaded again, for example when I try to upload 3 files in a row the first file will be uploaded 3 times, the second one 2 times and the last one only once. The intended behaviour is to have each file just once.
The following code demonstrates the problem:
using Microsoft.VisualStudio.TestTools.UnitTesting;
using OpenQA.Selenium;
using System;
using System.IO;
using System.Reflection;
namespace UnitTestProject1
{
[TestClass]
public class UnitTest1
{
[TestMethod]
public void TestMethod1()
{
var driver = new ChromeDriver(Directory.GetCurrentDirectory(), new ChromeOptions());
driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(15);
var path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
var pdfFile1 = $"{path}\\Files\\Geboorteakte 1.pdf";
var pdfFile2 = $"{path}\\Files\\Geboorteakte 2.pdf";
var input = driver.FindElementByXPath("//input[@type='file']");
input.SendKeys(pdfFile1);
input = driver.FindElementByXPath("//input[@type='file']");
input.SendKeys(pdfFile2);
Assert.AreEqual(2, driver.FindElementsByXPath("//tbody//tr[@role='row']").Count);
}
}
}
The pdf's are two random PDFs in a folder called Files in the project folder with 'Copy always'at Copy to Output Directory.
I'm using Selenium.Chrome.Webdriver 76, Chrome 76 and Selenium.Webdriver 3.141.0
Instead of 2 uploaded files I'm getting 3 uploaded files, the first file uploaded twice.
With Selenium.Chrome.Webdriver 74 and Chrome 74 this code worked fine, both files get uploaded once as intended.
I don't know what is causing the issues since Chrome v 75 and I don't know how to fix it elegantly, can anyone help?
Mark van der Werf