def test_first(self): self.driver.find_element_by_name('ActionButton').click() email_address = generate_email() self.driver.find_element_by_xpath('//UIATextField').send_keys(email_address) self.driver.find_element_by_name('ActionButton').click() self.driver.find_element_by_name('tos unchecked').click() password = get_default_password() self.driver.find_element_by_xpath('//UIASecureTextField[1]').send_keys(password) self.driver.find_element_by_name('ActionButton').click() self.driver.find_element_by_xpath('//UIATextField').send_keys('Appium') self.driver.find_element_by_name('Birthdate').click() self.driver.find_element_by_name('Next').click() self.driver.find_element_by_xpath('//UIATextField').send_keys('group-many') self.driver.find_element_by_name('ActionButton').click() sleep(5) # Simulate user who stops briefly to read welcome text message self.driver.find_element_by_name('ActionButton').click() self.driver.find_element_by_xpath('//UIAApplication[1]/UIAWindow[1]/UIATableView[2]/UIATableCell[1]/UIAButton[1]').click() self.driver.find_element_by_name('ActionButton').click() online_status = self.driver.find_elements_by_name('ONLINE') offline_status = self.driver.find_elements_by_name('OFFLINE') assert len(online_status) + len(offline_status) == 1, "Neither ONLINE nor OFFLINE status displayed on Your PHA page" if (len(online_offline_status) > 0): print 'offline' else: print 'online'
def test_signup_happy_path(self): driver = self.driver driver.get(self.base_url) # Navigate to FREE TRIAL page from home page's header driver.find_element_by_css_selector(locators['free_trial']).click() # First Name and Last Name driver.find_element_by_id( locators['first_name']).send_keys('SauceLabs') driver.find_element_by_id( locators['last_name']).send_keys('Automation') # Email value has to be unique! unique_date_stamp = helpers.generate_date_stamp() email = helpers.generate_email(date_stamp=unique_date_stamp) driver.find_element_by_id(locators['email']).send_keys(email) # Company driver.find_element_by_id( locators['company']).send_keys('Foothill CS82A') # Company Size Select(driver.find_element_by_id( locators['company_size'])).select_by_visible_text('11-50') # Username value has to be unique # Use the hhmmss-mmmmmm portion of the unique date stamp generated earlier driver.find_element_by_id(locators['username']).send_keys( unique_date_stamp[9:]) # Password values have to match driver.find_element_by_id( locators['password']).send_keys('SauceLabs2015') driver.find_element_by_id( locators['password_confirm']).send_keys('SauceLabs2015') # Submit the form try: element = WebDriverWait(driver, timeout).until( EC.presence_of_element_located( (By.ID, locators['submit_button']))) except TimeoutException: self.verificationErrors.append( "Timed out waiting for submit button") else: element.click() # Element found! # Verify that the new user has an Account page now try: self.assertEqual('Sauce Labs | Account', driver.title) except AssertionError as e: self.verificationErrors.append(str(e))
def signup(self, first_name = 'SauceLabs', last_name = 'Automation', email = helpers.generate_email(helpers.generate_date_stamp()), company = 'Foothill CS82A', company_size = '11-50', username = helpers.generate_date_stamp()[9:], password1='SauceLabs2015', password2='SauceLabs2015', ): driver = self.driver driver.get(self.base_url) # Navigate to FREE TRIAL page from home page's header driver.find_element_by_css_selector(locators['free_trial']).click() # First Name and Last Name driver.find_element_by_id(locators['first_name']).send_keys(first_name) driver.find_element_by_id(locators['last_name']).send_keys(last_name) # Email driver.find_element_by_id(locators['email']).send_keys(email) # Company driver.find_element_by_id(locators['company']).send_keys(company) # Company Size Select(driver.find_element_by_id(locators['company_size'])).select_by_visible_text(company_size) # Username value has to already exist driver.find_element_by_id(locators['username']).send_keys(username) # Password values have to match driver.find_element_by_id(locators['password']).send_keys(password1) driver.find_element_by_id(locators['password_confirm']).send_keys(password2) # Submit the form driver.find_element_by_id(locators['submit_button']).click() return driver
def test_signup_happy_path(self): driver = self.driver driver.get(self.base_url) # Navigate to FREE TRIAL page from home page's header driver.find_element_by_css_selector(locators['free_trial']).click() # First Name and Last Name driver.find_element_by_id(locators['first_name']).send_keys('SauceLabs') driver.find_element_by_id(locators['last_name']).send_keys('Automation') # Email value has to be unique! unique_date_stamp = helpers.generate_date_stamp() email = helpers.generate_email(date_stamp = unique_date_stamp) driver.find_element_by_id(locators['email']).send_keys(email) # Company driver.find_element_by_id(locators['company']).send_keys('Foothill CS82A') # Company Size Select(driver.find_element_by_id(locators['company_size'])).select_by_visible_text('11-50') # Username value has to be unique # Use the hhmmss-mmmmmm portion of the unique date stamp generated earlier driver.find_element_by_id(locators['username']).send_keys(unique_date_stamp[9:]) # Password values have to match driver.find_element_by_id(locators['password']).send_keys('SauceLabs2015') driver.find_element_by_id(locators['password_confirm']).send_keys('SauceLabs2015') # Submit the form try: element = WebDriverWait(driver, timeout).until( EC.presence_of_element_located((By.ID, locators['submit_button']))) except TimeoutException: self.verificationErrors.append("Timed out waiting for submit button") else: element.click() # Element found! # Verify that the new user has an Account page now try: self.assertEqual('Sauce Labs | Account', driver.title) except AssertionError as e: self.verificationErrors.append(str(e))
def test_signup_already_used_username_neg(self): driver = self.driver driver.get(self.base_url) # Navigate to FREE TRIAL page from home page's header driver.find_element_by_css_selector(locators['free_trial']).click() # First Name and Last Name driver.find_element_by_id(locators['first_name']).send_keys('SauceLabs') driver.find_element_by_id(locators['last_name']).send_keys('Automation') # Email value has to be unique unique_date_stamp = helpers.generate_date_stamp() email = helpers.generate_email(date_stamp = unique_date_stamp) driver.find_element_by_id(locators['email']).send_keys(email) # Company driver.find_element_by_id(locators['company']).send_keys('Foothill CS82A') # Company Size Select(driver.find_element_by_id(locators['company_size'])).select_by_visible_text('11-50') # Username value has to be unique # for a negtive test, use a used username 'jadewu' driver.find_element_by_id(locators['username']).send_keys('jadewu') # Password values have to match driver.find_element_by_id(locators['password']).send_keys('SauceLabs2015') driver.find_element_by_id(locators['password_confirm']).send_keys('SauceLabs2015') # Submit the form driver.find_element_by_id(locators['submit_button']).click() # Verify that the appropriate error message has been issued selector = driver.find_element_by_css_selector(locators['error_container']) try: self.assertEqual(in_use_username_error, selector.text) except AssertionError as e: self.verificationErrors.append(str(e))
def test_signup_group_with_blank_padded_email(self): get_started_page = GetStartedPage.GetStartedPage(self.driver) get_started_page.tap_action_button() email = " " + generate_email() + " " enter_email_page = EnterEmailPage.EnterEmailPage(self.driver) enter_email_page.enter_email(email) create_password_page = CreatePasswordPage.CreatePasswordPage(self.driver) create_password_page.enter_new_password() create_profile_page = CreateProfilePage.CreateProfilePage(self.driver) create_profile_page.enter_profile_info() enter_referral_code_page = EnterReferralCodePage.EnterReferralCodePage(self.driver) enter_referral_code_page.enter_referral_code('group-many') sleep(3) # Simulate user spending a few seconds to read the content on the custom welcome screen custom_welcome_page = CustomWelcomePage.CustomWelcomePage(self.driver) # assert not(custom_welcome_page.is_default_background_displayed()), 'Default background displayed when custom background should be' custom_welcome_page.tap_next() your_pha_page = YourPHAPage.YourPHAPage(self.driver) your_pha_page.decline_service()
# -*- coding: utf-8 -*- from selenium import webdriver from selenium.webdriver.support.ui import Select import unittest import helpers form_fields = { "first_name" : "SauceLabs", "last_name" : "Automation", "email" : helpers.generate_email(date_stamp=helpers.generate_date_stamp()), "company" : "Foothill CS82A", "username" : helpers.generate_date_stamp(), "password" : "", "password_confirm" : "" } class SauceLabsSignUpHappyPath(unittest.TestCase): def setUp(self): self.driver = webdriver.Firefox() self.driver.implicitly_wait(30) self.base_url = "https://saucelabs.com/signup/trial" self.verificationErrors = [] def test_sauce_labs_sign_up_happy_path(self): driver = self.driver driver.get(self.base_url) for field in form_fields: driver.find_element_by_id(field).send_keys(form_fields[field]) #company size select from drop down
def enter_email(self,email_address=generate_email()): self.driver.find_element_by_xpath(locators['email_address_field']).send_keys(email_address) self.driver.find_element_by_name(locators['next']).click()
import helpers import pandas as pd result = [] for i in range(200): email = helpers.generate_email(host="gmail.com") name = helpers.generate_alphanumeric("l") phone = helpers.generate_alphanumeric("dDDDDDDDDD") row = {"email": email, "name": name.capitalize(), "phone": phone} result.append(row) # df = pd.DataFrame(columns=list(result[0].keys())) df = pd.DataFrame(result) print(df) df.to_csv("Customer.csv")