1
2
3
4
5
6
7
8
9 |
public void uploadLocalFileToServer(String uploadFileName){ String AutomationPath = System.getProperty( "user.dir" ); String filePath=AutomationPath+ "\\src\\test\\resources\\testData\\" +uploadFileName; logger.info( "Upload file path : " +filePath); WebElement magnifyIcon = page.getMagnifyIconOfSampleReport(); magnifyIcon.sendKeys(filePath); Assert.assertEquals(page.getSampleReportTxtInput().getAttribute( "value" ),uploadFileName,uploadFileName+ " should be listed in Sample Report ." ); Assert.assertTrue(page.getSampleReportDeleteIcon().isDisplayed(), uploadFileName+ " should be listed in Sample Report with a delete icon on the right." ); } |
1
2
3 |
public WebElement getMagnifyIconOfSampleReport(){ return
SeleniumUtil.waitForElementPresent(driver, By.cssSelector( "div#tmpmgrDiv div.upsmpbtnc a#upSmp.filea input.file" )); } |
Selenium如何实现上传本地文件,布布扣,bubuko.com
原文地址:http://www.cnblogs.com/MasterMonkInTemple/p/3737255.html