def test_quantityzero(self): quantity = 0 check_quantityzero = ProductDetail(self.driver) base = Base(self.driver) check_quantityzero.click_proInto_list() base.click('xpath', check_quantityzero.normal_image) base.click('xpath', check_quantityzero.button_close) base.clear_text(check_quantityzero.quantity_xpath) base.send_key('xpath', check_quantityzero.quantity_xpath, quantity) time.sleep(3) base.click('xpath', check_quantityzero.buton_addtocart) title = check_quantityzero.check_alert() self.assertEqual('Null quantity.', title, 'This alert is not matching')
def test_contact(self): email = '*****@*****.**' order = '26' url = 'C:/Users/Administrator/Pictures/1.jpg' message = 'Happiness is when she love you' ct = Contact(self.driver) base = Base(self.driver) base.click('xpath', Contact.button_contact) time.sleep(3) ct.set_subject() base.send_key('id', ct.email, email) base.send_key('id', ct.order, order) base.send_key('id', ct.file_upload, url) base.send_key('id', ct.message, message) base.click('id', ct.button_send_contact) time.sleep(5) title = ct.check_message_notice() self.assertEqual( "Your message has been successfully sent to our team.", title, "This notice is about contact")
def test_login_error(self): email = 'abc123' login = LoginPage(self.driver) base = Base(self.driver) base.click('xpath', login.sign_in) login.set_email(email) base.click('id', login.button_login_id) time.sleep(3) message = login.check_message() self.assertEqual('Invalid email address.', message, 'Email is True')
def test_changeOrderDetail(self): value = 3 email = '*****@*****.**' pw = '@@q7vLZDt2PdmuG' change_order = OrderPage(self.driver) modify = Base(self.driver) modify.get_product(0, 5) modify.click('xpath', change_order.checkout_out_xpath) time.sleep(3) list_deleted = [] change_order.choice_random(list_deleted, value) time.sleep(2) change_order.delete_random(list_deleted) modify.check_out() title = change_order.check_notice_success() self.assertEqual('Your order on My Store is complete.', title, 'This notice is matching') time.sleep(10)
def test_orderPro(self): email = '*****@*****.**' pw = '@@q7vLZDt2PdmuG' check_order = OrderPage(self.driver) modify = Base(self.driver) modify.get_product(0, 3) modify.click('xpath', OrderPage.checkout_out_xpath) time.sleep(3) total_product = check_order.total_price() all_total_product = check_order.amount_total_product() if total_product == all_total_product: print('Amount total is True') else: print('Amount total is False') modify.check_out() title = check_order.check_notice_success() self.assertEqual('Your order on My Store is complete.', title, 'This notice is matching') time.sleep(10)
def test_search(self, browser): if browser == "Firefox": self.driver = webdriver.Firefox(executable_path="E:/Test_FinalProject/geckodriver.exe") self.driver.implicitly_wait(10) self.driver.get("http://automationpractice.com/") time.sleep(3) elif browser == "Chrome": self.driver = webdriver.Chrome(executable_path="E:/Test_FinalProject/chromedriver.exe") self.driver.implicitly_wait(10) self.driver.get("http://automationpractice.com") time.sleep(3) text = 'Dress' search = ProductDetailPage(self.driver) base = Base(self.driver) base.click('xpath', search.search_box) base.send_key('xpath', search.search_box, text) time.sleep(3) base.clear_text(search.search_box) checkbox = search.check_search() self.assertEqual('Search', checkbox, 'This text is not matching')
def test_sale_product(self): email = '*****@*****.**' pw = '@@q7vLZDt2PdmuG' get_sale_product = OrderPage(self.driver) modify = Base(self.driver) lst_product = get_sale_product.check_sale_product() sale_product = '-20%' for i in lst_product: if sale_product in i.text: i.click() time.sleep(4) get_sale_product.add_toCart() modify.click('xpath', get_sale_product.checkout_out_xpath) modify.check_out() title = get_sale_product.check_notice_success() self.assertEqual('Your order on My Store is complete.', title, 'This notice is matching') time.sleep(10) time.sleep(10)
def test_quantity(self): quantity1 = 0 quantity2 = 1 check_quantity = ProductDetail(self.driver) base = Base(self.driver) check_quantity.click_proInto_list() base.click('xpath', check_quantity.normal_image) time.sleep(3) base.click('xpath', check_quantity.button_close) base.clear_text(check_quantity.quantity_xpath) base.send_key('xpath', check_quantity.quantity_xpath, quantity1) base.click('xpath', check_quantity.buton_addtocart) check_quantity.close_button_alert() base.clear_text(check_quantity.quantity_xpath) base.send_key('xpath', check_quantity.quantity_xpath, quantity2) base.click('xpath', check_quantity.buton_addtocart) time.sleep(5) title = check_quantity.get_alert_success() self.assertEqual('Product successfully added to your shopping cart', title, "This notice is does not matching") check_quantity.close_popup() get_name_detail = check_quantity.get_name_detail() get_quantity_detail = check_quantity.get_quantity_detail() base.click('xpath', check_quantity.button_cart_xpath) get_name_cart = check_quantity.get_name_cart() get_quantity_cart = check_quantity.get_quantity_cart() if get_name_detail == get_name_cart: if get_quantity_detail == get_quantity_cart: print('This product is successfully added to the cart')
def test_close_Viewlarge(self): check_click_button = ProductDetail(self.driver) base = Base(self.driver) check_click_button.click_proInto_list() base.click('xpath', check_click_button.normal_image) base.click('xpath', check_click_button.button_close) base.click('xpath', check_click_button.button_viewlarge) time.sleep(3) normal_image = base.get_size(check_click_button.normal_image) big_image = base.get_size(check_click_button.big_image) size_normal_image = normal_image.get('height') siz_big_image = big_image.get('height') base.compareer(size_normal_image, siz_big_image) location_image = base.get_location(check_click_button.normal_image) get_location_image = location_image.get('y') location_name = base.get_location(check_click_button.big_image) get_location_name = location_name.get('y') base.compareer(get_location_name, get_location_image)
def test_login_success(self): email = "*****@*****.**" firstname = 'oanh' lastname = 'ngoc yen' password = '******' address = 'Hai Duong' city = 'Ha Noi' zipcode = 10000 phone = '0388826899' alias = 'Nothing' login = LoginPage(self.driver) base = Base(self.driver) base.click('xpath', login.sign_in) login.set_email(email) base.click('id', login.button_login_id) time.sleep(3) base.send_key('xpath', login.first_name, firstname) base.send_key('xpath', login.last_name, lastname) base.send_key('id', login.pass_word, password) base.send_key('id', login.address, address) base.send_key('id', login.city, city) login.set_state() base.send_key('id', login.zip, zipcode) login.set_country() base.send_key('id', login.phone, phone) login.set_alias(alias) base.click('id', login.button_register) time.sleep(2) title = self.driver.title self.assertEqual('My account - My Store', title, 'This title is matching') time.sleep(5)