Esempio n. 1
0
 def test_url_format(self):
     global type_modal
     driver = self.driver
     self.select_test()
     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-measure' %
         (type_modal, type_modal)).clear()
     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("www.algo.com")
     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:nth-child(5) > span' %
                          type_modal).get_attribute("innerText"),
                      msg=None)
     path = "clients/campaigns/creatives/screenshot/test_url_format_" + type_modal + "_creative"
     screenshot(self, path)
Esempio n. 2
0
 def test_data_required(self):
     driver = self.driver
     path = "login/screenshot/test_data_required"
     self.assertEqual("We are",
                      driver.find_element_by_xpath('//*[@id="we"]').text,
                      msg=None)
     self.assertEqual(
         "Cerebro Smart Media",
         driver.find_element_by_xpath('//*[@id="content"]/h2').text,
         msg=None)
     self.assertEqual(
         "Please login to your account",
         driver.find_element_by_xpath('//*[@id="subtitle"]').text,
         msg=None)
     self.assertEqual("keep me signed in",
                      driver.find_element_by_xpath(
                          '//*[@id="container_remember"]/label').text,
                      msg=None)
     self.assertEqual(
         "Forgot password?",
         driver.find_element_by_xpath('//*[@id="content"]/p/a').text,
         msg=None)
     driver.find_element_by_xpath('//*[@id="formLogin"]/button').click()
     sleep(2)
     self.assertEqual("Email is required",
                      driver.find_element_by_xpath(
                          '//*[@id="formLogin"]/div[1]/span').text,
                      msg=None)
     screenshot(self, path)
Esempio n. 3
0
 def test_reset_data_required(self):
     driver = self.driver
     path = "login/screenshot/test_reset_data_required"
     driver.find_element_by_xpath('//*[@id="content"]/p/a').click()
     sleep(2)
     self.assertIn(ModelConfig.base_url + "/admin/password_reset/",
                   driver.current_url,
                   msg=None)
     self.assertEqual("We are",
                      driver.find_element_by_xpath('//*[@id="we"]').text,
                      msg=None)
     self.assertEqual(
         "Cerebro Smart Media",
         driver.find_element_by_xpath('//*[@id="content"]/h2').text,
         msg=None)
     self.assertEqual(
         "Recover password",
         driver.find_element_by_xpath('//*[@id="subtitle"]').text,
         msg=None)
     self.assertEqual(
         "We can help you reset your password and\nsecurity information. First write your "
         "account\nand follow the instructions below.",
         driver.find_element_by_css_selector('#content > p').text,
         msg=None)
     self.assertEqual(
         "RESET MY PASSWORD",
         driver.find_element_by_xpath(
             '//*[@id="content"]/form/fieldset/button').text.upper(),
         msg=None)
     driver.find_element_by_xpath(
         '//*[@id="content"]/form/fieldset/button').click()
     sleep(5)
     self.assertEqual("Completa este campo", driver.page_source)
     screenshot(self, path)
Esempio n. 4
0
 def test_campaign(self):
     global campaign
     driver = self.driver
     # login
     login(self)
     sleep(2)
     # Click en clientes
     driver.find_element_by_xpath('//*[@id="inputSrc"]').click()
     sleep(1)
     driver.find_element_by_xpath('//*[@id="search"]').send_keys(client)
     sleep(2)
     driver.find_element_by_xpath(
         '//*[@id="clienttable"]/tbody/tr[1]/td[5]/a[1]/i').click()
     sleep(1)
     # Click en edit
     driver.find_element_by_xpath("//tr[1]/td[8]/a[2]").click()
     sleep(2)
     path = "clients/campaigns/screenshot/"
     screenshot(self, path)
     # name
     driver.find_element_by_css_selector("#mod-camp-name").clear()
     driver.find_element_by_css_selector("#mod-camp-name").send_keys(
         (info[1]["name"]))
     # budget
     driver.find_element_by_css_selector("#mod-camp-budget").clear()
     driver.find_element_by_css_selector("#mod-camp-budget").send_keys(
         (info[1]["budget"]))
     #  url
     driver.find_element_by_css_selector("#mod-camp-url").clear()
     driver.find_element_by_css_selector("#mod-camp-url").send_keys(
         (info[1]["url"]))
     # Objetive
     driver.find_element_by_css_selector("#mod-camp-objetive").clear()
     driver.find_element_by_css_selector("#mod-camp-objetive").send_keys(
         (info[1]["objetive"]))
     driver.find_element_by_xpath(
         '//*[@id="form-edit-campaign"]/div[9]/div/p/a').click()
     # Save
     driver.find_element_by_xpath(
         "//*[@id='modal-edit-campaign']/div/div/div[3]/button").click()
     sleep(2)
     # asserts
     self.assertEqual(info[1]['name'],
                      driver.find_element_by_xpath('//tr[1]/td[3]').text,
                      msg=None)
     self.assertEqual(
         float(info[1]['budget']),
         float(driver.find_element_by_xpath('//tr[1]/td[5]').text),
         msg=None)
     self.assertEqual(
         float(info[1]['objetive']),
         float(driver.find_element_by_xpath('//tr[1]/td[6]').text),
         msg=None)
     sleep(10)
     self.assertTrue(os.path.exists(file_path), msg=None)
Esempio n. 5
0
    def test_consult_client_success(self):
        browser_name = self.driver.capabilities['browserName']
        # print(browserName)
        path = "clients/client/screenshot/test_consult_client_success"
        info = json.loads(clients)

        # login
        login(self)
        sleep(3)
        driver = self.driver
        self.assertIn(
            "http://stage.eupam5k9mb.us-west-2.elasticbeanstalk.com/admin/clients/",
            driver.current_url,
            msg=None)
        # time.sleep(3)
        # driver.find_element_by_xpath('//*[@id="sections-access"]/div[2]/a').click()
        sleep(1)
        driver.find_element_by_xpath('//*[@id="inputSrc"]/img').click()
        driver.find_element_by_id('search').send_keys(rfc_inexist)
        sleep(3)
        self.assertEqual("No record found",
                         driver.find_element_by_xpath(
                             '//*[@id="clienttable"]/tbody/tr/td').text,
                         msg=None)
        sleep(3)
        screenshot(self, path)
        sleep(3)
        driver.find_element_by_id('search').clear()
        if browser_name == 'internet explorer':
            driver.find_element_by_xpath('//*[@id="inputSrc"]/img').click()
        driver.find_element_by_id('search').send_keys(info[0]['rfc'])
        sleep(3)
        self.assertEqual(info[0]['email'],
                         driver.find_element_by_xpath(
                             '//*[@id="clienttable"]/tbody/tr[1]/td[1]').text,
                         msg=None)
        self.assertEqual(info[0]['name'],
                         driver.find_element_by_xpath(
                             '//*[@id="clienttable"]/tbody/tr[1]/td[2]').text,
                         msg=None)
        self.assertEqual(info[0]['rfc'],
                         driver.find_element_by_xpath(
                             '//*[@id="clienttable"]/tbody/tr[1]/td[3]').text,
                         msg=None)
        self.assertEqual('active',
                         driver.find_element_by_xpath(
                             '//*[@id="clienttable"]/tbody/tr[1]/td[4]').text,
                         msg=None)
        screenshot(self, path)
        sleep(3)
Esempio n. 6
0
 def test_add_client(self):
     global campaign, value
     driver = self.driver
     # login
     login(self)
     sleep(2)
     # Click en clientes
     driver.find_element_by_xpath('//*[@id="inputSrc"]').click()
     sleep(1)
     driver.find_element_by_xpath('//*[@id="search"]').send_keys(client)
     sleep(2)
     driver.find_element_by_xpath(
         '//*[@id="clienttable"]/tbody/tr[1]/td[5]/a[1]').click()
     sleep(2)
     self.assertEqual(driver.find_element_by_xpath(
         '//*[@id="campaigntable"]/tbody/tr/td[@title="%s"]' %
         value[0]).get_attribute("innerText").replace("\t", ""),
                      info[0]['name'],
                      msg=None)
     self.assertEqual(
         "%s" % value[1],
         driver.find_element_by_xpath(
             '//*[@id="campaigntable"]/tbody/tr[1]/td[4]').get_attribute(
                 "innerText").replace("\t", ""),
         msg=None)
     self.assertEqual(
         "%s" % value[2],
         driver.find_element_by_xpath(
             '//*[@id="campaigntable"]/tbody/tr[1]/td[6]').get_attribute(
                 "innerText").replace("\t", ""),
         msg=None)
     sleep(3)
     driver.find_element_by_xpath(
         '//*[@id="campaigntable"]/tbody/tr[1]/td[8]/a[3]').click()
     path = "clients/campaigns/screenshot/"
     sleep(2)
     # message "Deleting record"
     driver.find_element_by_xpath(
         "//button[@class='btn-green text-uppercase col-sm-12']").click()
     # message confirmation
     sleep(2)
     driver.find_element_by_xpath(
         '//*[@id="input-confirmation"]').send_keys((info[0]['name']))
     sleep(2)
     driver.find_element_by_xpath("//button[@id='btn-submit']").click()
     screenshot(self, path)
Esempio n. 7
0
 def test_campaign(self):
     global campaign
     driver = self.driver
     info = json.loads(campaign)
     # login
     login(self)
     sleep(2)
     # Click en clientes
     driver.find_element_by_xpath('//*[@id="inputSrc"]').click()
     sleep(1)
     driver.find_element_by_xpath('//*[@id="search"]').send_keys(client)
     sleep(2)
     driver.find_element_by_xpath(
         '//*[@id="clienttable"]/tbody/tr[1]/td[5]/a[1]/i').click()
     sleep(2)
     # view campaign
     driver.find_element_by_xpath(
         '//*[@id="campaigntable"]/tbody/tr[1]/td[8]/a[1]').click()
     # asserts
     self.assertEqual(info[0]['name'],
                      driver.find_element_by_xpath(
                          '//*[@id="client-info"]/div/div[3]/p').text,
                      msg=None)
     self.assertEqual(info[0]['industry'],
                      driver.find_element_by_xpath(
                          '//*[@id="client-info"]/div/div[4]/p').text,
                      msg=None)
     self.assertEqual(info[0]['category'].capitalize(),
                      driver.find_element_by_xpath(
                          '//*[@id="client-info"]/div/div[5]/p').text,
                      msg=None)
     self.assertEqual(float(info[0]['budget']),
                      float(
                          driver.find_element_by_xpath(
                              '//*[@id="client-info"]/div/div[6]/p').text),
                      msg=None)
     self.assertEqual(float(info[0]['objective']),
                      float(
                          driver.find_element_by_xpath(
                              '//*[@id="client-info"]/div/div[7]/p').text),
                      msg=None)
     path = "clients/campaigns/screenshot/"
     screenshot(self, path)
     sleep(2)
