title: Selenium Chromedriver Headless mode problem, does not load an url
body: <p>Im a noob at programming I just started learning recently. I made a script to automate a process using selenium for python.The script logs in a webpage, scraps some info and downloads some pdf files some through wget others through requests because of the webpage structure and my limitations.</p>
  <p>It works well but <strong>if I run it on headless mode</strong> it <strong>fails</strong> to download the file through wget. To get the url for this file I click on a href and then use the current_url method. <strong>Here's where the problem seems to be</strong> as I've printed the url and returns the previous url as if it hadn't clicked on the link therefore not loading the requiered page.</p>
  <p>Might be important to point out that this href calls for a script(<em>I suppose</em>) to create the pdf and then redirects me to the actual url which is actually public. Heres the href:</p>
  <p>&quot;https://&quot;WEBPAGE.COM&quot;/admin.php?method=buildPDF&amp;scode=JT9UM1FL5MP0P57UXFP6R5FT6LPE&quot;</p>
  <p>I did some research and tought it might be opening the pdf on another tab so I tried switching tabs to the same result.</p>
  <p>Here's a sample of the code:</p>
  <pre><code>driver.get(&quot;https://webpage.com/&quot;)
  time.sleep(5)
  driver.find_element_by_xpath('//div[text()='+variable+']//ancestor::td[1]//following::a[1]').click()
  time.sleep(2)
  pr=driver.current_url
  print(pr)
  url= pr
  filename= variable + &quot;.pdf&quot; 
      
  wget.download(url,'path')
  </code></pre>
  <p>All other &quot;click()&quot;s in the code work fine and I also tried increasing sleep up to 10 seconds but nothing works.</p>
  <p>Any help/advise is really appreciated</p>
  <p>Thanks</p>