I am writing python code to automate testing to download files. I have downloaded the file by clicking the download icon. What I am trying now is to assert that correct file was downloaded in the background. For this purpose, I need to extract the get request and parameters within. This parameters and URL will contain values to identify if/whether correct document was downloaded.
Can you please help me. Many thanks.
Below is the code I am running.
import os
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
mime_types = "application/pdf,application/vnd.adobe.xfdf,application/vnd.fdf,application/vnd.adobe.xdp+xml"
fp = webdriver.FirefoxProfile()
fp.set_preference("browser.download.folderList", 2)
fp.set_preference("browser.download.manager.showWhenStarting", False)
fp.set_preference("browser.download.dir", os.getcwd())
fp.set_preference("browser.helperApps.neverAsk.saveToDisk", mime_types)
fp.set_preference("plugin.disable_full_page_plugin_for_types", mime_types)
fp.set_preference("pdfjs.disabled", True)
driver = webdriver.Firefox(firefox_profile=fp)
driver.get('site-name')
# login
driver.find_element_by_class_name('textboxUserName').send_keys(name)
driver.find_element_by_id('dummy1').click()
driver.find_element_by_id('content__login_Password').send_keys(pwd)
driver.find_element_by_id('content__login_Password').send_keys(Keys.RETURN)
# search
driver.find_element_by_id('top-search-input').send_keys('9001')
driver.find_element_by_id('top-search-input').send_keys(Keys.RETURN)
# download
driver.find_element_by_xpath("//ul[@class='search-result-list']/li[1]/div/ul/li[7]").click()
As stated earlier, I want to make sure that the file has been downloaded. So I want to get certain values from GET when the button to download is clicked.
thanks