def test_special(self): driver = self.driver sleep(4) # name driver.find_element_by_css_selector('#add-camp-name').clear() driver.find_element_by_css_selector('#add-camp-name').send_keys(randoms(100, "special")) # budget driver.find_element_by_css_selector('#add-camp-budget').clear() driver.find_element_by_css_selector('#add-camp-budget').send_keys(randoms(100, "special")) # url driver.find_element_by_css_selector('#add-camp-url').clear() driver.find_element_by_css_selector('#add-camp-url').send_keys("https://%s" % randoms(10, "special")+".com") # objetive driver.find_element_by_css_selector('#add-camp-objetive').clear() driver.find_element_by_css_selector('#add-camp-objetive').send_keys(randoms(100, "special")) # click Save driver.find_element_by_xpath('//div[10]/div[1]/div[1]/div[3]/button[1]').click() sleep(2) # asserts Budget self.assertEqual(driver.find_element_by_xpath('//*[@id="form-add-campaign"]/div[6]/span') .get_attribute('innerHTML'), "Enter a valid budget. Maximum allowed decimals: 2", msg=None) # asserts objetive self.assertEqual(driver.find_element_by_xpath('//*[@id="form-add-campaign"]/div[8]/span') .get_attribute('innerHTML'), "This field is empty", msg=None)
def test_special(self): driver = self.driver sleep(4) # name driver.find_element_by_css_selector('#mod-camp-name').clear() driver.find_element_by_css_selector('#mod-camp-name').send_keys( randoms(100, "special")) # budget driver.find_element_by_css_selector('#mod-camp-budget').clear() driver.find_element_by_css_selector('#mod-camp-budget').send_keys( randoms(100, "special")) # url driver.find_element_by_css_selector('#mod-camp-url').clear() driver.find_element_by_css_selector('#mod-camp-url').send_keys( "https://%s" % randoms(10, "special") + ".com") # objetive driver.find_element_by_css_selector('#mod-camp-objetive').clear() driver.find_element_by_css_selector('#mod-camp-objetive').send_keys( randoms(100, "special")) # click Save driver.find_element_by_xpath( '//*[@id="modal-edit-campaign"]/div/div/div[3]/button').click() sleep(2) # asserts Budget self.assertEqual( "Enter a valid budget. " "Maximum allowed decimals: 2", driver.find_element_by_xpath( '//*[@id="form-edit-campaign"]/div[6]/span').text, msg=None) # asserts objetive self.assertEqual("This field is empty", driver.find_element_by_xpath( '//*[@id="form-edit-campaign"]/div[8]/span').text, msg=None)
def test_min(self): driver = self.driver sleep(2) # name driver.find_element_by_css_selector('#mod-camp-name').clear() driver.find_element_by_css_selector('#mod-camp-name').send_keys( randoms(1, "letter")) # budget driver.find_element_by_css_selector('#mod-camp-budget').clear() driver.find_element_by_css_selector('#mod-camp-budget').send_keys( randoms(1, "number")) # url driver.find_element_by_css_selector('#mod-camp-url').clear() driver.find_element_by_css_selector('#mod-camp-url').send_keys( "https://.com") # objeive driver.find_element_by_css_selector('#mod-camp-objetive').clear() driver.find_element_by_css_selector('#mod-camp-objetive').send_keys( randoms(1, "number")) # click Save driver.find_element_by_xpath( '//*[@id="modal-edit-campaign"]/div/div/div[3]/button').click() self.assertEqual( 'Enter a valid URL.', driver.find_element_by_xpath( '//*[@id="form-edit-campaign"]/div[7]/span').get_attribute( 'innerHTML'))
def test_edit_min(self): driver = self.driver sleep(2) # email driver.find_element_by_xpath('//*[@id="edit-dash-user-email"]').clear() email_format = re.compile(r'\b[\w.%+-]+@([\w.-]{1,64})+\.[a-zA-Z]{2,64}\b') email = "%s@%s.%s" % (randoms(3, "alpha"), randoms(4, "alpha"), randoms(1, "alpha")) self.assertFalse(email_format.match(email), msg=None) driver.find_element_by_xpath('//*[@id="edit-dash-user-email"]').send_keys(email) driver.find_element_by_xpath('//*[@id="modal-edit-dashboard-user"]/div/div/div[3]/button').click() sleep(1) self.assertEqual(driver.find_element_by_xpath('//*[@id="form-edit-dashboard-user"]/div[1]/span') .get_attribute('innerHTML'), "Enter a valid email address.", msg=None)
def test_edit_max(self): driver = self.driver sleep(2) # email driver.find_element_by_xpath('//*[@id="edit-dash-user-email"]').clear() driver.find_element_by_xpath('//*[@id="edit-dash-user-email"]').send_keys(randoms(260, "alpha")) self.assertEqual(len(driver.find_element_by_xpath('//*[@id="edit-dash-user-email"]').get_attribute("value")), 255, msg=None) email_format = re.compile(r'\b[\w.%+-]+(@[\w.-]{1,64})+\.[a-zA-Z]{2,64}\b') # email platform email = "%s@%s.%s" % (randoms(3, "alpha"), randoms(65, "alpha"), randoms(2, "alpha")) self.assertFalse(email_format.match(email), msg=None) driver.find_element_by_xpath('//*[@id="edit-dash-user-email"]').send_keys(email) driver.find_element_by_xpath('//*[@id="modal-edit-dashboard-user"]/div/div/div[3]/button').click() sleep(1) self.assertEqual(driver.find_element_by_xpath('//*[@id="form-edit-dashboard-user"]/div[1]/span') .get_attribute('innerHTML'), "Enter a valid mail", msg=None) # email extension email = "%s@%s.%s" % (randoms(3, "alpha"), randoms(2, "alpha"), randoms(65, "alpha")) self.assertFalse(email_format.match(email), msg=None) driver.find_element_by_xpath('//*[@id="edit-dash-user-email"]').send_keys(email) driver.find_element_by_xpath('//*[@id="modal-edit-dashboard-user"]/div/div/div[3]/button').click() sleep(1) self.assertEqual(driver.find_element_by_xpath('//*[@id="form-edit-dashboard-user"]/div[1]/span') .get_attribute('innerHTML'), "Enter a valid mail", msg=None) driver.find_element_by_xpath('//*[@id="edit-dash-user-name"]').clear() driver.find_element_by_xpath('//*[@id="edit-dash-user-name"]').send_keys(randoms(260, "alpha")) self.assertEqual(len(driver.find_element_by_xpath('//*[@id="edit-dash-user-name"]').get_attribute("value")), 255, msg=None) # save driver.find_element_by_xpath('//*[@id="modal-edit-dashboard-user"]/div/div/div[3]/button').click()
def test_min(self): driver = self.driver sleep(2) # name driver.find_element_by_css_selector('#mod-camp-name').clear() driver.find_element_by_css_selector('#mod-camp-name').send_keys( randoms(1, "letter")) # budget driver.find_element_by_css_selector('#mod-camp-budget').clear() driver.find_element_by_css_selector('#mod-camp-budget').send_keys( randoms(1, "number")) # url driver.find_element_by_css_selector('#mod-camp-url').clear() driver.find_element_by_css_selector('#mod-camp-url') \ .send_keys("https://%s" % randoms(1, "letter")+".com") # objeive driver.find_element_by_css_selector('#mod-camp-objetive').clear() driver.find_element_by_css_selector('#mod-camp-objetive').send_keys( randoms(1, "number"))
def test_max(self): driver = self.driver sleep(2) # name driver.find_element_by_css_selector('#mod-camp-name').clear() driver.find_element_by_css_selector('#mod-camp-name').send_keys( randoms(250, "letter")) # Máximo 99999999999999999.99 driver.find_element_by_css_selector('#mod-camp-budget').clear() driver.find_element_by_css_selector('#mod-camp-budget').send_keys( randoms(18, 'number')) driver.find_element_by_css_selector('#mod-camp-url').clear() driver.find_element_by_css_selector('#mod-camp-url').send_keys( "https://%s" % randoms(501, "letter") + ".com") driver.find_element_by_css_selector('#mod-camp-objetive').clear() driver.find_element_by_css_selector('#mod-camp-objetive').send_keys( '21474836488') driver.find_element_by_xpath( '//*[@id="modal-edit-campaign"]/div/div/div[3]/button').click() sleep(2) # asserts self.assertEqual(driver.find_element_by_xpath( '//*[@id="form-edit-campaign"]/div[6]/span').get_attribute( 'innerHTML'), "Enter a valid budget. Maximum allowed decimals: 2", msg=None) self.assertEqual(driver.find_element_by_xpath( '//*[@id="form-edit-campaign"]/div[8]/span').get_attribute( 'innerHTML'), "Please input a value between 0-2147483647.", msg=None) self.assertEqual(len( driver.find_element_by_css_selector( '#mod-camp-name').get_attribute("value")), 250, msg=None) self.assertEqual(len( driver.find_element_by_css_selector('#mod-camp-url').get_attribute( "value")), 500, msg=None)
def test_max_min(self): driver = self.driver self.select_test() sleep(5) # ######################### Maximum ######################### driver.find_element_by_css_selector( '#form-%s-creative #%s-creative-name' % (type_modal, type_modal)).clear() driver.find_element_by_css_selector('#form-%s-creative #%s-creative-name' % (type_modal, type_modal))\ .send_keys(randoms(251, "letter")) driver.find_element_by_css_selector( '#form-%s-creative #%s-creative-measure' % (type_modal, type_modal)).clear() driver.find_element_by_css_selector('#form-%s-creative #%s-creative-measure' % (type_modal, type_modal)).\ send_keys(randoms(251, "number")) driver.find_element_by_css_selector( '#form-%s-creative #%s-creative-url' % (type_modal, type_modal)).clear() driver.find_element_by_css_selector('#form-%s-creative #%s-creative-url' % (type_modal, type_modal)).\ send_keys("http://"+randoms(244, "letter")) sleep(1) self.assertEqual( 250, len( driver.find_element_by_css_selector( '#form-%s-creative #%s-creative-name' % (type_modal, type_modal)).get_attribute("value")), msg=None) self.assertEqual( 250, len( driver.find_element_by_css_selector( '#form-%s-creative #%s-creative-measure' % (type_modal, type_modal)).get_attribute("value")), msg=None) self.assertEqual( 250, len( driver.find_element_by_css_selector( '#form-%s-creative #%s-creative-url' % (type_modal, type_modal)).get_attribute("value")), msg=None) path = "clients/campaigns/creatives/screenshot/test_max_" + type_modal + "_creative" screenshot(self, path) # ########################################################### # ######################### Minimum ######################### driver.find_element_by_css_selector( '#form-%s-creative #%s-creative-url' % (type_modal, type_modal)).clear() driver.find_element_by_css_selector('#form-%s-creative #%s-creative-url' % (type_modal, type_modal))\ .send_keys("http:") driver.find_element_by_xpath( '//*[@id="modal-%s-creative"]/div/div/div[3]/button' % type_modal).click() self.assertEqual( "Enter a valid URL.", driver.find_element_by_css_selector( '#form-%s-creative > div.form-group.has-error > ' 'span.help-block' % type_modal).get_attribute("innerText"), msg=None) path = "clients/campaigns/creatives/screenshot/test_min_" + type_modal + "_creative" screenshot(self, path)