Esempio n. 8
0
 def campaign_main(self):
     driver = self.driver
     # login
     login(self)
     sleep(2)
     # Click en clientes
     driver.find_element_by_xpath('//*[@id="inputSrc"]').click()
     sleep(1)
     driver.find_element_by_xpath('//*[@id="search"]').send_keys(client)
     sleep(2)
     driver.find_element_by_xpath(
         '//*[@id="clienttable"]/tbody/tr[1]/td[5]/a[1]/i').click()
     sleep(1)
     # Click en edit
     driver.find_element_by_xpath(
         '//*[@id="campaigntable"]/tbody/tr[1]/td[8]/a[2]').click()
     sleep(1)
     path = "clients/campaigns/screenshot/"
     screenshot(self, path)
Esempio n. 9
0
 def test_empty_fields(self):
     driver = self.driver
     self.select_test()
     sleep(2)
     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-measure' %
         (type_modal, type_modal)).clear()
     driver.find_element_by_css_selector(
         '#form-%s-creative #%s-creative-url' %
         (type_modal, type_modal)).clear()
     driver.find_element_by_xpath(
         '//*[@id="modal-%s-creative"]/div/div/div[3]/button' %
         type_modal).click()
     sleep(2)
     self.assertEqual("This field is empty",
                      driver.find_element_by_css_selector(
                          "#form-%s-creative > div:nth-child(2) > span" %
                          type_modal).get_attribute("innerText"),
                      msg=None)
     self.assertEqual("This field is empty",
                      driver.find_element_by_css_selector(
                          "#form-%s-creative > div:nth-child(4) > span" %
                          type_modal).get_attribute("innerText"),
                      msg=None)
     self.assertEqual("This field is empty.",
                      driver.find_element_by_css_selector(
                          "#form-%s-creative > div:nth-child(5) > span" %
                          type_modal).get_attribute("innerText"),
                      msg=None)
     if type_modal == "add":
         self.assertEqual(
             "THIS FIELD IS EMPTY",
             driver.find_element_by_css_selector(
                 "#form-%s-creative > div.drag-drop > label > span.help-block"
                 % type_modal).get_attribute("innerText"),
             msg=None)
     path = "clients/campaigns/creatives/screenshot/test_url_format_" + type_modal + "_creative"
     screenshot(self, path)
Esempio n. 10
0
 def test_login_success(self):
     driver = self.driver
     path = "login/screenshot/test_login_success"
     driver.get(ModelConfig.url_login)
     self.assertEqual("We are",
                      driver.find_element_by_xpath('//*[@id="we"]').text,
                      msg=None)
     self.assertEqual(
         "Cerebro Smart Media",
         driver.find_element_by_xpath('//*[@id="content"]/h2').text,
         msg=None)
     self.assertEqual(
         "Please login to your account",
         driver.find_element_by_xpath('//*[@id="subtitle"]').text,
         msg=None)
     self.assertEqual("keep me signed in",
                      driver.find_element_by_xpath(
                          '//*[@id="container_remember"]/label').text,
                      msg=None)
     self.assertEqual(
         "Forgot password?",
         driver.find_element_by_xpath('//*[@id="content"]/p/a').text,
         msg=None)
     driver.find_element_by_xpath('//*[@id="id_username"]').send_keys(
         ModelConfig.email)
     driver.find_element_by_xpath('//*[@id="id_password"]').send_keys(
         ModelConfig.password)
     screenshot(self, path)
     driver.find_element_by_xpath('//*[@id="formLogin"]/button').click()
     self.assertIn(ModelConfig.base_url +
                   "/admin/clients/?next=/admin/login/",
                   driver.current_url,
                   msg=None)
     self.assertEqual("Clients",
                      driver.find_element_by_xpath(
                          '//*[@id="logo-user"]').text.capitalize(),
                      msg=None)
     screenshot(self, path)
Esempio n. 11
0
 def test_redirect_login_success(self):
     driver = self.driver
     path = "login/screenshot/test_redirect_login_success"
     driver.get(ModelConfig.base_url + "/admin/client/update/1/")
     sleep(4)
     self.assertEqual("We are", driver.find_element_by_xpath('//*[@id="we"]')
                      .text, msg=None)
     self.assertEqual("Cerebro Smart Media", driver.find_element_by_xpath('//*[@id="content"]/h2')
                      .text, msg=None)
     self.assertEqual("Please login to see this page.", driver.find_element_by_xpath('//*[@id="subtitle"]')
                      .text, msg=None)
     self.assertEqual("keep me signed in", driver.find_element_by_xpath('//*[@id="container_remember"]/label')
                      .text, msg=None)
     self.assertEqual("Forgot password?", driver.find_element_by_xpath('//*[@id="content"]/p/a')
                      .text, msg=None)
     driver.find_element_by_xpath('//*[@id="id_username"]').send_keys(ModelConfig.email)
     driver.find_element_by_xpath('//*[@id="id_password"]').send_keys(ModelConfig.password)
     screenshot(self, path)
     driver.find_element_by_xpath('//*[@id="formLogin"]/button').click()
     sleep(4)
     self.assertIn(ModelConfig.base_url + "/admin/client/update/1/", driver.current_url, msg=None)
     sleep(4)
     screenshot(self, path)
Esempio n. 12
0
 def test_reset_format_email(self):
     driver = self.driver
     path = "login/screenshot/test_reset_format_email"
     driver.find_element_by_xpath('//*[@id="content"]/p/a').click()
     sleep(3)
     driver.find_element_by_xpath('//*[@id="id_email"]').clear()
     driver.find_element_by_xpath('//*[@id="id_email"]').send_keys(
         "sonia.amezcua")
     driver.find_element_by_xpath(
         '//*[@id="content"]/form/fieldset/button').click()
     sleep(1)
     self.assertEqual(
         'Incluye un signo "@" en la dirección de correo electrónico. '
         'La dirección "sonia.amezcua" no incluye el signo "@".',
         driver.page_source)
     screenshot(self, path)
     sleep(1)
     driver.find_element_by_xpath('//*[@id="id_email"]').clear()
     driver.find_element_by_xpath('//*[@id="id_email"]').send_keys(
         "sonia.amezcua@")
     driver.find_element_by_xpath(
         '//*[@id="content"]/form/fieldset/button').click()
     sleep(1)
     self.assertEqual(
         'Invalid email format',
         driver.find_element_by_css_selector(
             '#formLogin > div.form-group.has-error > span').text,
         msg=None)
     screenshot(self, path)
     sleep(1)
     driver.find_element_by_xpath('//*[@id="id_email"]').clear()
     driver.find_element_by_xpath('//*[@id="id_email"]').send_keys(
         "sonia.amezcua@varangard.")
     driver.find_element_by_xpath(
         '//*[@id="content"]/form/fieldset/button').click()
     sleep(1)
     self.assertEqual(
         'Invalid email format',
         driver.find_element_by_css_selector(
             '#formLogin > div.form-group.has-error > span').text,
         msg=None)
     screenshot(self, path)
     sleep(1)
Esempio n. 13
0
 def test_incorrect_data(self):
     driver = self.driver
     path = "login/screenshot/test_incorrect_data"
     sleep(2)
     driver.find_element_by_xpath('//*[@id="id_username"]').clear()
     driver.find_element_by_xpath('//*[@id="id_username"]').send_keys(
         email_inexist)
     driver.find_element_by_xpath('//*[@id="id_password"]').send_keys(
         password_inexist)
     driver.find_element_by_xpath('//*[@id="formLogin"]/button').click()
     sleep(2)
     self.assertEqual(
         "Your username and password didn't match.\nPlease try again.",
         driver.find_element_by_xpath('//*[@id="formLogin"]/p').text,
         msg=None)
     screenshot(self, path)
     sleep(2)
     driver.find_element_by_xpath('//*[@id="id_username"]').clear()
     driver.find_element_by_xpath('//*[@id="id_username"]').send_keys(
         ModelConfig.email)
     driver.find_element_by_xpath('//*[@id="id_password"]').send_keys(
         password_inexist)
     driver.find_element_by_xpath('//*[@id="formLogin"]/button').click()
     sleep(2)
     self.assertEqual(
         "Your username and password didn't match.\nPlease try again.",
         driver.find_element_by_xpath('//*[@id="formLogin"]/p').text,
         msg=None)
     screenshot(self, path)
     sleep(2)
     driver.find_element_by_xpath('//*[@id="id_username"]').clear()
     driver.find_element_by_xpath('//*[@id="id_username"]').send_keys(
         email_inexist)
     driver.find_element_by_xpath('//*[@id="id_password"]').send_keys(
         ModelConfig.password)
     driver.find_element_by_xpath('//*[@id="formLogin"]/button').click()
     sleep(2)
     self.assertEqual(
         "Your username and password didn't match.\nPlease try again.",
         driver.find_element_by_xpath('//*[@id="formLogin"]/p').text,
         msg=None)
     screenshot(self, path)
