【发布时间】:2015-05-22 10:10:00
【问题描述】:
以下是我的 Firefox 配置文件的非工作代码。
@Before
public void setUp() throws Exception {
FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("browser.helperApps.alwaysAsk.force", false);
profile.setPreference("browser.download.manager.showWhenStarting",false);
profile.setPreference("browser.download.dir", "/Location");
profile.setPreference("browser.helperApps.neverAsk.saveToDisk","text/docx");
driver=new FirefoxDriver(profile);
baseUrl = "<URL>";
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
}
@Test
public void test1() throws Exception {
driver.get("URL");
driver.findElement(By.id("Username")).sendKeys("username");
driver.findElement(By.id("Password")).sendKeys("Password");
driver.findElement(By.xpath(".//*[@id='rowCell0']/td[4]/a[4]")).click();// This line of code is for Download Link on the UI
现在一旦 selenium 点击它,Firefox 将再次打开确认框,询问“打开方式”和“保存文件”。
【问题讨论】:
-
你遇到了什么错误?
-
没有报错,但是每次我运行这段代码,火狐点击下载链接时总是会打开确认框(但是,实际上已经写了不要打开它,直接下载点击)。我不确定我哪里出错了。