가능한 중복 : 난 당신이 날 어떻게 셀레늄을 사용하여 Internet Explorer에서 파일 업로드를 자동화하는 전화를하시기 바랍니다 Selenium.Can에 새로운 오전
How to upload a file from a site using Selenium's java intefaceSelenium을 사용하여 Internet Explorer에서 파일 업로드를 자동화하는 방법은 무엇입니까?
?
가능한 중복 : 난 당신이 날 어떻게 셀레늄을 사용하여 Internet Explorer에서 파일 업로드를 자동화하는 전화를하시기 바랍니다 Selenium.Can에 새로운 오전
How to upload a file from a site using Selenium's java intefaceSelenium을 사용하여 Internet Explorer에서 파일 업로드를 자동화하는 방법은 무엇입니까?
?
쉬운 일이 아니며 아주 좋은 이유로 보안이 쉽지 않습니다 - 보안. 이와 같은 것을 업로드 할 수 있다면, 동일한 방법을 사용하여 세부 정보를 업로드하는 누군가가 멈추는 것은 무엇입니까?
당신은 또한 우리에게 그렇게 작업 할 예 주어지지 않은:
을 감안할 때이 샘플 웹 페이지 :
<html>
<head>
<style type="text/css">
.fileSave { color: red; }
</style>
</head>
<label for="fileUpload">File location:
<input type="file" id="fileUpload" />
<br>
<br>
<a href="" class="fileSave">Save file</a>
</body>
</html>
내가 C#으로,이 작업을 수행 할 수 있습니다
Driver = new ChromeDriver();
var fileUploadControl = Driver.FindElement(By.Id("fileUpload"));
fileUploadControl.SendKeys("C:\File.txt");
var submitLink = Driver.FindElement(By.ClassName("fileSave"));
submitLink.Click();
이있다 several times을 물었고 Selenium FAQ에도 있습니다.
셀레늄이 (WebDriver) 자바 예 :
셀레늄 RC를 들어// assuming driver is a healthy WebDriver instance
WebElement fileInput = driver.findElement(By.xpath("//input[@type='file']"));
fileInput.sendKeys("C:/path/to/file.jpg");
, this question를 참조하십시오.
아이디어는 파일의 절대 경로를 직접 클릭하여 모달 창을 가져 오는 요소 (즉, <input type='file' />
요소)로 직접 보내는 것입니다.
"이와 같은 것을 업로드 할 수 있다면, 같은 방법으로 내 세부 정보를 업로드 한 사람이 무엇을 멈추게할까요?" 어느 정도까지, CAPTCHA는 것입니다. – fixxxer