I have two buttons on my page, one for viewing a pdf (opens in new tab) and one for downloading pdf (downloads it directly by adding the attachment header.
Here's my testing code so far:
def test_study_popover_view_clicked(self):
cls.selenium_chrome.get('https://www.shenkan-associates.com/')
try:
target_element_chrome = cls.selenium_chrome.find_element_by_id('study-item-7')
target_element_chrome.click()
popover_element_chrome = cls.selenium_chrome.find_element_by_class_name('popover')
popover_view_button_element_chrome = cls.selenium_chrome.findElement(By.cssSelector('.popover > .popover-content > .popover-actions > .study-view'))
except NoSuchElementException as ex:
self.fail(ex.msg)
nt.assert_true(popover_element_chrome.is_displayed())
nt.assert_true(popover_view_button_element_chrome.is_displayed())
nt.assert_equal(popover_view_button_element_chrome.text, 'View')
popover_view_button_element_chrome.click()
def test_study_popover_download_clicked(self):
cls.selenium_chrome.get('https://www.shenkan-associates.com/')
try:
target_element_chrome = cls.selenium_chrome.find_element_by_id('study-item-7')
target_element_chrome.click()
popover_element_chrome = cls.selenium_chrome.find_element_by_class_name('popover')
popover_download_button_element_chrome = cls.selenium_chrome.findElement(By.cssSelector('.popover > .popover-content > .popover-actions > .study-download'))
except NoSuchElementException as ex:
self.fail(ex.msg)
nt.assert_true(popover_element_chrome.is_displayed())
nt.assert_true(popover_download_button_element_chrome.is_displayed())
nt.assert_equal(popover_download_button_element_chrome.text, 'Download')
popover_download_button_element_chrome.click()
As you can see I click the download and view button elements. at the end of each method. Clicking view should open a pdf in a separate tab. Clicking download should start to download the pdf directly.
I just need a way to test that the buttons are doing what they should.
How can I test this?
Thanks
Aucun commentaire:
Enregistrer un commentaire