问题
Currently i wish to run selenium for test excel upload. And my coding didn't working as expected. Just wondering how to resolve it. Every time i run the automated testing my code will be stop at this step:sendKeys("C:\Users\user\Desktop\JSPL Style Excel Upload.csv") without any error message show. Any suggestion?
@Before
public void setUp() throws Exception {
driver = new FirefoxDriver();
baseUrl = "http://localhost:7101/";
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
}
public void testJava() throws Exception {
driver.get(baseUrl + "SCM_Telephone_Accounting_2-ViewController-context-root/faces/Main_Menu");
driver.findElement(By.id("np2:cni10")).click();
driver.findElement(By.id("r1:1:if1::content")).click();
driver.findElement(By.id("r1:1:if1::content")).clear();
driver.findElement(By.id("r1:1:if1::content")).sendKeys("C:\\Users\\user\\Desktop\\JSPL Style Excel Upload.csv");
driver.findElement(By.id("r1:1:cb1")).click();
}
来源:https://stackoverflow.com/questions/27917882/test-upload-file-in-selenium