2012-07-12 2 views
3

Chrome의 Selenium WebDriver로 파일을 업로드하는 방법.셀레늄 webdriver. NET 크롬 업로드 파일

버전 Chrome (20.0.1132.57). 버전 chromedriver 22.0.1203.0b 코드

:

driver.GetElement(someXpath).SendKeys(filePath) 

가 발생 예외 :

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

HTML 코드 : 당신은 요소를 강제 할 수

<a class="button addfile"> Upload <input class="fileupload" type="file" multiple="" name="files[]"/> </a> 
+0

클릭 가능하지 않은 요소는 사전에 비활성화되어 있습니까? 그렇다면 SendKeys() –

+1

이 요소가 활성화되어 페이지에서 볼 수 있기 전에 wait 명령을 추가해야 할 수 있습니다. –

+1

이 코드가 제대로 작동하지만 FireFox에서 Chrome에서 테스트를 실행해야합니다. –

답변

2

이 표시 될 JavaScript를 사용합니다. input 요소의 경우 IJavaScriptExecutor를 사용하여 JavaScript를 실행하고 요소의 가시성을 표시하도록 설정하고 좋은 측정을 위해 치수를 지정합니다.

((JavascriptExecutor)driver).ExecuteScript("arguments[0].style.visibility = 'visible'; 
arguments[0].style.height = '1px'; arguments[0].style.width = '1px'; 
arguments[0].style.opacity = 1", fileUploadElement); 
관련 문제