def setUp(self): self.driver = ModelConfig.driver_web browser_name = self.driver.capabilities['browserName'] if browser_name == "chrome": self.driver.maximize_window() # login login(self) # ENVIROMENT SETTING code = """ client = {0} campaign = {1} cur.execute("DELETE FROM clients WHERE email = '%s'" % client[0]['email']) cur.execute("DELETE FROM campaigns WHERE name = '%s'" % campaign[0]['name']) sql_clients = 'INSERT INTO clients (person_contact, cpm, budget, status, email, "created_at", updated_at, ' \ 'password, company_name, rfc, phone, address) ' \ 'VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s,%s, %s) RETURNING id' val_clients = (client[0]['name'], client[0]['cpm'], client[0]['budget'], 1, client[0]['email'],strftime("%Y/%m/%d"), \ strftime("%Y/%m/%d"), client[0]['password'], client[0]['company'], client[0]['rfc'], client[0]['phone'], \ client[0]['address']) cur.execute(sql_clients, val_clients) sql_campaign = 'INSERT INTO campaigns (url, cam_code, name, budget, objetive, industry, category, created_at, ' \ 'updated_at, redirect_url, script_snippet, status, dbm_client_secret, dbm_client_id, ' \ 'client_id) ' \ 'VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)' val_campaign = (campaign[0]['url'], campaign[0]['camcode'], campaign[0]['name'], campaign[0]['budget'], campaign[0]['objetive'], campaign[0]['industry'], campaign[0]['category'], strftime("%Y/%m/%d"), strftime("%Y/%m/%d"), '', '', 1, '', '', cur.fetchone()[0]) cur.execute(sql_campaign, val_campaign)""".format(client, campaign) db_functions(code)
def go_to_creative(self): global types, client, campaign, creative driver = self.driver login(self) sleep(1) driver.find_element_by_css_selector( 'a[href*="/admin/client/detail/%d/"]' % client).click() sleep(1) band = 0 while band == 0: try: if driver.find_element_by_xpath( '//a[@href="/admin/campaign/detail/%d/"]' % campaign): band = 1 if browser_name == "internet explorer": print(browser_name) if browser_name == "chrome" or browser_name == "firefox" or browser_name == "edge": position = driver.find_element_by_xpath('//a[@href="/admin/campaign/detail/%d/"]' % campaign) \ .location_once_scrolled_into_view driver.execute_script("window.scrollTo(0, %d);" % (position["y"] + 110)) sleep(2) except NoSuchElementException: if browser_name == "chrome" or browser_name == "firefox" or browser_name == "edge": driver.execute_script( "window.scrollTo(0, document.body.scrollHeight);") sleep(2) driver.find_element_by_css_selector( "#campaigntable_paginate > ul > li.next > a").click() sleep(1) band = 0 driver.find_element_by_xpath( '//a[@href="/admin/campaign/detail/%d/"]' % campaign).click() sleep(1)
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)
def dashboard_main(self): driver = self.driver login(self) driver.find_element_by_xpath('//*[@id="inputSrc"]').click() sleep(1) driver.find_element_by_xpath('//*[@id="search"]').send_keys(client) sleep(3) # view driver.find_element_by_xpath('//*[@id="clienttable"]/tbody/tr[1]/td[5]/a[1]').click() sleep(3) # edit driver.find_element_by_xpath('//*[@id="user-dashboard"]/div/div/div[4]/a[1]').click() sleep(2)
def testuserempty(self): driver = self.driver info = json.loads(dashboard_success) code = """ info = {0} cur.execute("SELECT du.user_id FROM dashboard_users AS du JOIN users ON du.user_id = users.id where name = '%s' " "and email = '%s'" % (info[0]['name'], info[0]['email'])) try: id = cur.fetchone()[0] cur.execute("DELETE FROM users u USING dashboard_users du JOIN users u ON u.id = user_id JOIN "admin_historicaluser hu ON history_user_id=u.id WHERE duser_id = u.id AND u.id = history_user_id AND " "u.id = %s" % id) # cur.execute("DELETE FROM admin_historicaluser WHERE history_user_id = %s" % id) # cur.execute("DELETE FROM users WHERE id = %s" % id) except Exception as errorException: errorException """.format(info) db_functions(code) login(self) driver.find_element_by_xpath('//*[@id="inputSrc"]').click() sleep(1) driver.find_element_by_xpath('//*[@id="search"]').send_keys(client) sleep(1) # view driver.find_element_by_xpath('//*[@id="clienttable"]/tbody/tr[1]/td[5]/a[1]').click() sleep(3) # button_dashboard driver.find_element_by_xpath('//*[@id="btn-add-"]').click() sleep(3) # email driver.find_element_by_xpath('//*[@id="add-dash-user-email"]')\ .send_keys((info[0]["email"])) # name driver.find_element_by_xpath('//*[@id="add-dash-user-name"]')\ .send_keys((info[0]["name"])) sleep(3) # password driver.find_element_by_xpath('//*[@id="add-dash-user-password1"]')\ .send_keys((info[0]["password"])) # confirmation de password driver.find_element_by_xpath('//*[@id="add-dash-user-password2"]')\ .send_keys((info[0]["password"])) # save driver.find_element_by_xpath('//*[@id="modal-add-dashboard-user"]/div/div/div[3]/button').click() sleep(3) # asser self.assertEqual(info[0]["name"], driver.find_element_by_xpath('//*[@id="user-dashboard"]/div/div/div[2]') .text, msg=None) self.assertEqual(info[0]["email"], driver.find_element_by_xpath('//*[@id="user-dashboard"]/div/div/div[1]') .text, msg=None)
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)
def create_setup(self): driver = self.driver # Llamada a login login(self) sleep(1) self.assertIn( self, "http://stage.eupam5k9mb.us-west-2.elasticbeanstalk.com/admin/clients/?next=/admin/login/", driver.current_url) driver.find_element_by_xpath( '//*[@id="sections-access"]/div[1]/a').click() sleep(2) driver.find_element_by_xpath('//*[@id="btn-add"]').click() sleep(2)
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)
def test_dashboard_remove_successful(self): driver = self.driver login(self) # view driver.find_element_by_xpath('//*[@id="clienttable"]/tbody/tr[4]/td[6]/a[1]/i').click() time.sleep(3) # delete driver.find_element_by_xpath('//*[@id="user-dashboard"]/div/div/div[4]/a[2]/i').click() time.sleep(4) # delete driver.find_element_by_xpath('//*[@id="modal-delete"]/div/div/div[3]/div[2]').click() time.sleep(2) # Enter the confirmation driver.find_element_by_xpath('//*[@id="input-email"]').send_keys("andres") time.sleep(3) # button driver.find_element_by_xpath('//*[@id="btn-submit"]').click() time.sleep(3)
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)
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)
def campaign_main(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(2) # view campaign driver.find_element_by_xpath( '//*[@id="campaigntable"]/tbody/tr[1]/td[8]/a[1]').click() # view edit driver.find_element_by_xpath('//*[@id="green-edit"]').click()
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 view driver.find_element_by_xpath('//*[@id="client-camp-header"]/div/button').click() sleep(1) # self.screenshot() # save driver.find_element_by_xpath('//*[@id="modal-add-campaign"]/div/div/div[3]/button').click() sleep(2)
def create_setup(self): global users info = json.loads(users) driver = self.driver # Llamada a login login(self) self.assertIn( self, "http://stage.eupam5k9mb.us-west-2.elasticbeanstalk.com/admin/clients/?next=/admin/login/", driver.current_url) driver.find_element_by_xpath( '//*[@id="sections-access"]/div[1]/a').click() sleep(2) driver.find_element_by_xpath('//button[@id="inputSrc"]').click() sleep(1) driver.find_element_by_xpath('//input[@id="search"]').send_keys( info[0]['email']) sleep(2) driver.find_element_by_xpath( '//*[@id="usertable"]/tbody/tr[1]/td[4]/a[1]/i').click() sleep(2)
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)
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)
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)
def test_add_creative_success(self): global types, client, campaign, creative driver = self.driver login(self) self.assertIn("%s/admin/clients/" % ModelConfig.base_url, driver.current_url, msg=None) sleep(1) driver.find_element_by_css_selector( 'a[href*="/admin/client/detail/%d/"]' % client).click() sleep(1) self.assertIn("%s/admin/client/detail/" % ModelConfig.base_url, driver.current_url, msg=None) sleep(2) band = 0 while band == 0: try: if driver.find_element_by_xpath( '//a[@href="/admin/campaign/detail/%d/"]' % campaign): band = 1 if browser_name == "internet explorer": print(browser_name) if browser_name == "chrome" or browser_name == "firefox" or browser_name == "edge": position = driver.find_element_by_xpath('//a[@href="/admin/campaign/detail/%d/"]' % campaign) \ .location_once_scrolled_into_view driver.execute_script("window.scrollTo(0, %d);" % (position["y"] + 110)) sleep(2) except NoSuchElementException: if browser_name == "chrome" or browser_name == "firefox" or browser_name == "edge": driver.execute_script( "window.scrollTo(0, document.body.scrollHeight);") sleep(2) driver.find_element_by_css_selector( "#campaigntable_paginate > ul > li.next > a").click() sleep(2) band = 0 driver.find_element_by_xpath( '//a[@href="/admin/campaign/detail/%d/"]' % campaign).click() sleep(2) self.assertIn("%s/admin/campaign/detail/" % ModelConfig.base_url, driver.current_url, msg=None) for position_file in range(4): print("\n<<<------ %s ------>>>\n" % types[position_file]["type"]) position = driver.find_element_by_xpath( '//*[@id="btn-add-"]').location_once_scrolled_into_view driver.execute_script("window.scrollTo(0, %d);" % (position["y"] + 110)) sleep(2) driver.find_element_by_xpath('//*[@id="btn-add-"]').click() sleep(2) driver.find_element_by_css_selector( '#form-add-creative #add-creative-name').clear() driver.find_element_by_css_selector('#form-add-creative #add-creative-name') \ .send_keys(list_creatives[position_file]["name"]) driver.find_element_by_css_selector( '#form-add-creative #add-creative-status').click() sleep(1) # rand = random.randint(0,2) driver.find_element_by_css_selector( '#form-add-creative #add-creative-status > option[value="%d"]' % list_creatives[position_file]["status"]).click() sleep(1) driver.find_element_by_css_selector( '#form-add-creative #add-creative-measure').clear() driver.find_element_by_css_selector('#form-add-creative #add-creative-measure') \ .send_keys(list_creatives[position_file]["measure"]) driver.find_element_by_css_selector( '#form-add-creative #add-creative-url').clear() driver.find_element_by_css_selector('#form-add-creative #add-creative-url') \ .send_keys(list_creatives[position_file]["url"]) driver.find_element_by_css_selector( '#form-add-creative #add-creative-type').click() sleep(1) driver.find_element_by_css_selector( '#form-add-creative #add-creative-type > option[value="%s"]' % types[position_file]["type"]).click() sleep(1) driver.find_element_by_css_selector( '#form-add-creative #add-creative-type').click() sleep(1) # driver.find_element_by_css_selector('#form-add-creative #add-creative-file').click() # sleep(5) driver.switch_to_window(driver.window_handles[0]) sleep(2) if browser_name == "chrome" or browser_name == "firefox" or browser_name == "edge": position = driver.find_element_by_xpath('/html/body/div[12]/div/div/div[3]/button') \ .location_once_scrolled_into_view driver.execute_script("window.scrollTo(0, %d);" % (position["y"])) # for i in range(0,10): # sleep(1) # driver.find_element_by_css_selector('html').send_keys(Keys.ARROW_DOWN) sleep(2) image_path = types[position_file]["file"] driver.find_element_by_css_selector( '#form-add-creative #add-creative-file').send_keys(image_path) sleep(2) driver.find_element_by_xpath( '//*[@id="modal-add-creative"]/div/div/div[3]/button').click() sleep(3) try: while driver.find_element_by_css_selector( '#form-add-creative div div.loader-input-file.center span' ): print("Cargando %s ..." % types[position_file]["type"]) sleep(2) except NoSuchElementException: print("Archivo %s cargado" % types[position_file]["type"]) sleep(2) driver.execute_script( "window.scrollTo(0, document.body.scrollHeight);") sleep(2)
def testuserempty(self): driver = self.driver info = json.loads(dashboard_success) code = """ info = {0} client = "{1}" for d_user in info: cur.execute("SELECT du.user_id FROM dashboard_users AS du JOIN users ON du.user_id = users.id WHERE " "email = '%s'" % (d_user['email'])) try: id = cur.fetchone()[0] cur.execute("DELETE FROM dashboard_users WHERE user_id=%s" % id) cur.execute("DELETE FROM admin_historicaluser WHERE history_user_id = %s" % id) cur.execute("DELETE FROM users WHERE id = %s" % id) except Exception as errorException: errorException cur.execute("INSERT INTO users (name, password, status, email, created_at, updated_at, is_active, is_client) VALUES " "('%s', '%s', 1, '%s', current_timestamp, current_timestamp, true, true) RETURNING id;" % (info[1]['name'], info[1]['password'], info[1]['email'])) id = cur.fetchone()[0] cur.execute("SELECT id FROM clients WHERE email = '%s'" % client) id_client = cur.fetchone()[0] cur.execute("INSERT INTO dashboard_users (client_id, user_id) VALUES (%s, %s)" % (id_client, id)) """.format(info, client) db_functions(code) login(self) driver.find_element_by_xpath('//*[@id="inputSrc"]').click() sleep(1) driver.find_element_by_xpath('//*[@id="search"]').send_keys(client) sleep(1) # view driver.find_element_by_xpath( '//*[@id="clienttable"]/tbody/tr[1]/td[5]/a[1]').click() sleep(3) # button_dashboard driver.find_element_by_xpath( '//*[@id="user-dashboard"]/div/div/div[4]/a[1]').click() sleep(3) # email driver.find_element_by_xpath('//*[@id="edit-dash-user-email"]').clear() driver.find_element_by_xpath( '//*[@id="edit-dash-user-email"]').send_keys((info[0]["email"])) # name driver.find_element_by_xpath('//*[@id="edit-dash-user-name"]').clear() driver.find_element_by_xpath( '//*[@id="edit-dash-user-name"]').send_keys((info[0]["name"])) sleep(3) # password driver.find_element_by_xpath( '//*[@id="edit-dash-user-status"]').click() driver.find_element_by_xpath( '//*[@id="edit-dash-user-status"]').send_keys((info[0]["status"])) # confirmation de password # save driver.find_element_by_xpath( '//*[@id="modal-edit-dashboard-user"]/div/div/div[3]/button' ).click() sleep(3) # asser self.assertEqual(info[0]["name"], driver.find_element_by_xpath( '//*[@id="user-dashboard"]/div/div/div[2]').text, msg=None) self.assertEqual(info[0]["email"], driver.find_element_by_xpath( '//*[@id="user-dashboard"]/div/div/div[1]').text, msg=None)
def test_edit_creative_success(self): global types, client, campaign, creative, rand_creative, position_file driver = self.driver login(self) self.assertIn("%s/admin/clients/" % ModelConfig.base_url, driver.current_url, msg=None) sleep(1) driver.find_element_by_css_selector( 'a[href*="/admin/client/detail/%d/"]' % client).click() sleep(1) self.assertIn("%s/admin/client/detail/" % ModelConfig.base_url, driver.current_url, msg=None) sleep(2) band = 0 while band == 0: try: if driver.find_element_by_xpath( '//a[@href="/admin/campaign/detail/%d/"]' % campaign): band = 1 if browser_name == "internet explorer": print(browser_name) if browser_name == "chrome" or browser_name == "firefox" or browser_name == "edge": position = driver.find_element_by_xpath('//a[@href="/admin/campaign/detail/%d/"]' % campaign) \ .location_once_scrolled_into_view driver.execute_script("window.scrollTo(0, %d);" % (position["y"] + 110)) sleep(2) except NoSuchElementException: if browser_name == "chrome" or browser_name == "firefox" or browser_name == "edge": driver.execute_script( "window.scrollTo(0, document.body.scrollHeight);") sleep(2) driver.find_element_by_css_selector( "#campaigntable_paginate > ul > li.next > a").click() sleep(2) band = 0 driver.find_element_by_xpath( '//a[@href="/admin/campaign/detail/%d/"]' % campaign).click() sleep(2) self.assertIn("%s/admin/campaign/detail/" % ModelConfig.base_url, driver.current_url, msg=None) for position_file in range(4): rand_creative = random.randint(0, len(list_creatives) - 1) print("\n<<<------ %s ------>>>\n" % types[position_file]["type"]) position = driver.find_element_by_xpath( '//a[@href="/admin/campaign/detail/%d/creative/update/%s"]' % (campaign, creative)).location_once_scrolled_into_view driver.execute_script("window.scrollTo(0, %d);" % (position["y"] + 110)) sleep(2) driver.find_element_by_xpath( '//a[@href="/admin/campaign/detail/%d/creative/update/%d"]' % (campaign, creative)).click() sleep(2) self.assertIn("%s/admin/campaign/detail/%d/creative/update/%d" % (ModelConfig.base_url, campaign, creative), driver.current_url, msg=None) sleep(2) driver.find_element_by_css_selector( '#form-edit-creative #edit-creative-name').clear() driver.find_element_by_css_selector('#form-edit-creative #edit-creative-name')\ .send_keys(list_creatives[rand_creative]["name"]) driver.find_element_by_css_selector( '#form-edit-creative #edit-creative-status').click() sleep(1) driver.find_element_by_css_selector( '#form-edit-creative #edit-creative-status > option[value="%d"]' % list_creatives[rand_creative]["status"]).click() sleep(1) driver.find_element_by_css_selector( '#form-edit-creative #edit-creative-measure').clear() driver.find_element_by_css_selector('#form-edit-creative #edit-creative-measure')\ .send_keys(list_creatives[rand_creative]["measure"]) driver.find_element_by_css_selector( '#form-edit-creative #edit-creative-url').clear() driver.find_element_by_css_selector('#form-edit-creative #edit-creative-url')\ .send_keys(list_creatives[rand_creative]["url"]) driver.find_element_by_css_selector( '#form-edit-creative #edit-creative-type').click() sleep(1) driver.find_element_by_css_selector( '#form-edit-creative #edit-creative-type > option[value="%s"]' % types[position_file]["type"]).click() sleep(1) driver.find_element_by_css_selector( '#form-edit-creative #edit-creative-type').click() sleep(1) driver.find_element_by_xpath( '/html/body/div[13]/div/div/div[2]/form/div[6]/div[2]/p/a' ).click() sleep(5) driver.switch_to_window(driver.window_handles[0]) 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"])) # for i in range(0,10): # sleep(1) # driver.find_element_by_css_selector('html').send_keys(Keys.ARROW_DOWN) sleep(2) image_path = types[position_file]["file"] driver.find_element_by_css_selector( '#form-edit-creative #id_file').send_keys(image_path) sleep(2) driver.find_element_by_xpath( '//*[@id="modal-edit-creative"]/div/div/div[3]/button').click( ) sleep(3) try: while driver.find_element_by_css_selector( '# form-edit-creative div div.loader-input-file.center span' ): print("Cargando %s ..." % types[position_file]["type"]) sleep(2) except NoSuchElementException: print("Archivo %s cargado" % types[position_file]["type"]) position = driver.find_element_by_xpath('//a[@href="/admin/creative/detail/%s"]' % creative)\ .location_once_scrolled_into_view driver.execute_script("window.scrollTo(0, %d);" % (position["y"] + 110)) sleep(2) driver.find_element_by_xpath('//a[@href="/admin/creative/detail/%s"]' % creative).click() sleep(2) self.assertEqual( str(creative), driver.find_element_by_xpath('//*[@id="client-info"]/div/div[1]/p' ).get_attribute("innerText").rstrip(), msg=None) self.assertEqual( str(campaign), driver.find_element_by_xpath('//*[@id="client-info"]/div/div[2]/p' ).get_attribute("innerText").rstrip(), msg=None) self.assertEqual( list_creatives[rand]["name"].upper().replace(" ", "_") + "-" + str(creative), driver.find_element_by_xpath('//*[@id="client-info"]/div/div[3]/p' ).get_attribute("innerText").rstrip(), msg=None) self.assertEqual( list_creatives[rand_creative]["name"], driver.find_element_by_xpath('//*[@id="client-info"]/div/div[4]/p' ).get_attribute("innerText").rstrip(), msg=None) self.assertEqual( list_creatives[rand_creative]["measure"], driver.find_element_by_xpath('//*[@id="client-info"]/div/div[5]/p' ).get_attribute("innerText").rstrip(), msg=None) self.assertEqual( types[position_file]["type"], driver.find_element_by_xpath('//*[@id="client-info"]/div/div[6]/p' ).get_attribute("innerText").rstrip(), msg=None) status: None if list_creatives[rand_creative]["status"] == 0: status = "Inactive" elif list_creatives[rand_creative]["status"] == 1: status = "Active" elif list_creatives[rand_creative]["status"] == 2: status = "Deleted" self.assertEqual( status, driver.find_element_by_xpath('//*[@id="client-info"]/div/div[7]/p' ).get_attribute("innerText").rstrip(), msg=None) sleep(1)
def test_detail_creative_success(self): driver = self.driver login(self) self.assertIn("%s/admin/clients/" % ModelConfig.base_url, driver.current_url, msg=None) sleep(1) driver.find_element_by_css_selector( 'a[href*="/admin/client/detail/%d/"]' % client).click() sleep(1) self.assertIn("%s/admin/client/detail/" % ModelConfig.base_url, driver.current_url, msg=None) band = 0 while band == 0: try: if driver.find_element_by_xpath( '//a[@href="/admin/campaign/detail/%d/"]' % campaign): band = 1 if browser_name == "internet explorer": print(browser_name) if browser_name == "chrome" or browser_name == "firefox" or browser_name == "edge": position = driver.find_element_by_xpath('//a[@href="/admin/campaign/detail/%d/"]' % campaign) \ .location_once_scrolled_into_view driver.execute_script("window.scrollTo(0, %d);" % (position["y"] + 110)) sleep(2) except NoSuchElementException: if browser_name == "chrome" or browser_name == "firefox" or browser_name == "edge": driver.execute_script( "window.scrollTo(0, document.body.scrollHeight);") sleep(2) driver.find_element_by_css_selector( "#campaigntable_paginate > ul > li.next > a").click() sleep(2) band = 0 driver.find_element_by_xpath( '//a[@href="/admin/campaign/detail/%d/"]' % campaign).click() sleep(2) self.assertIn("%s/admin/campaign/detail/" % ModelConfig.base_url, driver.current_url, msg=None) position = driver.find_element_by_xpath( '//a[@href="/admin/creative/detail/%s"]' % creative).location_once_scrolled_into_view driver.execute_script("window.scrollTo(0, %d);" % (position["y"] + 110)) sleep(2) driver.find_element_by_xpath('//a[@href="/admin/creative/detail/%s"]' % creative).click() sleep(2) self.assertIn("%s/admin/creative/detail/" % ModelConfig.base_url, driver.current_url, msg=None) sleep(1) self.assertEqual( str(creative), driver.find_element_by_xpath('//*[@id="client-info"]/div/div[1]/p' ).get_attribute("innerText").rstrip(), msg=None) self.assertEqual( str(campaign), driver.find_element_by_xpath('//*[@id="client-info"]/div/div[2]/p' ).get_attribute("innerText").rstrip(), msg=None) self.assertEqual( list_creatives[rand]["name"].upper().replace(" ", "_") + "-" + str(creative), driver.find_element_by_xpath('//*[@id="client-info"]/div/div[3]/p' ).get_attribute("innerText").rstrip(), msg=None) self.assertEqual( list_creatives[rand]["name"], driver.find_element_by_xpath('//*[@id="client-info"]/div/div[4]/p' ).get_attribute("innerText").rstrip(), msg=None) self.assertEqual( list_creatives[rand]["measure"], driver.find_element_by_xpath('//*[@id="client-info"]/div/div[5]/p' ).get_attribute("innerText").rstrip(), msg=None) self.assertEqual( list_creatives[rand]["type"], driver.find_element_by_xpath('//*[@id="client-info"]/div/div[6]/p' ).get_attribute("innerText").rstrip(), msg=None) status: None if list_creatives[rand]["status"] == 0: status = "Inactive" elif list_creatives[rand]["status"] == 1: status = "Active" elif list_creatives[rand]["status"] == 2: status = "Deleted" self.assertEqual( status, driver.find_element_by_xpath('//*[@id="client-info"]/div/div[7]/p' ).get_attribute("innerText").rstrip(), msg=None) preview = driver.find_element_by_xpath('//*[@id="client-info"]/div/div[8]/p').get_attribute("innerText").\ rstrip() if preview == "Preview": # driver.find_element_by_link_text("Preview").click() driver.find_element_by_xpath( '/html/body/div[1]/div/div[8]/p/a').click() sleep(6) self.assertTrue(os.path.exists(file_path), msg=None) else: print("No hay archivo para descargar") sleep(1) driver.execute_script("arguments[0].click();", driver.find_element_by_id("btn-edit")) # driver.find_element_by_xpath('//*[@id="btn-edit"]').click() sleep(2) self.assertEqual( "http://stage.eupam5k9mb.us-west-2.elasticbeanstalk.com/admin/campaign/detail/%d/" "creative/update/%s" % (campaign, creative), driver.current_url, msg=None) driver.find_element_by_xpath( '//*[@id="modal-edit-creative"]/div/div/div[1]/button').click()
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()
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)
def testUploadCsv(self): global client, campaign driver = self.driver login(self) sleep(2) assert "%s/admin/clients/" % ModelConfig.base_url in driver.current_url driver.find_element_by_css_selector( 'a[href*="/admin/client/detail/%d/"]' % client).click() sleep(1) assert "%s/admin/client/detail/" % ModelConfig.base_url in driver.current_url band = 0 while band == 0: try: if driver.find_element_by_xpath( '//a[@href="/admin/campaign/detail/%d/"]' % campaign): band = 1 if browser_name == "internet explorer": print(browser_name) if browser_name == "chrome" or browser_name == "firefox" or browser_name == "edge": position = driver.find_element_by_xpath('//a[@href="/admin/campaign/detail/%d/"]' % campaign) \ .location_once_scrolled_into_view driver.execute_script("window.scrollTo(0, %d);" % (position["y"] + 110)) sleep(2) except NoSuchElementException: if browser_name == "chrome" or browser_name == "firefox" or browser_name == "edge": driver.execute_script( "window.scrollTo(0, document.body.scrollHeight);") sleep(2) driver.find_element_by_css_selector( "#campaigntable_paginate > ul > li.next > a").click() sleep(2) band = 0 driver.find_element_by_xpath( '//a[@href="/admin/campaign/detail/%d/"]' % campaign).click() sleep(2) assert "%s/admin/campaign/detail/" % ModelConfig.base_url in driver.current_url driver.find_element_by_xpath( '//*[@id="dashboard-user"]/div/div[3]/button').click() sleep(1) image_path = root_files + "creatives\creativesValidation .csv" driver.find_element_by_xpath('//*[@id="id_file"]').send_keys( image_path) sleep(2) driver.find_element_by_xpath( '//*[@id="modal-csv"]/div/div/div[3]/button').click() sleep(2) self.assertEqual( "In row #1: Repeated\n" "In row #2: NAME: This field cannot be blank.\n" "URL: Enter a valid URL.\n" "TYPE: Value 'OTRACOSA' is not a valid choice.\n" "In row #3: URL: This field cannot be blank.\n" "TYPE: This field cannot be blank.\n" "In row #4: NAME: This field cannot be blank.\n" "In row #5: URL: Enter a valid URL.\n", driver.find_element_by_xpath('//*[@id="form-csv"]/div/div[1]/span' ).get_attribute('innerText'), msg=None) sleep(3) driver.find_element_by_xpath( '//*[@id="modal-csv"]/div/div/div[1]/button').click() sleep(2) driver.refresh() sleep(1) driver.execute_script( "window.scrollTo(0, document.body.scrollHeight);") sleep(4)
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]').click() sleep(1) # Click en view driver.find_element_by_xpath( '//*[@id="client-camp-header"]/div/button').click() sleep(1) # llenado de Form # name driver.find_element_by_css_selector('#add-camp-name').send_keys( (info[0]['name'])) sleep(2) # Seleccionar Select contenedor Status driver.find_element_by_css_selector('#add-camp-status').click() sleep(3) # Seleccionar estatus aleatorio = randint(1, 3) driver.find_element_by_css_selector( '#add-camp-status > option:nth-child(%d)' % aleatorio).click() sleep(2) # Seleccionar Select contenedor INDUSTRY driver.find_element_by_css_selector('#add-camp-industry').click() sleep(2) # Seleccionar AUTOMOTRIZ driver.find_element_by_css_selector( '#add-camp-industry > option[value="automotriz"]').click() sleep(2) # Seleccionar Select contenedor CATEGORY driver.find_element_by_css_selector('#add-camp-category').click() sleep(2) # Seleccionar CELULARES driver.find_element_by_css_selector( '#add-camp-category > option[value="celulares"]').click() # BUGET driver.find_element_by_css_selector('#add-camp-budget').send_keys( (info[0]['budget'])) # URL driver.find_element_by_css_selector('#add-camp-url').send_keys( (info[0]['url'])) # OBJETIVE driver.find_element_by_css_selector('#add-camp-objetive').send_keys( (info[0]['objetive'])) driver.find_element_by_xpath( '//*[@id="form-add-campaign"]/div[9]/div/p/a').click() # enter driver.find_element_by_xpath( "//div[10]/div[1]/div[1]/div[3]/button[1]").click() sleep(3) try: if driver.find_element_by_xpath('//tr[1]/td[3]').get_attribute( "title") == info[0]['name']: True except Exception as error: print(error) driver.find_element_by_xpath( '//*[@id="client-camp-links"]/a[2]').click() sleep(2) self.assertEqual(info[0]['name'], driver.find_element_by_xpath('//tr[1]/td[3]').text, msg=None) self.assertEqual( float(info[0]['budget']), float(driver.find_element_by_xpath('//tr[1]/td[5]').text), msg=None) self.assertEqual(info[0]['objetive'], driver.find_element_by_xpath('//tr[1]/td[6]').text, msg=None) sleep(10) self.assertTrue(os.path.exists(file_path), msg=None)
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)
def testUploadCsv(self): global client, campaign driver = self.driver login(self) sleep(2) self.assertIn("%s/admin/clients/" % ModelConfig.base_url, driver.current_url) driver.find_element_by_css_selector( 'a[href*="/admin/client/detail/%d/"]' % client).click() sleep(1) self.assertIn("%s/admin/client/detail/" % ModelConfig.base_url, driver.current_url) band = 0 while band == 0: try: if driver.find_element_by_xpath( '//a[@href="/admin/campaign/detail/%d/"]' % campaign): band = 1 if browser_name == "internet explorer": print(browser_name) if browser_name == "chrome" or browser_name == "firefox" or browser_name == "edge": position = driver.find_element_by_xpath('//a[@href="/admin/campaign/detail/%d/"]' % campaign) \ .location_once_scrolled_into_view driver.execute_script("window.scrollTo(0, %d);" % (position["y"] + 110)) sleep(2) except NoSuchElementException: if browser_name == "chrome" or browser_name == "firefox" or browser_name == "edge": driver.execute_script( "window.scrollTo(0, document.body.scrollHeight);") sleep(2) driver.find_element_by_css_selector( "#campaigntable_paginate > ul > li.next > a").click() sleep(2) band = 0 driver.find_element_by_xpath( '//a[@href="/admin/campaign/detail/%d/"]' % campaign).click() sleep(2) self.assertIn("%s/admin/campaign/detail/" % ModelConfig.base_url, driver.current_url, msg=None) driver.find_element_by_xpath( '//*[@id="dashboard-user"]/div/div[3]/button').click() sleep(1) image_path = root_files + "creatives\creativesSuccess.csv" driver.find_element_by_xpath('//*[@id="id_file"]').send_keys( image_path) sleep(2) driver.find_element_by_xpath( '//*[@id="modal-csv"]/div/div/div[3]/button').click() sleep(2) # self.assertEqual("Record successfully added", # driver.find_element_by_xpath('//*[@id="form-csv"]/div/div[1]/span').get_attribute('innerText'), # msg=None) # sleep(3) # driver.find_element_by_xpath('//*[@id="modal-csv"]/div/div/div[1]/button').click() # sleep(2) # driver.refresh() sleep(2) driver.execute_script( "window.scrollTo(0, document.body.scrollHeight);") sleep(4)
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)
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)
def test_detail_creative_success(self): driver = self.driver login(self) self.assertIn("%s/admin/clients/" % ModelConfig.base_url, driver.current_url, msg=None) sleep(1) driver.find_element_by_css_selector( 'a[href*="/admin/client/detail/%d/"]' % client).click() sleep(1) self.assertIn("%s/admin/client/detail/" % ModelConfig.base_url, driver.current_url, msg=None) band = 0 while band == 0: try: if driver.find_element_by_xpath( '//a[@href="/admin/campaign/detail/%d/"]' % campaign): band = 1 if browser_name == "internet explorer": print(browser_name) if browser_name == "chrome" or browser_name == "firefox" or browser_name == "edge": position = driver.find_element_by_xpath('//a[@href="/admin/campaign/detail/%d/"]' % campaign) \ .location_once_scrolled_into_view driver.execute_script("window.scrollTo(0, %d);" % (position["y"] + 110)) sleep(2) except NoSuchElementException: if browser_name == "chrome" or browser_name == "firefox" or browser_name == "edge": driver.execute_script( "window.scrollTo(0, document.body.scrollHeight);") sleep(2) driver.find_element_by_css_selector( "#campaigntable_paginate > ul > li.next > a").click() sleep(2) band = 0 driver.find_element_by_xpath( '//a[@href="/admin/campaign/detail/%d/"]' % campaign).click() sleep(2) self.assertIn("%s/admin/campaign/detail/" % ModelConfig.base_url, driver.current_url, msg=None) position = driver.find_element_by_xpath( '//a[@data-id="%s" and @data-target="#modal-delete"]' % creative).location_once_scrolled_into_view driver.execute_script("window.scrollTo(0, %d);" % (position["y"] + 110)) sleep(2) confirm = driver.find_element_by_xpath('//a[@data-id="%s" and @data-target="#modal-delete"]' % creative)\ .get_property("dataset")['confirm'] driver.find_element_by_xpath( '//a[@data-id="%s" and @data-target="#modal-delete"]' % creative).click() sleep(2) driver.find_element_by_xpath( '//*[@id="modal-delete"]/div/div/div[3]/div[2]/button').click() sleep(1) driver.find_element_by_xpath( '//*[@id="input-confirmation"]').send_keys(confirm) driver.find_element_by_xpath('//*[@id="btn-submit"]').click() sleep(2) driver.find_element_by_xpath('//a[@href="/admin/creative/detail/%s"]' % creative).click() sleep(2) self.assertIn("%s/admin/creative/detail/" % ModelConfig.base_url, driver.current_url, msg=None) self.assertEqual( "Deleted", driver.find_element_by_xpath('//*[@id="client-info"]/div/div[7]/p' ).get_attribute("innerText").rstrip(), msg=None)