Esempio n. 14
0
 def test_format_email(self):
     driver = self.driver
     path = "login/screenshot/test_format_email"
     sleep(3)
     driver.find_element_by_xpath('//*[@id="id_username"]').clear()
     driver.find_element_by_xpath('//*[@id="id_username"]').send_keys(
         "sonia.amezcua")
     driver.find_element_by_xpath('//*[@id="formLogin"]/button').click()
     sleep(1)
     self.assertEqual(
         'Invalid email format',
         driver.find_element_by_css_selector(
             '#formLogin > div.form-group.has-error > span').text,
         msg=None)
     screenshot(self, path)
     sleep(1)
     driver.find_element_by_xpath('//*[@id="id_username"]').clear()
     driver.find_element_by_xpath('//*[@id="id_username"]').send_keys(
         "sonia.amezcua@")
     driver.find_element_by_xpath('//*[@id="formLogin"]/button').click()
     sleep(1)
     self.assertEqual(
         'Invalid email format',
         driver.find_element_by_css_selector(
             '#formLogin > div.form-group.has-error > span').text,
         msg=None)
     screenshot(self, path)
     sleep(1)
     driver.find_element_by_xpath('//*[@id="id_username"]').clear()
     driver.find_element_by_xpath('//*[@id="id_username"]').send_keys(
         "sonia.amezcua@varangard.")
     driver.find_element_by_xpath('//*[@id="formLogin"]/button').click()
     sleep(1)
     self.assertEqual(
         'Invalid email format',
         driver.find_element_by_css_selector(
             '#formLogin > div.form-group.has-error > span').text,
         msg=None)
     screenshot(self, path)
Esempio n. 15
0
 def test_file_creative_validation(self):
     global types, type_modal
     driver = self.driver
     self.select_test()
     sleep(2)
     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("name")
     driver.find_element_by_css_selector(
         '#form-%s-creative #%s-creative-status' %
         (type_modal, type_modal)).click()
     sleep(1)
     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("10x5")
     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://www.algo.com")
     sleep(2)
     for position_file in range(4):
         print("\n<<<------ %s ------>>>\n" % types[position_file]["type"])
         driver.find_element_by_css_selector('#form-%s-creative #%s-creative-type' % (type_modal, type_modal))\
             .click()
         sleep(1)
         driver.find_element_by_css_selector(
             '#form-%s-creative #%s-creative-type > option[value="%s"]' %
             (type_modal, type_modal,
              types[position_file]["type"])).click()
         sleep(1)
         driver.find_element_by_css_selector('#form-%s-creative #%s-creative-type' % (type_modal, type_modal))\
             .click()
         sleep(1)
         sleep(2)
         if browser_name == "chrome" or browser_name == "firefox" or browser_name == "edge":
             position = driver.find_element_by_xpath('/html/body/div[13]/div/div/div[3]/button') \
                 .location_once_scrolled_into_view
             driver.execute_script("window.scrollTo(0, %d);" %
                                   (position["y"]))
         sleep(2)
         if position_file == len(types) - 1:
             image_path = types[0]["file"]
         else:
             image_path = types[position_file + 1]["file"]
         if position_file == 0:
             image_path = types[3]["file"]
         name: None
         if type_modal == "add":
             name = "add-creative-"
         elif type_modal == "edit":
             name = "id_"
         driver.find_element_by_css_selector('#form-%s-creative #%sfile' % (type_modal, name))\
             .send_keys(image_path)
         sleep(2)
         driver.find_element_by_xpath(
             '//*[@id="modal-%s-creative"]/div/div/div[3]/button' %
             type_modal).click()
         sleep(3)
         try:
             while driver.find_element_by_css_selector(
                     '#form-%s-creative div div.loader-input-file.center span'
                     % type_modal):
                 print("Cargando %s ..." % types[position_file]["type"])
                 sleep(2)
         except NoSuchElementException:
             print("Archivo %s cargado" % types[position_file]["type"])
             sleep(2)
         if types[position_file]["type"] == "HTML5":
             self.assertEqual(
                 "The file must be a html or html compressed in zip format.",
                 driver.find_element_by_xpath(
                     '//*[@id="form-%s-creative"]/div[6]/div[1]/span' %
                     type_modal).get_attribute("innerText"),
                 msg=None)
         else:
             self.assertEqual(
                 "The file must be a: %s" % types[position_file]["type"],
                 driver.find_element_by_xpath(
                     '//*[@id="form-%s-creative"]/div[6]/div[1]/span' %
                     type_modal).get_attribute("innerText"),
                 msg=None)
         path = "clients/campaigns/creatives/screenshot/file_validation_" + type_modal + "_creative"
         screenshot(self, path)
     sleep(2)
Esempio n. 16
0
    def test_edit_client_success(self):
        global clients
        path = "clients/client/screenshot/test_edit_client_success"

        info = json.loads(clients)
        # login
        login(self)
        sleep(3)
        driver = self.driver

        self.assertIn(
            "http://stage.eupam5k9mb.us-west-2.elasticbeanstalk.com/admin/clients/",
            driver.current_url,
            msg=None)
        sleep(3)
        driver.find_element_by_xpath('//*[@id="inputSrc"]/img').click()
        driver.find_element_by_id('search').send_keys(info[0]['rfc'])
        sleep(8)
        driver.find_element_by_xpath(
            '//*[@id="clienttable"]/tbody/tr[1]/td[5]/a[2]').click()
        sleep(5)
        driver.find_element_by_css_selector('#edit-form-email').clear()
        driver.find_element_by_css_selector('#edit-form-email').send_keys(
            info[1]['email'])
        driver.find_element_by_css_selector(
            '#edit-form-person_contact').clear()
        driver.find_element_by_css_selector(
            '#edit-form-person_contact').send_keys(info[1]['name'])
        select = Select(
            driver.find_element_by_css_selector("#edit-form-status"))
        select.select_by_index(1)
        driver.find_element_by_css_selector('#edit-form-password').clear()
        driver.find_element_by_css_selector('#edit-form-password').send_keys(
            info[1]['password'])
        driver.find_element_by_css_selector('#edit-form-cpm').clear()
        driver.find_element_by_css_selector('#edit-form-cpm').send_keys(
            info[1]['cpm'])
        driver.find_element_by_css_selector('#edit-form-budget').clear()
        driver.find_element_by_css_selector('#edit-form-budget').send_keys(
            info[1]['budget'])
        driver.find_element_by_css_selector('#edit-form-company_name').clear()
        driver.find_element_by_css_selector(
            '#edit-form-company_name').send_keys(info[1]['company'])
        driver.find_element_by_css_selector('#edit-form-rfc').clear()
        driver.find_element_by_css_selector('#edit-form-rfc').send_keys(
            info[1]['rfc'])
        driver.find_element_by_css_selector('#edit-form-address').clear()
        driver.find_element_by_css_selector('#edit-form-address').send_keys(
            info[1]['address'])
        driver.find_element_by_css_selector('#edit-form-phone').clear()
        driver.find_element_by_css_selector('#edit-form-phone').send_keys(
            info[1]['phone'])
        screenshot(self, path)
        sleep(3)
        driver.find_element_by_xpath(
            '//*[@id="modal-edit"]/div/div/div[3]/button').click()
        # self.assertIn("Record successfully updated", driver.page_source)
        sleep(5)
        driver.find_element_by_xpath('//*[@id="inputSrc"]/img').click()
        driver.find_element_by_id('search').send_keys(info[1]['rfc'])
        sleep(3)
        self.assertEqual(info[1]['email'],
                         driver.find_element_by_xpath(
                             '//*[@id="clienttable"]/tbody/tr[1]/td[1]').text,
                         msg=None)
        self.assertEqual(info[1]['name'],
                         driver.find_element_by_xpath(
                             '//*[@id="clienttable"]/tbody/tr[1]/td[2]').text,
                         msg=None)
        self.assertEqual(info[1]['rfc'],
                         driver.find_element_by_xpath(
                             '//*[@id="clienttable"]/tbody/tr[1]/td[3]').text,
                         msg=None)
        self.assertEqual('inactive',
                         driver.find_element_by_xpath(
                             '//*[@id="clienttable"]/tbody/tr[1]/td[4]').text,
                         msg=None)
        screenshot(self, path)
        sleep(3)
Esempio n. 17
0
    def testDeletedUsersSuccess(self):
        users = '''
        [{"email" : "*****@*****.**", "password" : "2233445:", "confirm_password" : "2233445:",
          "name" : "Fernanda Rodriguez Martinez"},
         {"email" : "*****@*****.**", "password" : "46546554?¡", "confirm_password" : "46546554?¡",
          "name" : "Cesar Perez Lopez"},
         {"email" : "*****@*****.**", "password" : "97744552121?", "confirm_password" : "97744552121?",
          "name" : "Anita Rodriguez Perez"}
         ]'''
        info = json.loads(users)
        driver = self.driver
        rand = randint(0, len(info) - 1)
        code = """
        
#declaraciones de variables
        
info = {0}
rand = {1}

#recorrer el JSON

for user in info: 
    cur.execute("DELETE FROM users WHERE email = '%s'" % user['email'])
    cur.execute("DELETE FROM admin_historicaluser WHERE email = '%s'" % user['email'])      
#print the returned value
print(cur.rowcount)
sql = 'INSERT INTO users (name, password, status, email, created_at, updated_at, is_active, is_client)' \
      'VALUES (%s, %s, %s, %s, current_timestamp, current_timestamp, %s, %s) returning email'    
val = (info[rand]['name'], info[rand]['password'], '1', info[rand]['email'], 'true', 'false') 
cur.execute(sql, val)
""".format(info, rand)
        db_functions(code)
        login(self)
        time.sleep(3)
        time.sleep(3)
        driver.find_element_by_xpath(
            '//*[@id="sections-access"]/div[1]/a').click()
        time.sleep(2)

        # Find user
        driver.find_element_by_id('inputSrc').click()
        time.sleep(2)
        driver.find_element_by_xpath('//*[@id="search"] ').send_keys(
            info[rand]['email'])
        time.sleep(3)
        driver.find_element_by_xpath(
            '//*[@id="usertable"]/tbody/tr[1]/td[4]/a[2]/i').click()
        time.sleep(2)

        # Remove user
        driver.find_element_by_xpath(
            '//*[@id="modal-delete"]/div/div/div[3]/div[2]/button').click()
        time.sleep(4)
        driver.find_element_by_css_selector(
            '#form-confirm #input-confirmation').send_keys(info[rand]['email'])
        time.sleep(4)
        driver.find_element_by_xpath('//*[@id="btn-submit"]').click()
        time.sleep(4)

        # Screenshot
        path = "/users/screenshot/delete/"
        screenshot(self, path)
        driver.refresh()
        time.sleep(4)

        # Find user
        driver.find_element_by_id('inputSrc').click()
        time.sleep(2)
        driver.find_element_by_xpath('//*[@id="search"]').send_keys(
            info[rand]['email'])
        time.sleep(5)

        # Screenshot
        screenshot(self, path)

        # Compare
        self.assertEqual(driver.find_element_by_xpath(
            '//*[@id="usertable"]/tbody/tr[1]/td[1]').get_attribute(
                'innerHTML'),
                         info[rand]['email'],
                         msg=None)
        time.sleep(5)
        self.assertEqual(driver.find_element_by_xpath(
            '//*[@id="usertable"]/tbody/tr[1]/td[2]').get_attribute(
                'innerHTML'),
                         info[rand]['name'],
                         msg=None)
