【发布时间】:2015-02-25 18:28:13
【问题描述】:
我正在尝试上传文件但没有成功,我找到了这个例子:
WebElement element = getSupport().getDriver().findElement(By.xpath(".//input[@type='file']"));
element.sendKeys("D:/Profiles/user/workspace/copla-selenium/src/test/resources/datasets/default/test-image.jpg");
但我收到此错误:
2015-02-23 17:32:59 ERROR root:97 - 测试失败 org.openqa.selenium.WebDriverException:未知错误:无法聚焦 元素
有什么想法吗?谢谢!
【问题讨论】:
-
应该有一个
input元素负责上传字段。 -
我真的不明白你的意思,在这个例子中就像我做的那样:example
-
查看该线程中使用的 xpath 指向
input元素 - 你的指向a元素。这可能是这里的问题。 -
我知道你的意思..我改变了它,现在我没有收到任何错误但它没有加载图像
-
显示你要上传文件的部分代码。
标签: java selenium automated-tests