【发布时间】:2015-06-11 14:01:23
【问题描述】:
您好,您能帮我在 Safari 和 Mac OS 中上传文件吗?
我提供了一个网站,我们可以通过单击“选择文件”按钮上传以下类型的文件(JPG、PNG、GIF、DOC、XLS、PDF、ZIP、RAR、ZIPX)
package Default;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.Alert;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.safari.SafariDriver;
public class Safari_demo {
public static void main(String[] args) throws InterruptedException{
WebDriver driver = new SafariDriver();
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
Thread.sleep(6000);
driver.get("http://www.files.com/");
driver.findElement(By.id("uploadFields")).click();
//can you please help me with code in this line
//this is the place were i need to enter the address of the
//file which is in my system
driver.close();
}
}
【问题讨论】:
-
driver.findElement(By.id("youruploadbuttonid")).sendKeys("yourpicturelocalpath");
-
你能解决这个问题吗?
标签: java macos selenium safari