Esempio n. 18
0
    def test_edit_detail_client_success(self):
        browser_name = self.driver.capabilities['browserName']
        # print(browserName)
        path = "clients/client/screenshot/test_edit_detail_client_success"
        info = json.loads(clients)

        # login
        login(self)
        sleep(3)
        driver = self.driver
        self.assertIn(ModelConfig.base_url + "/admin/clients/",
                      driver.current_url,
                      msg=None)
        sleep(3)
        driver.find_element_by_xpath('//*[@id="inputSrc"]/img').click()
        driver.find_element_by_id('search').send_keys(info[0]['rfc'])
        sleep(3)
        self.assertEqual(info[0]['email'],
                         driver.find_element_by_xpath(
                             '//*[@id="clienttable"]/tbody/tr[1]/td[1]').text,
                         msg=None)
        self.assertEqual(info[0]['name'],
                         driver.find_element_by_xpath(
                             '//*[@id="clienttable"]/tbody/tr[1]/td[2]').text,
                         msg=None)
        self.assertEqual(info[0]['rfc'],
                         driver.find_element_by_xpath(
                             '//*[@id="clienttable"]/tbody/tr[1]/td[3]').text,
                         msg=None)
        self.assertEqual('active',
                         driver.find_element_by_xpath(
                             '//*[@id="clienttable"]/tbody/tr[1]/td[4]').text,
                         msg=None)
        screenshot(self, path)
        driver.find_element_by_xpath(
            '//*[@id="clienttable"]/tbody/tr/td[5]/a[1]').click()
        sleep(3)
        self.assertIn(ModelConfig.base_url + "/admin/client/detail",
                      driver.current_url,
                      msg=None)
        self.assertEqual(info[0]['company'],
                         driver.find_element_by_xpath(
                             '//*[@id="client-info-header"]/h2').text,
                         msg=None)
        self.assertEqual(
            "Clients /",
            driver.find_element_by_xpath(
                '//*[@id="client-info-header"]/a[1]').text.capitalize(),
            msg=None)
        self.assertEqual(
            "Email",
            driver.find_element_by_xpath(
                '//*[@id="client-info"]/div/div[1]/label').text.capitalize(),
            msg=None)
        self.assertEqual(
            "Company",
            (driver.find_element_by_xpath(
                '//*[@id="client-info"]/div/div[2]/label').text).capitalize(),
            msg=None)
        self.assertEqual(
            "RFC",
            (driver.find_element_by_xpath(
                '//*[@id="client-info"]/div/div[3]/label').text).upper(),
            msg=None)
        self.assertEqual(
            "Address",
            (driver.find_element_by_xpath(
                '//*[@id="client-info"]/div/div[4]/label').text).capitalize(),
            msg=None)
        self.assertEqual(
            "Contact",
            (driver.find_element_by_xpath(
                '//*[@id="client-info"]/div/div[5]/label').text).capitalize(),
            msg=None)
        self.assertEqual(
            "Phone",
            (driver.find_element_by_xpath(
                '//*[@id="client-info"]/div/div[6]/label').text).capitalize(),
            msg=None)
        self.assertEqual(
            "Budget",
            (driver.find_element_by_xpath(
                '//*[@id="client-info"]/div/div[7]/label').text).capitalize(),
            msg=None)
        self.assertEqual(
            "Cpm",
            (driver.find_element_by_xpath(
                '//*[@id="client-info"]/div/div[8]/label').text).capitalize(),
            msg=None)
        self.assertEqual(info[0]['company'],
                         driver.find_element_by_xpath(
                             '//*[@id="client-info-header"]/a[2]').text,
                         msg=None)
        self.assertEqual(
            info[0]['email'],
            (driver.find_element_by_xpath(
                '//*[@id="client-info"]/div/div[1]/p').text).rstrip(),
            msg=None)
        self.assertEqual(
            info[0]['company'],
            (driver.find_element_by_xpath(
                '//*[@id="client-info"]/div/div[2]/p').text).rstrip(),
            msg=None)
        self.assertEqual(
            info[0]['rfc'],
            (driver.find_element_by_xpath(
                '//*[@id="client-info"]/div/div[3]/p').text).rstrip(),
            msg=None)
        self.assertEqual(
            info[0]['address'],
            (driver.find_element_by_xpath(
                '//*[@id="client-info"]/div/div[4]/p').text).rstrip(),
            msg=None)
        self.assertEqual(
            info[0]['name'],
            (driver.find_element_by_xpath(
                '//*[@id="client-info"]/div/div[5]/p').text).rstrip(),
            msg=None)
        self.assertEqual(
            info[0]['phone'],
            (driver.find_element_by_xpath(
                '//*[@id="client-info"]/div/div[6]/p').text).rstrip(),
            msg=None)
        self.assertEqual(
            info[0]['budget'],
            (driver.find_element_by_xpath(
                '//*[@id="client-info"]/div/div[7]/p').text).rstrip(),
            msg=None)
        self.assertEqual(
            info[0]['cpm'],
            (driver.find_element_by_xpath(
                '//*[@id="client-info"]/div/div[8]/p').text).rstrip(),
            msg=None)
        screenshot(self, path)
        driver.find_element_by_xpath('//*[@id="btn-edit"]').click()
        screenshot(self, path)
        sleep(3)
        driver.find_element_by_css_selector('#edit-form-email').clear()
        driver.find_element_by_css_selector('#edit-form-email').send_keys(
            info[1]['email'])
        driver.find_element_by_css_selector(
            '#edit-form-person_contact').clear()
        driver.find_element_by_css_selector(
            '#edit-form-person_contact').send_keys(info[1]['name'])
        select = Select(
            driver.find_element_by_css_selector("#edit-form-status"))
        select.select_by_index(1)
        driver.find_element_by_css_selector('#edit-form-password').clear()
        driver.find_element_by_css_selector('#edit-form-password').send_keys(
            info[1]['password'])
        driver.find_element_by_css_selector('#edit-form-cpm').clear()
        driver.find_element_by_css_selector('#edit-form-cpm').send_keys(
            info[1]['cpm'])
        driver.find_element_by_css_selector('#edit-form-budget').clear()
        driver.find_element_by_css_selector('#edit-form-budget').send_keys(
            info[1]['budget'])
        driver.find_element_by_css_selector('#edit-form-company_name').clear()
        driver.find_element_by_css_selector(
            '#edit-form-company_name').send_keys(info[1]['company'])
        driver.find_element_by_css_selector('#edit-form-rfc').clear()
        driver.find_element_by_css_selector('#edit-form-rfc').send_keys(
            info[1]['rfc'])
        driver.find_element_by_css_selector('#edit-form-address').clear()
        driver.find_element_by_css_selector('#edit-form-address').send_keys(
            info[1]['address'])
        driver.find_element_by_css_selector('#edit-form-phone').clear()
        driver.find_element_by_css_selector('#edit-form-phone').send_keys(
            info[1]['phone'])
        screenshot(self, path)
        driver.find_element_by_css_selector(
            "#modal-edit > div:nth-child(1) > div:nth-child(1) > div:nth-child(3) > "
            + "button:nth-child(1)").click()
        sleep(3)
        driver.find_element_by_xpath('//*[@id="inputSrc"]/img').click()
        driver.find_element_by_id('search').send_keys(info[1]['rfc'])
        sleep(3)
        self.assertEqual(info[1]['email'],
                         driver.find_element_by_xpath(
                             '//*[@id="clienttable"]/tbody/tr[1]/td[1]').text,
                         msg=None)
        self.assertEqual(info[1]['name'],
                         driver.find_element_by_xpath(
                             '//*[@id="clienttable"]/tbody/tr[1]/td[2]').text,
                         msg=None)
        self.assertEqual(info[1]['rfc'],
                         driver.find_element_by_xpath(
                             '//*[@id="clienttable"]/tbody/tr[1]/td[3]').text,
                         msg=None)
        self.assertEqual('inactive',
                         driver.find_element_by_xpath(
                             '//*[@id="clienttable"]/tbody/tr[1]/td[4]').text,
                         msg=None)
        screenshot(self, path)
        sleep(1)
Esempio n. 19
0
 def test_reset_password(self):
     driver = self.driver
     path = "login/screenshot/test_reset_password"
     driver.get(ModelConfig.url_login)
     driver.find_element_by_xpath('//*[@id="content"]/p/a').click()
     sleep(2)
     self.assertIn(ModelConfig.base_url + "/admin/password_reset/",
                   driver.current_url,
                   msg=None)
     self.assertEqual("We are",
                      driver.find_element_by_xpath('//*[@id="we"]').text,
                      msg=None)
     self.assertEqual(
         "Cerebro Smart Media",
         driver.find_element_by_xpath('//*[@id="content"]/h2').text,
         msg=None)
     self.assertEqual(
         "Recover password",
         driver.find_element_by_xpath('//*[@id="subtitle"]').text,
         msg=None)
     self.assertEqual(
         "We can help you reset your password and\nsecurity information. First write your "
         "account\nand follow the instructions below.",
         driver.find_element_by_css_selector('#content > p').text,
         msg=None)
     self.assertEqual(
         "RESET MY PASSWORD",
         driver.find_element_by_xpath(
             '//*[@id="content"]/form/fieldset/button').text.upper(),
         msg=None)
     driver.find_element_by_xpath('//*[@id="id_email"]').send_keys(
         users[0]['email'])
     screenshot(self, path)
     driver.find_element_by_xpath(
         '//*[@id="content"]/form/fieldset/button').click()
     sleep(2)
     self.assertIn(ModelConfig.base_url + "/admin/password_reset/done/",
                   driver.current_url,
                   msg=None)
     self.assertEqual("We are",
                      driver.find_element_by_xpath('//*[@id="we"]').text,
                      msg=None)
     self.assertEqual(
         "Cerebro Smart Media",
         driver.find_element_by_xpath('//*[@id="content"]/h2').text,
         msg=None)
     self.assertEqual(
         "We just sent you an email, run to check it",
         driver.find_element_by_xpath('//*[@id="content"]/form/p').text,
         msg=None)
     self.assertEqual("GO BACK",
                      driver.find_element_by_xpath(
                          '//*[@id="content"]/form/a').text.upper(),
                      msg=None)
     screenshot(self, path)
     driver.find_element_by_xpath('//*[@id="content"]/form/a').click()
     sleep(2)
     self.assertIn(ModelConfig.base_url + "/admin/login/",
                   driver.current_url,
                   msg=None)
     screenshot(self, path)
