Beruflich Dokumente
Kultur Dokumente
2019sp93042
class SlackFailReport:
def __init__(self, driver_location, url):
self.url = url
self.driver_location = driver_location
options = Options()
options.headless = False # make this 'True' to run in background
WEBDRIVER_PATH = self.driver_location
self.username = 'Test_user'
self.password = '123456'
self.email = 'tu18228@gmail.com'
self.phone_number = '9945842250'
self.driver = webdriver.Chrome(executable_path=WEBDRIVER_PATH,
chrome_options=options)
def open_creat_account_page(self):
self.driver.get(self.url)
for _ in range(MAX_TRIES):
first_hover = self.driver.find_element_by_xpath(
'//*[@id="nav-link-accountList"]')
then_click = self.driver.find_element_by_xpath(
'//*[@id="nav-flyout-ya-newCust"]/a')
try:
Hover = ActionChains(self.driver).move_to_element(
first_hover).move_to_element(then_click)
Hover.click().perform()
time.sleep(30)
print("Account login Page loaded successfully")
return True
except WebDriverException:
print("element not clickable retrying..")
time.sleep(WAIT_TIME)
return False
email = self.driver.find_element_by_xpath('//*[@id="ap_email"]')
print('Send email: {}'.format(mail))
email.clear()
email.send_keys(mail)
password = self.driver.find_element_by_xpath(
'//*[@id="ap_password"]')
print('Send Password: {}'.format(self.password))
password.clear()
password.send_keys(self.password)
self.driver.find_element_by_xpath('//*[@id="continue"]').click()
time.sleep(30)
data = self.validation_data()
validation_list.append({mail: data})
return validation_list
phone_no = self.driver.find_element_by_xpath(
'//*[@id="ap_phone_number"]')
print('Send Phone number: {}'.format(number))
phone_no.clear()
phone_no.send_keys(number)
password = self.driver.find_element_by_xpath(
'//*[@id="ap_password"]')
print('Send Password: {}'.format(self.password))
password.clear()
password.send_keys(self.password)
self.driver.find_element_by_xpath('//*[@id="continue"]').click()
time.sleep(30)
data = self.validation_data()
validation_list.append({number: data})
return validation_list
def validation_data(self):
try:
alert_text_1 = self.driver.find_element_by_xpath(
'//*[@id="auth-email-invalid-email-alert"]/div/div').text
if alert_text_1 != '':
return alert_text_1
except:
pass
try:
alert_text_2 = self.driver.find_element_by_class_name(
"a-list-item").text
if alert_text_2 != '':
return alert_text_2
except:
pass
try:
self.driver.find_element_by_xpath(
'//*[@id="authportal-main-
section"]/div[2]/div/div[3]/div/div/div[1]/label'
)
self.driver.find_element_by_xpath(
'//*[@id="authportal-main-section"]/div[2]/div/div[3]/div/p[3]/a'
).click()
return 'Account creation success'
except NoSuchElementException:
pass
return ''
def put_default_values(self):
email = self.driver.find_element_by_xpath('//*[@id="ap_email"]')
print('Send email: {}'.format(self.email))
email.clear()
email.send_keys(self.email)
phone_number = self.driver.find_element_by_xpath(
'//*[@id="ap_phone_number"]')
print('Send Phone number: {}'.format(self.phone_number))
phone_number.clear()
phone_number.send_keys(self.phone_number)
password = self.driver.find_element_by_xpath('//*[@id="ap_password"]')
print('Send Password: {}'.format(self.password))
password.clear()
password.send_keys(self.password)
if __name__ == "__main__":
driver_location = "C:\\Users\\I516429\\Downloads\\chrome80\\chromedriver.exe"
result_url = "https://www.amazon.in"
a = SlackFailReport(driver_location, result_url)
if (a.open_creat_account_page()):
namer = 'Test_user'
mail_list = [
'ananyalakshmi.p@gmail.com', 'tu18228@gmail.com',
'ajskahdkjhaskdhak'
]
mobile_number = ['12345', '9945842250', '12045678901234']
list_val = a.phone_validation(mobile_number)
print(list_val)
list_val1 = a.email_validation(mail_list)
print(list_val1)
else:
print('Failed to open Create account page')
OUTPUT:
About:
The website amazon.in accepts phone number with digits in between 5-14 and if the given
email id is already existing as user of amazon it doesn’t create new account and also if the email
id is invalid it doesn’t create new account.