嗨,你可以幫助我在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」); –