Esempio n. 20
0
    def test_edit_user_bd(self):
        global users

        info = json.loads(users)
        driver = self.driver

        # Login

        login(self)
        time.sleep(3)

        driver.find_element_by_xpath(
            '//*[@id="sections-access"]/div[1]/a').click()
        time.sleep(2)

        # Search user

        driver.find_element_by_id('inputSrc').click()
        time.sleep(2)
        driver.find_element_by_xpath('//*[@id="search"]').send_keys(
            info[0]['email'])
        time.sleep(5)

        # Edit the status

        driver.find_element_by_xpath(
            '//*[@id="usertable"]/tbody/tr/td[4]/a[1]/i').click()
        time.sleep(5)
        driver.find_element_by_css_selector(
            '#form-edit #edit-form-status').click()
        aleatory = randint(0, 2)
        driver.find_element_by_css_selector(
            '#form-edit #edit-form-status > option[value="%d"]' %
            aleatory).click()
        print(
            driver.find_element_by_xpath(
                '//*[@id="form-edit"]/span').get_attribute('innerHTML'))

        # Add assert

        self.assertIn(
            "Raw passwords are not stored, so there is no way to see this user's password, "
            "but you can change the password using this",
            driver.find_element_by_xpath(
                '//*[@id="form-edit"]/span').get_attribute('innerHTML'),
            msg=None)
        time.sleep(3)
        driver.find_element_by_css_selector('#form-edit > span > a').click()
        time.sleep(3)
        driver.find_element_by_css_selector(
            '#form-change #change-pwd-password1').clear()
        driver.find_element_by_css_selector(
            '#form-change #change-pwd-password1').send_keys(
                info[0]["password"])
        time.sleep(3)
        driver.find_element_by_css_selector(
            '#form-change #change-pwd-password2').clear()
        driver.find_element_by_css_selector(
            '#form-change #change-pwd-password2').send_keys(
                info[0]["password"])
        time.sleep(3)
        driver.find_element_by_xpath(
            '//*[@id="modal-change-pwd"]/div/div/div[3]/button').click()
        time.sleep(10)
        driver.find_element_by_xpath(
            '//*[@id="modal-edit"]/div/div/div[3]/button').click()
        time.sleep(2)

        # Screenshot

        path = "/users/screenshot/edit/"
        screenshot(self, path)
        time.sleep(2)

        # Search user

        driver.find_element_by_id('inputSrc').click()
        time.sleep(2)
        driver.find_element_by_xpath('//*[@id="search"]').send_keys(
            info[0]['email'])
        time.sleep(5)

        # Edit the name

        driver.find_element_by_xpath(
            '//*[@id="usertable"]/tbody/tr/td[4]/a[1]/i').click()
        time.sleep(5)
        driver.find_element_by_css_selector(
            '#form-edit #edit-form-name').clear()
        driver.find_element_by_css_selector(
            '#form-edit #edit-form-name').send_keys(info[0]["name"])
        driver.find_element_by_xpath(
            '//*[@id="modal-edit"]/div/div/div[3]/button').click()
        time.sleep(2)

        # Screenshot

        path = "/users/screenshot/add/"
        screenshot(self, path)

        # Search user

        driver.find_element_by_id('inputSrc').click()
        time.sleep(2)
        driver.find_element_by_xpath('//*[@id="search"]').send_keys(
            info[0]['email'])
        time.sleep(5)

        # edit the email

        driver.find_element_by_xpath(
            '//*[@id="usertable"]/tbody/tr/td[4]/a[1]/i').click()
        time.sleep(5)
        driver.find_element_by_css_selector(
            '#form-edit #edit-form-email').clear()
        driver.find_element_by_css_selector(
            '#form-edit #edit-form-email').send_keys(info[0]["email"])
        driver.find_element_by_xpath(
            '//*[@id="modal-edit"]/div/div/div[3]/button').click()
        time.sleep(2)

        # Screenshot

        path = "/users/screenshot/add/"
        screenshot(self, path)

        # Search user

        driver.find_element_by_id('inputSrc').click()
        time.sleep(2)
        driver.find_element_by_xpath('//*[@id="search"]').send_keys(
            info[0]['email'])
        time.sleep(5)

        # Compare

        self.assertEqual(driver.find_element_by_xpath(
            '//*[@id="usertable"]/tbody/tr[1]/td[1]').get_attribute(
                'innerHTML'),
                         info[0]['email'],
                         msg=None)
        time.sleep(5)
        self.assertEqual(driver.find_element_by_xpath(
            '//*[@id="usertable"]/tbody/tr[1]/td[2]').get_attribute(
                'innerHTML'),
                         info[0]['name'],
                         msg=None)
        time.sleep(5)

        status: None
        if aleatory == 0:
            status = 'inactive'
        else:
            if aleatory == 1:
                status = 'active'
            else:
                if aleatory == 2:
                    status = 'delete'
        self.assertEqual(driver.find_element_by_xpath(
            '//*[@id="usertable"]/tbody/tr[1]/td[3]').get_attribute(
                'innerHTML'),
                         status,
                         msg=None)
        time.sleep(5)
        logout(self)
        driver.find_element_by_xpath('//*[@id="id_username"]').send_keys(
            info[0]['email'])
        driver.find_element_by_xpath('//*[@id="id_password"]').send_keys(
            info[0]['password'])
        driver.find_element_by_xpath('//*[@id="formLogin"]/button ').click()
Esempio n. 21
0
    def test_delete_client_success(self):
        info = json.loads(clients)
        path = "clients/client/screenshot/test_delete_client_success"
        # login
        login(self)
        sleep(3)
        driver = self.driver
        self.assertIn(
            "http://stage.eupam5k9mb.us-west-2.elasticbeanstalk.com/admin/clients/",
            driver.current_url,
            msg=None)
        sleep(3)
        driver.find_element_by_xpath(
            '//*[@id="sections-access"]/div[2]/a').click()
        sleep(1)
        driver.find_element_by_xpath('//*[@id="inputSrc"]/img').click()
        driver.find_element_by_id('search').send_keys(info[0]['rfc'])
        sleep(3)
        self.assertEqual(info[0]['email'],
                         driver.find_element_by_xpath(
                             '//*[@id="clienttable"]/tbody/tr[1]/td[1]').text,
                         msg=None)
        self.assertEqual(info[0]['name'],
                         driver.find_element_by_xpath(
                             '//*[@id="clienttable"]/tbody/tr[1]/td[2]').text,
                         msg=None)
        self.assertEqual(info[0]['rfc'],
                         driver.find_element_by_xpath(
                             '//*[@id="clienttable"]/tbody/tr[1]/td[3]').text,
                         msg=None)
        self.assertEqual("active",
                         driver.find_element_by_xpath(
                             '//*[@id="clienttable"]/tbody/tr[1]/td[4]').text,
                         msg=None)
        sleep(3)
        screenshot(self, path)
        driver.find_element_by_xpath(
            '//*[@id="clienttable"]/tbody/tr[1]/td[5]/a[3]').click()
        sleep(3)
        self.assertEqual("Deleting record",
                         driver.find_element_by_xpath(
                             '//*[@id="modal-delete"]/div/div/div[2]/h2').text,
                         msg=None)
        driver.find_element_by_xpath(
            '//*[@id="modal-delete"]/div/div/div[3]/div[2]/button').click()
        sleep(3)
        self.assertEqual(
            "Are you sure to delete this record?",
            driver.find_element_by_xpath(
                '//*[@id="modal-confirm"]/div/div/div[1]/h1').text,
            msg=None)
        self.assertEqual(
            "Deleting this client, will eraser the campaigns and creatives relating with it.",
            driver.find_element_by_xpath(
                '//*[@id="modal-confirm"]/div/div/div[1]/p').text,
            msg=None)
        self.assertEqual("Enter the confirmation:",
                         driver.find_element_by_xpath(
                             '//*[@id="modal-confirm"]/div/div/div[2]/p').text,
                         msg=None)
        driver.find_element_by_xpath('//*[@id="btn-submit"]').click()
        sleep(3)
        self.assertEqual(
            "This field doesn't match with the record.",
            driver.find_element_by_xpath(
                '//*[@id="form-confirm"]/div/span').text.rstrip(' '),
            msg=None)
        screenshot(self, path)
        driver.find_element_by_xpath('//*[@id="input-confirmation"]').clear()
        driver.find_element_by_xpath(
            '//*[@id="input-confirmation"]').send_keys("BATALLON@GMAIL")
        driver.find_element_by_xpath('//*[@id="btn-submit"]').click()
        sleep(3)
        self.assertEqual(
            "This field doesn't match with the record.",
            driver.find_element_by_xpath('//*[@id="form-confirm"]/div/span').
            get_attribute('innerHTML').rstrip(' '),
            msg=None)
        screenshot(self, path)
        driver.find_element_by_xpath('//*[@id="input-confirmation"]').clear()
        driver.find_element_by_xpath(
            '//*[@id="input-confirmation"]').send_keys(info[0]['email'])
        driver.find_element_by_xpath('//*[@id="btn-submit"]').click()
        sleep(3)

        self.assertEqual("No record found",
                         driver.find_element_by_xpath(
                             '//*[@id="clienttable"]/tbody/tr/td').text,
                         msg=None)

        screenshot(self, path)
        sleep(3)
