简体   繁体   中英

C# Selenium: Send keys ""{ENTER}"" not working

Trying to paste file path in windows file upload, when I pass filepath in sendwait it does not paste entire data all the time,so was trying with the below but enter key is not working in this case, not sure why. Kindly help.

Code:

Clipboard.SetDataObject(FilePath,false,2,2000);
SendKeys.SendWait("^{V}");
SendKeys.SendWait(@"{ENTER}");

Have you tried to send the path, straight to the input element? That is the best way to upload a file, using Selenium.

Example:

Driver.FindElement(By.ClassName("upload")).SendKeys(path);

You're finding the input element, which is responsible for upload and sending a path to it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM