嗨,你可以帮助我在Safari,Mac OS中上传文件。如何使用selenium webdriver在SafariDriver/Safari中上传文件?
我已经给了一个位点,我们可以通过点击 “选择文件” 上传以下类型文件的按钮(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”); –