Esempio n. 22
0
 def test_double_click_manager(self):
     path = path_screenshot + "test_double_click_manager"
     sleep(3)
     driver = self.driver
     self.assertIn(ModelConfig.base_url + "/admin/clients/",
                   driver.current_url,
                   msg=None)
     sleep(3)
     driver.find_element_by_xpath('//*[@id="inputSrc"]/img').click()
     driver.find_element_by_id('search').send_keys(client[0]['rfc'])
     sleep(2)
     driver.find_element_by_xpath(
         '//*[@id="clienttable"]/tbody/tr/td[5]/a[1]').click()
     sleep(3)
     self.assertIn(ModelConfig.base_url + "/admin/client/detail/",
                   driver.current_url,
                   msg=None)
     driver.find_element_by_xpath(
         '//*[@id="campaigntable"]/tbody/tr/td[8]/a[1]').click()
     sleep(3)
     self.assertIn(ModelConfig.base_url + "/admin/campaign/detail/",
                   driver.current_url,
                   msg=None)
     self.assertEqual(campaign[0]['name'],
                      driver.find_element_by_xpath(
                          '//*[@id="client-info-header"]/h2').text,
                      msg=None)
     self.assertEqual(
         "DoubleClick Manager",
         driver.find_element_by_xpath('/html/body/div[4]/h2').text,
         msg=None)
     self.assertEqual(
         "To improve your campaign, connect with DoubleClick Manager. Check the connection guide",
         driver.find_element_by_xpath(
             '/html/body/div[4]/div/div/span').text,
         msg=None)
     self.assertEqual("Client ID",
                      driver.find_element_by_xpath(
                          '//*[@id="form-dbm"]/div/div[1]/div/label').text,
                      msg=None)
     self.assertEqual("Client Secret",
                      driver.find_element_by_xpath(
                          '//*[@id="form-dbm"]/div/div[2]/div/label').text,
                      msg=None)
     self.assertEqual(
         "CONNECT",
         driver.find_element_by_xpath(
             '//*[@id="form-dbm"]/div/div[3]/div/button').text.upper(),
         msg=None)
     driver.find_element_by_xpath(
         '//*[@id="form-dbm"]/div/div[1]/div/input').send_keys(client_id)
     driver.find_element_by_xpath('//*[@id="form-dbm"]/div/div[2]/div/input'
                                  ).send_keys(client_secret)
     driver.find_element_by_xpath(
         '//*[@id="form-dbm"]/div/div[3]/div/button').click()
     # ESTE TEXTO SE COMENTÓ DEBIDO A QUE NO PUEDE REALIZARSE LA CONEXIÓN EN STAGE
     #self.assertEqual("Successful connection",
     #                 driver.find_element_by_css_selector('//*[@id="dbm_tab"]/span[2]').text.upper(), msg=None)
     screenshot(self, path)
     driver.refresh()
     sleep(2)
     driver.find_element_by_xpath(
         '//*[@id="client-info-header"]/a[1]').click()
     self.assertEqual(driver.find_element_by_xpath(
         '//*[@id="form-dbm"]/div/div[1]/div/input').get_attribute("value"),
                      client_id,
                      msg=None)
     self.assertEqual(driver.find_element_by_xpath(
         '//*[@id="form-dbm"]/div/div[2]/div/input').get_attribute("value"),
                      client_secret,
                      msg=None)
     screenshot(self, path)
Esempio n. 23
0
    def test_reset_password_email(self):
        driver = self.driver
        path = "login/screenshot/test_reset_password_email"
        browser_name = self.driver.capabilities['browserName']

        driver.get('https://mail.google.com/mail/u/0/#inbox')

        sleep(8)
        driver.find_element_by_css_selector('#identifierId').send_keys(email)
        driver.find_element_by_css_selector(
            '#identifierNext > content').click()
        sleep(5)
        driver.find_element_by_css_selector('#password > div > div > div > input')\
            .send_keys(password)
        driver.find_element_by_css_selector('#passwordNext > content').click()
        sleep(5)
        driver.find_element_by_xpath('//table/tbody/tr[1]/td[5]').click()
        sleep(10)
        self.assertIn(
            "Password reset on",
            driver.find_element_by_xpath(
                '//*[@role="main"]/div/table/tr/td[1]/div[2]/div[1]/div[2]'
                '/div[1]/h2').get_attribute("innerHTML"),
            msg=None)
        self.assertEqual(
            "Hey there,",
            driver.find_element_by_xpath(
                '//*[@role="listitem"]/div/div/div/div[1]/div[1]'
                '/div[2]/div[3]/div[3]/div[1]/div[2]/div[2]/h1').get_attribute(
                    "innerHTML"),
            msg=None)
        self.assertEqual(
            "Someone requested a new password for you Cerebro account.",
            driver.find_element_by_xpath(
                '//*[@role="listitem"]/div/div/div/div[1]/div[1]'
                '/div[2]/div[3]/div[3]/div[1]/div[2]/div[2]/p[1]').
            get_attribute("innerHTML"),
            msg=None)
        self.assertEqual("Reset Password",
                         driver.find_element_by_xpath(
                             '//*[@role="listitem"]/div/div/div/div[1]/div[1]'
                             '/div[2]/div[3]/div[3]/div[1]/div[2]/div[2]/a/h2'
                         ).get_attribute("innerHTML"),
                         msg=None)
        self.assertEqual(
            "If you didn't make this request then you can safely ignore this email.",
            driver.find_element_by_xpath(
                '//*[@role="listitem"]/div/div/div/div[1]/div[1]'
                '/div[2]/div[3]/div[3]/div[1]/div[2]/div[2]/p[2]').
            get_attribute("innerHTML"),
            msg=None)
        driver.find_element_by_xpath(
            '//table/tr/td[1]/div[2]/div[2]/div/div[3]/div/div/div/div/div/div[1]/'
            'div[2]/div[3]/div[3]/div/div[2]/div[2]/a/h2').click()
        screenshot(self, path)
        sleep(5)
        driver.switch_to.window(driver.window_handles[1])
        sleep(3)
        self.assertEqual("We are",
                         driver.find_element_by_xpath('//*[@id="we"]').text,
                         msg=None)
        self.assertEqual(
            "Cerebro Smart Media",
            driver.find_element_by_xpath('//*[@id="content"]/h2').text,
            msg=None)
        self.assertEqual(
            "Set new password",
            driver.find_element_by_xpath('//*[@id="subtitle"]').text,
            msg=None)
        self.assertEqual(
            "The reset password link is no longer valid",
            driver.find_element_by_xpath(
                '//*[@id="content"]/form/fieldset/div/div/strong').text,
            msg=None)
        self.assertEqual(driver.find_element_by_xpath(
            '//*[@id="content"]/form/fieldset/div/a').text.upper(),
                         "GO BACK",
                         msg=None)
        screenshot(self, path)
        driver.find_element_by_xpath(
            '//*[@id="content"]/form/fieldset/div/a').click()
        sleep(2)
        self.assertEqual(
            "http://stage.eupam5k9mb.us-west-2.elasticbeanstalk.com/admin/login/",
            driver.current_url,
            msg=None)
Esempio n. 24
0
    def test_edit_user_bd(self):
        global users
        info = json.loads(users)
        driver = self.driver

        # Login
        login(self)
        time.sleep(3)
        driver.find_element_by_xpath(
            '//*[@id="sections-access"]/div[1]/a').click()
        time.sleep(2)

        # Search user
        driver.find_element_by_id('inputSrc').click()
        time.sleep(2)
        driver.find_element_by_xpath('//*[@id="search"]').send_keys(
            info[0]['email'])
        time.sleep(5)

        # Edit the status
        driver.find_element_by_xpath(
            '//*[@id="usertable"]/tbody/tr/td[4]/a[1]/i').click()
        time.sleep(5)
        driver.find_element_by_css_selector(
            '#form-edit #edit-form-status').click()
        aleatory = randint(0, 2)
        driver.find_element_by_css_selector(
            '#form-edit #edit-form-status> option[value="%d"]' %
            aleatory).click()
        print(
            driver.find_element_by_xpath(
                '//*[@id="form-edit"]/span').get_attribute('innerHTML'))
        driver.find_element_by_css_selector('#form-edit > span > a').click()
        time.sleep(3)
        driver.find_element_by_css_selector(
            '#form-change #change-pwd-password1').clear()
        driver.find_element_by_css_selector(
            '#form-change #change-pwd-password1').send_keys(
                info[0]["password"])
        time.sleep(3)
        self.assertIn(
            "Your password can't be too similar to your other personal information.",
            driver.find_element_by_xpath(
                '//*[@id="form-change"]/div[1]/ul/li[1]').get_attribute(
                    'innerHTML'),
            msg=None)
        time.sleep(3)
        self.assertIn(
            "Your password must contain at least 8 characters.",
            driver.find_element_by_xpath(
                '//*[@id="form-change"]/div[1]/ul/li[2]').get_attribute(
                    'innerHTML'),
            msg=None)
        time.sleep(3)
        self.assertIn(
            "Your password can't be a commonly used password.",
            driver.find_element_by_xpath(
                '//*[@id="form-change"]/div[1]/ul/li[3]').get_attribute(
                    'innerHTML'),
            msg=None)
        time.sleep(3)
        self.assertIn(
            "Your password can't be entirely numeric.",
            driver.find_element_by_xpath(
                '//*[@id="form-change"]/div[1]/ul/li[4]').get_attribute(
                    'innerHTML'),
            msg=None)
        time.sleep(3)
        driver.find_element_by_css_selector(
            '#form-change #change-pwd-password2').clear()
        driver.find_element_by_css_selector(
            '#form-change #change-pwd-password2').send_keys(
                info[0]["password"])
        driver.find_element_by_xpath(
            '//*[@id="modal-change-pwd"]/div/div/div[3]/button').click()
        time.sleep(2)
        driver.find_element_by_xpath(
            '//*[@id="modal-edit"]/div/div/div[3]/button').click()
        time.sleep(2)
        # Screenshot
        path = "/users/screenshot/edit/"
        screenshot(self, path)
        time.sleep(2)

        # Search user
        driver.find_element_by_id('inputSrc').click()
        time.sleep(2)
        driver.find_element_by_xpath('//*[@id="search"]').send_keys(
            info[0]['email'])
        time.sleep(5)

        # Edit the name
        driver.find_element_by_xpath(
            '//*[@id="usertable"]/tbody/tr/td[4]/a[1]/i').click()
        time.sleep(5)
        driver.find_element_by_css_selector(
            '#form-edit #edit-form-name').clear()
        driver.find_element_by_css_selector(
            '#form-edit #edit-form-name').send_keys(info[0]["name"])
        driver.find_element_by_xpath(
            '//*[@id="modal-edit"]/div/div/div[3]/button').click()
        time.sleep(2)

        # Screenshot
        screenshot(self, path)

        # Search user
        driver.find_element_by_id('inputSrc').click()
        time.sleep(2)
        driver.find_element_by_xpath('//*[@id="search"]').send_keys(
            info[0]['email'])
        time.sleep(5)

        # Edit the email
        driver.find_element_by_xpath(
            '//*[@id="usertable"]/tbody/tr/td[4]/a[1]/i').click()
        time.sleep(5)
        driver.find_element_by_css_selector(
            '#form-edit #edit-form-email').clear()
        driver.find_element_by_css_selector(
            '#form-edit #edit-form-email').send_keys(info[0]["email"])
        driver.find_element_by_xpath(
            '//*[@id="modal-edit"]/div/div/div[3]/button').click()
        time.sleep(2)

        # Screenshot
        path = "/users/screenshot/add/"
        screenshot(self, path)
