I have searched StackOverflow and could not find the correct solution for the following problem:
In an internal Sharepoint site, after clicking Upload, and then Folders, I use SendKeys.SendWait to input the directory location,. And then after sending "Enter" as Send.Keys.SendWait, a dialogue box appears, where I need to click the Upload button, but this element is not searchable, as it seems to be not part of the DOM.
Here is the code snippet:
SendKeys.SendWait(@"C:\Automation\Testing\");
SendKeys.SendWait("{Enter}");
SendKeys.SendWait("{Enter}");
IAlert alert = Driver.driver.SwitchTo().Alert();
alert.Accept();
I have also tried to use JavaScript to handle this but it didn't help:
IJavaScriptExecutor jsX = (IJavaScriptExecutor)driver;
jsX.ExecuteScript("Object.defineProperty(BeforeUnloadEvent.prototype,
'returnValue', { get:function(){}, set:function(){} });");
In another thread I noticed a suggestion to add "--disable-notifications" and "--disable-popup-blocking", but that didn't work either.
Here is the code:
ChromeOptions options = new ChromeOptions();
options.AddArguments("disable-infobars", "start-maximized", "no-sandbox", "--disable-notifications", "--disable-popup-blocking");
Driver.driver = new ChromeDriver(options);
What is the best way to find and click the "Upload" in the dialogue box?