title: How to download a file with attribute(href) in chrome using selenium webdriver via js executor
body: <p>I want to download a file in Selenium web driver in C#. 
  i have the url in the web element as the attribute href. With that url, i have to download the file through javascript executor. 
  I tried with js executescript to get the file in the form of bytes and then converting it to pdf file and storing in my desired location. But no luck </p>
  
  <pre><code>IWebDriver driver = new ChromeDriver();
  driver.Navigate().GoToUrl("https://www.win-rar.com/predownload.html?&amp;L=0");
  string linkVal = driver.FindElement(By.LinkText("Download WinRAR")).GetAttribute("href");
  var href = "https://www.win-rar.com/fileadmin/winrar-versions/winrar/winrar-x64-571.exe";
  IJavaScriptExecutor js = (IJavaScriptExecutor)driver;
  ///  Object reposne = js.ExecuteScript("arguments[0].setAttribute(arguments[1],arguments[2])", linkVal, "href", "https://www.win-rar.com/postdownload.html?&amp;amp;L=0");
  String script = "document.querySelector('a[href*=\"/print/\"]').setAttribute('download','name-of-the-download-file-recommend-guid-or-timestamp.pdf');";
  ///Object reposne = js.ExecuteAsyncScript(script , href);
  var bytes = Convert.FromBase64String(reposne.ToString());
  File.WriteAllBytes("F:\\file.exe", bytes);
  </code></pre>