Esempio n. 25
0
    def test_add_client_success(self):
        global clients
        path = "clients/client/screenshot/test_add_client_success"
        info = json.loads(clients)
        rand = randint(0, len(info) - 1)

        # login
        login(self)
        sleep(3)
        driver = self.driver
        self.assertIn(
            "http://stage.eupam5k9mb.us-west-2.elasticbeanstalk.com/admin/clients/",
            driver.current_url,
            msg=None)
        sleep(3)
        driver.find_element_by_xpath('//*[@id="btn-add"]').click()
        sleep(1)
        driver.find_element_by_xpath('//*[@id="add-form-email"]').send_keys(
            info[rand]['email'])
        driver.find_element_by_xpath(
            '//*[@id="add-form-person_contact"]').send_keys(info[rand]['name'])
        driver.find_element_by_xpath('//*[@id="add-form-status"]').click()
        driver.find_element_by_xpath('//*[@id="add-form-password"]').send_keys(
            info[rand]['password'])
        driver.find_element_by_xpath('//*[@id="add-form-cpm"]').send_keys(
            info[rand]['cpm'])
        driver.find_element_by_xpath('//*[@id="add-form-budget"]').send_keys(
            info[rand]['budget'])
        driver.find_element_by_xpath(
            '//*[@id="add-form-company_name"]').send_keys(
                info[rand]['company'])
        driver.find_element_by_xpath('//*[@id="add-form-rfc"]').send_keys(
            info[rand]['rfc'])
        driver.find_element_by_xpath('//*[@id="add-form-address"]').send_keys(
            info[rand]['address'])
        driver.find_element_by_xpath('//*[@id="add-form-phone"]').send_keys(
            info[rand]['phone'])
        screenshot(self, path)
        driver.find_element_by_xpath(
            "//*[@id='modal-add']/div[1]/div[1]/div[3]/button[1 and @type='submit']"
        ).click()
        sleep(10)
        driver.find_element_by_xpath('//*[@id="inputSrc"]/img').click()
        driver.find_element_by_id('search').send_keys(info[rand]['rfc'])
        sleep(5)
        self.assertEqual(info[rand]['email'],
                         driver.find_element_by_xpath(
                             '//*[@id="clienttable"]/tbody/tr[1]/td[1]').text,
                         msg=None)
        self.assertEqual(info[rand]['name'],
                         driver.find_element_by_xpath(
                             '//*[@id="clienttable"]/tbody/tr[1]/td[2]').text,
                         msg=None)
        self.assertEqual(info[rand]['rfc'],
                         driver.find_element_by_xpath(
                             '//*[@id="clienttable"]/tbody/tr[1]/td[3]').text,
                         msg=None)
        self.assertEqual('active',
                         driver.find_element_by_xpath(
                             '//*[@id="clienttable"]/tbody/tr[1]/td[4]').text,
                         msg=None)
        screenshot(self, path)
        sleep(5)
Esempio n. 26
0
    def test_detail_client_success(self):
        # browser_name = self.driver.capabilities['browserName']
        # print(browser_name)
        path = "clients/client/screenshot/test_detail_client_success"
        info = json.loads(clients)

        # login
        login(self)
        sleep(3)
        driver = self.driver
        self.assertIn("%s/admin/clients/" % ModelConfig.base_url, driver.current_url, msg=None)
        sleep(3)
        driver.find_element_by_xpath('//*[@id="inputSrc"]/img').click()
        driver.find_element_by_id('search').send_keys(info[0]['rfc'])
        sleep(3)
        self.assertEqual(info[0]['email'], driver.find_element_by_xpath('//*[@id="clienttable"]/tbody/tr[1]/td[1]')
                         .text, msg=None)
        self.assertEqual(info[0]['name'], driver.find_element_by_xpath('//*[@id="clienttable"]/tbody/tr[1]/td[2]')
                         .text, msg=None)
        self.assertEqual(info[0]['rfc'], driver.find_element_by_xpath('//*[@id="clienttable"]/tbody/tr[1]/td[3]')
                         .text, msg=None)
        self.assertEqual('active', driver.find_element_by_xpath('//*[@id="clienttable"]/tbody/tr[1]/td[4]')
                         .text, msg=None)
        screenshot(self, path)
        driver.find_element_by_xpath('//*[@id="clienttable"]/tbody/tr/td[5]/a[1]').click()
        sleep(3)
        self.assertIn("%s/admin/client/detail/" % ModelConfig.base_url, driver.current_url, msg=None)
        self.assertEqual(info[0]['company'], driver.find_element_by_xpath('//*[@id="client-info-header"]/h2')
                         .text, msg=None)
        sleep(3)
        self.assertEqual("Clients /", driver.find_element_by_xpath('//*[@id="client-info-header"]/a[1]').text
                         .capitalize(), msg=None)
        self.assertEqual("Email", driver.find_element_by_xpath('//*[@id="client-info"]/div/div[1]/label').text
                         .capitalize(), msg=None)
        self.assertEqual("Company", (driver.find_element_by_xpath('//*[@id="client-info"]/div/div[2]/label')
                                     .text).capitalize(), msg=None)
        self.assertEqual("RFC", (driver.find_element_by_xpath('//*[@id="client-info"]/div/div[3]/label')
                         .text).upper(), msg=None)
        self.assertEqual("Address", (driver.find_element_by_xpath('//*[@id="client-info"]/div/div[4]/label')
                         .text).capitalize(), msg=None)
        self.assertEqual("Contact", (driver.find_element_by_xpath('//*[@id="client-info"]/div/div[5]/label')
                                     .text).capitalize(), msg=None)
        self.assertEqual("Phone", (driver.find_element_by_xpath('//*[@id="client-info"]/div/div[6]/label')
                         .text).capitalize(), msg=None)
        self.assertEqual("Budget", (driver.find_element_by_xpath('//*[@id="client-info"]/div/div[7]/label')
                         .text).capitalize(), msg=None)
        self.assertEqual("Cpm", (driver.find_element_by_xpath('//*[@id="client-info"]/div/div[8]/label')
                         .text).capitalize(), msg=None)
        self.assertEqual(info[0]['company'], driver.find_element_by_xpath('//*[@id="client-info-header"]/a[2]')
                         .text, msg=None)
        self.assertEqual(info[0]['email'], (driver.find_element_by_xpath('//*[@id="client-info"]/div/div[1]/p')
                         .text).rstrip(), msg=None)
        self.assertEqual(info[0]['company'], (driver.find_element_by_xpath('//*[@id="client-info"]/div/div[2]/p')
                         .text).rstrip(), msg=None)
        self.assertEqual(info[0]['rfc'], (driver.find_element_by_xpath('//*[@id="client-info"]/div/div[3]/p')
                         .text).rstrip(), msg=None)
        self.assertEqual(info[0]['address'], (driver.find_element_by_xpath('//*[@id="client-info"]/div/div[4]/p')
                         .text).rstrip(), msg=None)
        self.assertEqual(info[0]['name'], (driver.find_element_by_xpath('//*[@id="client-info"]/div/div[5]/p')
                         .text).rstrip(), msg=None)
        self.assertEqual(info[0]['phone'], (driver.find_element_by_xpath('//*[@id="client-info"]/div/div[6]/p')
                         .text).rstrip(), msg=None)
        self.assertEqual(info[0]['budget'], (driver.find_element_by_xpath('//*[@id="client-info"]/div/div[7]/p')
                         .text).rstrip(), msg=None)
        self.assertEqual(info[0]['cpm'], (driver.find_element_by_xpath('//*[@id="client-info"]/div/div[8]/p')
                         .text).rstrip(), msg=None)
        screenshot(self, path)
        sleep(3)
Esempio n. 27
0
    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)
Esempio n. 28
0
 def test_double_click_manager(self):
     path = path_screenshot + "test_double_click_manager"
     sleep(3)
     driver = self.driver
     self.assertIn(ModelConfig.base_url + "/admin/clients/",
                   driver.current_url,
                   msg=None)
     sleep(3)
     driver.find_element_by_xpath('//*[@id="inputSrc"]/img').click()
     driver.find_element_by_id('search').send_keys(client[0]['rfc'])
     sleep(2)
     driver.find_element_by_xpath(
         '//*[@id="clienttable"]/tbody/tr/td[5]/a[1]').click()
     sleep(3)
     self.assertIn(ModelConfig.base_url + "/admin/client/detail/",
                   driver.current_url,
                   msg=None)
     self.assertEqual(client[0]['company'],
                      driver.find_element_by_xpath(
                          '//*[@id="client-info-header"]/h2').text,
                      msg=None)
     sleep(2)
     driver.find_element_by_xpath(
         '//*[@id="campaigntable"]/tbody/tr/td[8]/a[1]').click()
     sleep(3)
     self.assertIn(ModelConfig.base_url + "/admin/campaign/detail/",
                   driver.current_url,
                   msg=None)
     self.assertEqual(campaign[0]['name'],
                      driver.find_element_by_xpath(
                          '//*[@id="client-info-header"]/h2').text,
                      msg=None)
     self.assertEqual(
         "DoubleClick Manager",
         driver.find_element_by_xpath('/html/body/div[4]/h2').text,
         msg=None)
     self.assertEqual(
         "To improve your campaign, connect with DoubleClick Manager. Check the connection guide",
         driver.find_element_by_xpath(
             '/html/body/div[4]/div/div/span').text,
         msg=None)
     self.assertEqual("Client ID",
                      driver.find_element_by_xpath(
                          '//*[@id="form-dbm"]/div/div[1]/div/label').text,
                      msg=None)
     self.assertEqual("Client Secret",
                      driver.find_element_by_xpath(
                          '//*[@id="form-dbm"]/div/div[2]/div/label').text,
                      msg=None)
     self.assertEqual(
         "CONNECT",
         driver.find_element_by_xpath(
             '//*[@id="form-dbm"]/div/div[3]/div/button').text.upper(),
         msg=None)
     self.assertEqual("Check the connection guide",
                      driver.find_element_by_xpath(
                          '/html/body/div[4]/div/div/span/a').text,
                      msg=None)
     driver.find_element_by_xpath(
         '/html/body/div[4]/div/div/span/a').click()
     sleep(3)
     screenshot(self, path)
     sleep(6)
     self.assertTrue(os.path.exists(file_path), msg=None)
