1

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();
  }
goh6319
  • 137
  • 1
  • 3
  • 20
  • 3
    What exactly do you mean by "And my coding didn't working as expected." What are you expecting, and how does the outcome of this code differ? – Jonny Henly Jan 13 '15 at 08:40
  • Have you looked at similar questions such as http://stackoverflow.com/questions/6128208/how-to-deal-with-file-uploading-in-test-automation-using-selenium-or-webdriver ? – reto Jan 13 '15 at 08:42
  • @JonnyHenly: my auto run test case will be stop at this step: driver.findElement(By.id("r1:1:if1::content")).sendKeys("C:\\Users\\user\\Desktop\\JSPL Style Excel Upload.csv"); – goh6319 Jan 13 '15 at 08:48
  • @reto: i testing the method now. – goh6319 Jan 13 '15 at 08:52
  • Is the element with id **`r1:1:if1::content`** a textfield where you enter the path of the file to upload ? – Subh Jan 13 '15 at 09:44
  • Did U read webdriver FAQ about file upload? – SkorpEN Jan 13 '15 at 09:50
  • 1
    I resolve it already~ The link provided by @reto really work. Thank you very much. (^^) – goh6319 Jan 14 '15 at 02:31

0 Answers0