Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

selenium webdriver .Net chrome upload file

How to upload file with Selenium WebDriver in Chrome .NET.

Version Chrome (20.0.1132.57). Version chromedriver 22.0.1203.0b

Code:

driver.GetElement(someXpath).SendKeys(filePath)

throws exception:

Element is not clickable at point (144, 90.5). Other element would receive the click: <h2>...</h2>

HTML-code:

<a class="button addfile"> Upload <input class="fileupload" type="file" multiple="" name="files[]"/> </a>
like image 938
Anvar Ramazanov Avatar asked Mar 17 '26 00:03

Anvar Ramazanov


1 Answers

You can force the element to be visible using JavaScript. For the input element, execute JavaScript using the IJavaScriptExecutor, and set the visibility of the element visible, and for good measure, give it some dimensions.

    ((JavascriptExecutor)driver).ExecuteScript("arguments[0].style.visibility = 'visible';
arguments[0].style.height = '1px'; arguments[0].style.width = '1px'; 
arguments[0].style.opacity = 1", fileUploadElement);
like image 184
Nathan Dace Avatar answered Mar 18 '26 14:03

Nathan Dace



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!