Esempio n. 29
0
    def test_reset_password_email(self):
        driver = self.driver
        path = "login/screenshot/test_reset_password_email"
        browser_name = self.driver.capabilities['browserName']

        driver.get('https://mail.google.com/mail/u/0/#inbox')

        sleep(8)
        driver.find_element_by_css_selector('#identifierId').send_keys(email)
        driver.find_element_by_css_selector(
            '#identifierNext > content').click()
        sleep(5)
        driver.find_element_by_css_selector('#password > div > div > div > input')\
            .send_keys(password)
        driver.find_element_by_css_selector('#passwordNext > content').click()
        sleep(5)
        driver.find_element_by_xpath('//table/tbody/tr[1]/td[5]').click()
        sleep(10)
        self.assertIn(
            "Password reset on",
            driver.find_element_by_xpath(
                '//*[@role="main"]/div/table/tr/td[1]/div[2]/div[1]/div[2]'
                '/div[1]/h2').get_attribute("innerHTML"),
            msg=None)
        self.assertEqual(
            "Hey there,",
            driver.find_element_by_xpath(
                '//*[@role="listitem"]/div/div/div/div[1]/div[1]'
                '/div[2]/div[3]/div[3]/div[1]/div[2]/div[2]/h1').get_attribute(
                    "innerHTML"),
            msg=None)
        self.assertEqual(
            "Someone requested a new password for you Cerebro account.",
            driver.find_element_by_xpath(
                '//*[@role="listitem"]/div/div/div/div[1]/div[1]'
                '/div[2]/div[3]/div[3]/div[1]/div[2]/div[2]/p[1]').
            get_attribute("innerHTML"),
            msg=None)
        self.assertEqual("Reset Password",
                         driver.find_element_by_xpath(
                             '//*[@role="listitem"]/div/div/div/div[1]/div[1]'
                             '/div[2]/div[3]/div[3]/div[1]/div[2]/div[2]/a/h2'
                         ).get_attribute("innerHTML"),
                         msg=None)
        self.assertEqual(
            "If you didn't make this request then you can safely ignore this email.",
            driver.find_element_by_xpath(
                '//*[@role="listitem"]/div/div/div/div[1]/div[1]'
                '/div[2]/div[3]/div[3]/div[1]/div[2]/div[2]/p[2]').
            get_attribute("innerHTML"),
            msg=None)
        driver.find_element_by_xpath(
            '//table/tr/td[1]/div[2]/div[2]/div/div[3]/div/div/div/div/div/div[1]/'
            'div[2]/div[3]/div[3]/div/div[2]/div[2]/a/h2').click()
        screenshot(self, path)
        sleep(5)
        driver.switch_to.window(driver.window_handles[1])
        sleep(3)
        self.assertEqual("We are",
                         driver.find_element_by_xpath('//*[@id="we"]').text,
                         msg=None)
        self.assertEqual(
            "Cerebro Smart Media",
            driver.find_element_by_xpath('//*[@id="content"]/h2').text,
            msg=None)
        self.assertEqual(
            "Set new password",
            driver.find_element_by_xpath('//*[@id="subtitle"]').text,
            msg=None)
        self.assertEqual(
            "SIGN IN",
            driver.find_element_by_xpath(
                '//*[@id="content"]/form/fieldset/div/button').text.upper(),
            msg=None)
        driver.find_element_by_xpath('//*[@id="id_new_password1"]').send_keys(
            '12345678#9')
        driver.find_element_by_xpath('//*[@id="id_new_password2"]').send_keys(
            '12345678#')
        driver.find_element_by_xpath(
            '//*[@id="content"]/form/fieldset/div/button').click()
        sleep(7)
        self.assertEqual("The two password fields didn't match.",
                         driver.find_element_by_xpath(
                             '/html/body/div[1]/div[2]/div/div/strong').text,
                         msg=None)
        screenshot(self, path)
        sleep(2)
        driver.find_element_by_xpath('//*[@id="id_new_password1"]').send_keys(
            '123456789')
        driver.find_element_by_xpath('//*[@id="id_new_password2"]').send_keys(
            '123456789')
        driver.find_element_by_xpath(
            '//*[@id="content"]/form/fieldset/div/button').click()
        sleep(3)
        self.assertEqual(
            "This password is too common.",
            driver.find_element_by_xpath(
                '/html/body/div[1]/div[2]/div/div[1]/strong').text,
            msg=None)
        self.assertEqual(
            "This password is entirely numeric.",
            driver.find_element_by_xpath(
                '/html/body/div[1]/div[2]/div/div[2]/strong').text,
            msg=None)
        screenshot(self, path)
        sleep(2)
        driver.find_element_by_xpath('//*[@id="id_new_password1"]').send_keys(
            similary)
        driver.find_element_by_xpath('//*[@id="id_new_password2"]').send_keys(
            similary)
        driver.find_element_by_xpath(
            '//*[@id="content"]/form/fieldset/div/button').click()
        sleep(5)
        self.assertEqual("The password is too similar to the email.",
                         driver.find_element_by_xpath(
                             '/html/body/div[1]/div[2]/div/div/strong').text,
                         msg=None)
        screenshot(self, path)
        sleep(2)
        driver.find_element_by_xpath('//*[@id="id_new_password1"]').send_keys(
            '1234567')
        driver.find_element_by_xpath('//*[@id="id_new_password2"]').send_keys(
            '1234567')
        driver.find_element_by_xpath(
            '//*[@id="content"]/form/fieldset/div/button').click()
        sleep(5)
        self.assertEqual(
            "This password is too short. It must contain at least 8 characters.",
            driver.find_element_by_xpath(
                '/html/body/div[1]/div[2]/div/div[1]/strong').text,
            msg=None)
        self.assertEqual(
            "This password is too common.",
            driver.find_element_by_xpath(
                '/html/body/div[1]/div[2]/div/div[2]/strong').text,
            msg=None)
        self.assertEqual(
            "This password is entirely numeric.",
            driver.find_element_by_xpath(
                '/html/body/div[1]/div[2]/div/div[3]/strong').text,
            msg=None)
        screenshot(self, path)
        sleep(2)
        driver.find_element_by_xpath('//*[@id="id_new_password1"]').send_keys(
            '12345678#9')
        driver.find_element_by_xpath('//*[@id="id_new_password2"]').send_keys(
            '12345678#9')
        driver.find_element_by_xpath(
            '//*[@id="content"]/form/fieldset/div/button').click()
        sleep(3)
        self.assertEqual("We are",
                         driver.find_element_by_xpath('//*[@id="we"]').text,
                         msg=None)
        self.assertEqual(
            "Cerebro Smart Media",
            driver.find_element_by_xpath('//*[@id="content"]/h2').text,
            msg=None)
        self.assertEqual(
            "Please login to your account",
            driver.find_element_by_xpath('//*[@id="subtitle"]').text,
            msg=None)
        self.assertEqual("SIGN IN",
                         driver.find_element_by_xpath(
                             '//*[@id="formLogin"]/button').text.upper(),
                         msg=None)
        screenshot(self, path)
        sleep(2)
        driver.find_element_by_xpath('//*[@id="id_username"]').send_keys(email)
        driver.find_element_by_xpath('//*[@id="id_password"]').send_keys(
            '12345678#9')
        driver.find_element_by_xpath('//*[@id="formLogin"]/button').click()
        sleep(3)
        self.assertIn(
            "http://stage.eupam5k9mb.us-west-2.elasticbeanstalk.com/admin/clients/",
            driver.current_url,
            msg=None)
        logout(self)
        driver.switch_to.window(driver.window_handles[0])
        sleep(5)
        driver.find_element_by_xpath(
            '//table/tr/td[1]/div[2]/div[2]/div/div[3]/div/div/div/div/div/div[1]/'
            'div[2]/div[3]/div[3]/div/div[2]/div[2]/a/h2').click()
        sleep(5)
        if browser_name == "chrome" or browser_name == "MicrosoftEdge":
            driver.switch_to.window(driver.window_handles[2])
        else:
            if browser_name == "firefox":
                driver.switch_to.window(driver.window_handles[1])
        sleep(5)
        self.assertEqual("We are",
                         driver.find_element_by_xpath(
                             '//*[@id="we"]').get_attribute("innerHTML"),
                         msg=None)
        self.assertEqual(
            "Cerebro Smart Media",
            driver.find_element_by_xpath('//*[@id="content"]/h2').text,
            msg=None)
        self.assertEqual(
            "Set new password",
            driver.find_element_by_xpath('//*[@id="subtitle"]').text,
            msg=None)
        self.assertEqual(
            "The reset password link is no longer valid",
            driver.find_element_by_xpath(
                '/html/body/div[1]/div[2]/div/form/fieldset/div/div/strong').
            text,
            msg=None)
        self.assertEqual(
            "GO BACK",
            driver.find_element_by_xpath(
                '//*[@id="content"]/form/fieldset/div/a').text.upper(),
            msg=None)
        screenshot(self, path)