Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
552 views
in Technique[技术] by (71.8m points)

How to handle Windows file browse window using selenium webdriver

How to handle file window popup using selenium webdriver.

I have clicked on file browse button , new pop up window has been opened and i am unabled to handle this window(as i want to select the file)

 WebElement browser=driver.findElement(By.name("uploadFile"));
browser.click();
driver.switchTo().window("File Upload");
WebElement el=driver.findElement(By.name("fileName"));
el.sendKeys("E:\DVBScheduleEvent.xml");
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I have a sample code for this:

driver.get("http://www.2shared.com/");
        driver.findElement(By.id("upField")).sendKeys("D:\james.xls");
        driver.findElement(By.xpath("//input[@title='Upload file']")).click();
    }

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...