Skip to content

Instantly share code, notes, and snippets.

@rafaelcs
Created November 30, 2016 14:31
Show Gist options
  • Save rafaelcs/1bccf4d3eb972bc903469679370cbdca to your computer and use it in GitHub Desktop.
Save rafaelcs/1bccf4d3eb972bc903469679370cbdca to your computer and use it in GitHub Desktop.
Fill form > save infos and assert new values
def update_contacts_form(self):
enter_twitter = "http://" + fake.text(max_nb_chars=13) + "com"
enter_facebook = fake.url()
enter_email = fake.free_email()
enter_phone_cell = fake.phone_number()
enter_home_phone = fake.phone_number()
enter_home_ext_phone = fake.building_number()
enter_work_phone = fake.phone_number()
enter_work_ext_phone = fake.building_number()
enter_street1 = fake.street_name()
enter_street2 = fake.street_suffix()
enter_building = fake.building_number()
enter_city = fake.city()
enter_zipcode = fake.zipcode()
self.find_element(*ContractorsLocators.CONTACT_TAB_LINK).click()
self.find_element(*ContractorsLocators.TWITTER).clear()
self.find_element(*ContractorsLocators.TWITTER).send_keys(enter_twitter)
self.find_element(*ContractorsLocators.FACEBOOK).clear()
self.find_element(*ContractorsLocators.FACEBOOK).send_keys(enter_facebook)
self.find_element(*ContractorsLocators.EMAIL).clear()
self.find_element(*ContractorsLocators.EMAIL).send_keys(enter_email)
self.find_element(*ContractorsLocators.CELL).clear()
self.find_element(*ContractorsLocators.CELL).send_keys(enter_phone_cell)
self.find_element(*ContractorsLocators.WORK).clear()
self.find_element(*ContractorsLocators.WORK).send_keys(enter_work_phone)
self.find_element(*ContractorsLocators.WORK_EXT).clear()
self.find_element(*ContractorsLocators.WORK_EXT).send_keys(enter_work_ext_phone)
self.find_element(*ContractorsLocators.HOME).clear()
self.find_element(*ContractorsLocators.HOME).send_keys(enter_home_phone)
self.find_element(*ContractorsLocators.HOME_EXT).clear()
self.find_element(*ContractorsLocators.HOME_EXT).send_keys(enter_home_ext_phone)
self.find_element(*ContractorsLocators.STREET_1).clear()
self.find_element(*ContractorsLocators.STREET_1).send_keys(enter_street1)
self.find_element(*ContractorsLocators.STREET_2).clear()
self.find_element(*ContractorsLocators.STREET_2).send_keys(enter_street2)
self.find_element(*ContractorsLocators.BUILDING).clear()
self.find_element(*ContractorsLocators.BUILDING).send_keys(enter_building)
self.find_element(*ContractorsLocators.CITY).clear()
self.find_element(*ContractorsLocators.CITY).send_keys(enter_city)
self.find_element(*ContractorsLocators.ZIP_CODE).clear()
self.find_element(*ContractorsLocators.ZIP_CODE).send_keys(enter_zipcode)
self.find_element(*ContractorsLocators.SAVE_BUTTON).click()
WebDriverWait(self.driver, AUTOCOMPLETE_TIMEOUT).until(
EC.text_to_be_present_in_element((By.CLASS_NAME, "success"), "Profile updated successfully"))
assert self.find_element(*ContractorsLocators.TWITTER).get_attribute("value") == enter_twitter
assert self.find_element(*ContractorsLocators.FACEBOOK).get_attribute("value") == enter_facebook
assert self.find_element(*ContractorsLocators.EMAIL).get_attribute("value") == enter_email
assert self.find_element(*ContractorsLocators.CELL).get_attribute("value") == enter_phone_cell
assert self.find_element(*ContractorsLocators.WORK).get_attribute("value") == enter_work_phone
assert self.find_element(*ContractorsLocators.WORK_EXT).get_attribute("value") == enter_work_ext_phone
assert self.find_element(*ContractorsLocators.HOME).get_attribute("value") == enter_home_phone
assert self.find_element(*ContractorsLocators.HOME_EXT).get_attribute("value") == enter_home_ext_phone
assert self.find_element(*ContractorsLocators.STREET_1).get_attribute("value") == enter_street1
assert self.find_element(*ContractorsLocators.STREET_2).get_attribute("value") == enter_street2
assert self.find_element(*ContractorsLocators.BUILDING).get_attribute("value") == enter_building
assert self.find_element(*ContractorsLocators.CITY).get_attribute("value") == enter_city
assert self.find_element(*ContractorsLocators.ZIP_CODE).get_attribute("value") == enter_zipcode
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment