public void DownloadVSComunity2017() { WebDriverAPI.ClickOnElement(downloadVSlink); string userPath = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile); string downloadPath = Path.Combine(userPath, "Downloads"); ChromeOptions chromeOptions = new ChromeOptions(); chromeOptions.AddUserProfilePreference("download.default_directory", downloadPath); DirectoryInfo dirInfo = new DirectoryInfo(downloadPath); dirInfo = new DirectoryInfo(downloadPath); int directoryFiles = dirInfo.EnumerateFiles().Count(); Actions action = new Actions(driver); IWebElement elem = driver.FindElement(downloadVSForWindows); action.MoveToElement(elem).Perform(); WebDriverAPI.ClickOnElement(downloadComunity2017); Thread.Sleep(10000); dirInfo = new DirectoryInfo(downloadPath); int currentFiles = dirInfo.EnumerateFiles().Count(); Assert.Greater(currentFiles, directoryFiles); }
public static void ClickOnWebElement(By element) { driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(5); WebDriverAPI.ClickOnElement(element); }