Internet explorer webdriver:在internet explorer中上载文件

Internet explorer webdriver:在internet explorer中上载文件,internet-explorer,upload,webdriver,Internet Explorer,Upload,Webdriver,你知道如何在IE中上传文件吗? 这不是我第一次遇到这样的问题,但我总是通过将隐藏的输入文本设置为可见来解决它 JavascriptExecutor jse = (JavascriptExecutor) SelTestCase.driver; WebElement element=SelTestCase.driver.findElement(By.xpath("//input[@type='file']")); String js = "arguments[0].style.visibility

你知道如何在IE中上传文件吗? 这不是我第一次遇到这样的问题,但我总是通过将隐藏的输入文本设置为可见来解决它

JavascriptExecutor jse = (JavascriptExecutor) SelTestCase.driver;
WebElement element=SelTestCase.driver.findElement(By.xpath("//input[@type='file']"));
String js = "arguments[0].style.visibility = 'visible';"
但这一次,我没有看到任何隐藏的风格在输入,所以我真的有想法如何做到这一点。Firefox和chrome运行良好,我只发送了路径,但IE警告元素不可见

有什么想法吗

<div class="btn btn-primary ib-fileupload">
    <span>Upload File</span>
    <input id="channel-image-upload" class="upload pristine" type="file" accept=".jpg,.jpeg,.gif,.png"/>
</div>
尝试直接设置属性,然后单击上载或其他任何操作来触发该操作。而且,请确保您只尝试以下文件类型之一,因为这是所有允许的

.jpg、.jpeg、.gif、.png


有时输入也可能超出页面边界。您可以设置“样式”属性,然后按正常方式键入输入

JavascriptExecutor jse = (JavascriptExecutor) SelTestCase.driver;
WebElement element=SelTestCase.driver.findElement(By.xpath("//input[@type='file']"));
//set the style
String js = "arguments[0].setAttribute('style','position: absolute; opacity: 0;');"
JavascriptExecutor jse = (JavascriptExecutor) SelTestCase.driver;
WebElement element=SelTestCase.driver.findElement(By.xpath("//input[@type='file']"));
//set the style
String js = "arguments[0].setAttribute('style','position: absolute; opacity: 0;');"