Exemplo n.º 1
0
class Login(Common):
    def __init__(self, driver):
        super().__init__(driver)
        self.driver = driver

    login_button = LocatorStrategy.locator_by_xpath("//a[@class='login']")
    email_field = LocatorStrategy.locator_by_id("email")
    password_field = LocatorStrategy.locator_by_id("passwd")
    submit_button = LocatorStrategy.locator_by_name("SubmitLogin")
    logout_button = LocatorStrategy.locator_by_css_selector(
        "a[class='logout']")

    def navigate_to_login_page(self):
        self.click(Login.login_button)
        self.get_screenshot(file_name="Login_page")
        self.time_sleep(sleep_time)

    def login_verify(self, email, password):
        self.driver_wait(wait_time)
        self.enter_text(Login.email_field, text=email)
        self.enter_text(Login.password_field, text=password)
        self.click(Login.submit_button)
        self.verify_element_present(Login.logout_button)

    def logout(self):
        self.click(Login.logout_button)
Exemplo n.º 2
0
class Search_Item(Common):


    def __init__(self, driver):
        super().__init__(driver)
        self.driver = driver
        #d = DataRead()
        self.data = DataRead.json_read('data.json')

    search_field = LocatorStrategy.locator_by_id("search_query_top")
    search_button = LocatorStrategy.locator_by_xpath("//button[@name='submit_search']")
    product = LocatorStrategy.locator_by_xpath("//div[@class='product-container']/div[1]/div/a/img")
    add_to_cart = LocatorStrategy.locator_by_xpath("//div[@class='product-container']/div[2]/div[2]/a[@title='Add to cart']")
    checkout_button = LocatorStrategy.locator_by_xpath("//*[@id='layer_cart']/div[1]/div[2]/div[4]/a")
    shopping_cart_checkout_button = LocatorStrategy.locator_by_xpath("//*[@id='center_column']/p[2]/a[1]/span")
    address_page_checkout_button = LocatorStrategy.locator_by_xpath("//*[@class='columns-container']/div/div[3]/div/form/p/button/span")

    def item_search(self):
        self.enter_text(Search_Item.search_field, text=self.data['item'])
        self.click(Search_Item.search_button)

    def add_item(self):
        self.actions(move1=Search_Item.product,move2=Search_Item.add_to_cart)

    def proceed_to_checkout(self):
        self.time_sleep(sleep_time)
        self.click(Search_Item.checkout_button)

    def shopping_cart_checkout(self):
        self.time_sleep(sleep_time)
        self.click(Search_Item.shopping_cart_checkout_button)

    def address_page_checkout(self):
        self.click(Search_Item.address_page_checkout_button)
Exemplo n.º 3
0
class HomePage(Common):
    def __init__(self, driver):
        super().__init__(driver)
        self.driver = driver

    logo = LocatorStrategy.locator_by_xpath(
        "//*[@class='logo img-responsive']")

    def navigate_to_homepage(self):
        self.click(HomePage.logo)
Exemplo n.º 4
0
class Womentab(Common):
    def __init__(self, driver):
        super().__init__(driver)
        self.driver = driver

    women_tab = LocatorStrategy.locator_by_xpath(
        "//div[@id='block_top_menu']/ul/li[1]")
    left_slider = LocatorStrategy.locator_by_xpath(
        "//a[contains(@class,'ui-slider-handle')][1]")
    right_slider = LocatorStrategy.locator_by_xpath(
        "//a[contains(@class,'ui-slider-handle')][2]")
    size_checkbox = LocatorStrategy.locator_by_id(
        "layered_id_attribute_group_3")

    def slider_range(self):
        self.click(Womentab.women_tab)
        self.time_sleep(config.sleep_time)
        self.click(Womentab.size_checkbox)
        self.time_sleep(config.sleep_time)
        self.drag_drop_offset(Womentab.left_slider, 50, 0)
        self.drag_drop_offset(Womentab.right_slider, -70, 0)
Exemplo n.º 5
0
class ExistingUser(Common):
    def __init__(self, driver):
        super().__init__(driver)
        self.driver = driver
        self.data = DataRead.json_read('data.json')

    login_button = LocatorStrategy.locator_by_class_name('login')
    email_field = LocatorStrategy.locator_by_id("email_create")
    submit_button = LocatorStrategy.locator_by_id("SubmitCreate")

    def login_click(self):
        self.click(ExistingUser.login_button)

    def enter_email(self):
        self.enter_text(ExistingUser.email_field,
                        text=self.data['existing_email'])
        self.click(ExistingUser.submit_button)
        self.log.info("Entered email is {}".format(
            self.data['existing_email']))
        self.time_sleep(config.sleep_time)
        self.get_screenshot(file_name="Existing_User")
Exemplo n.º 6
0
class Contact(Common):
    def __init__(self, driver):
        super().__init__(driver)
        self.driver = driver
        self.data = DataRead.json_read('data.json')

    contact_button = LocatorStrategy.locator_by_id("contact-link")
    text_message = LocatorStrategy.locator_by_id("message")
    subject_heading = LocatorStrategy.locator_by_id("id_contact")
    email_address = LocatorStrategy.locator_by_id("email")
    send_button = LocatorStrategy.locator_by_id("email")
    upload_file = LocatorStrategy.locator_by_id("fileUpload")

    def contact_us_form(self):
        self.click(Contact.contact_button)
        self.enter_text(Contact.text_message, text="This is a test.")
        select = self.select_option_from_drop_down(Contact.subject_heading)
        select.select_by_index(1)
        self.clear_text(Contact.email_address)
        self.enter_text(Contact.email_address, text=self.data['contact_email'])
        self.enter_text(Contact.upload_file,
                        text=config.file_path + self.data['upload_file'])
        self.click(Contact.send_button)
Exemplo n.º 7
0
class SearchItem(Common):

    def __init__(self, driver):
        super().__init__(driver)
        self.driver = driver
        # d = DataRead()
        self.data = DataRead.json_read('data.json')
        self.log = self.logger()

    search_field = LocatorStrategy.locator_by_id("search_query_top")
    search_button = LocatorStrategy.locator_by_xpath("//button[@name='submit_search']")
    product = LocatorStrategy.locator_by_xpath("//div[@class='product-container']/div[1]/div/a/img")
    add_to_cart = LocatorStrategy.locator_by_xpath(
        "//div[@class='product-container']/div[2]/div[2]/a[@title='Add to cart']")
    checkout_button = LocatorStrategy.locator_by_xpath("//*[@id='layer_cart']/div[1]/div[2]/div[4]/a")
    product_description = LocatorStrategy.locator_by_xpath("//*[@id='order-detail-content']/table/tbody/tr/td/p/a")
    shopping_cart_checkout_button = LocatorStrategy.locator_by_xpath("//*[@id='center_column']/p[2]/a[1]/span")
    address_page_checkout_button = LocatorStrategy.locator_by_xpath(
        "//*[@class='columns-container']/div/div[3]/div/form/p/button/span")
    shipping_page_terms = LocatorStrategy.locator_by_id("cgv")
    shipping_page_checkout_button = LocatorStrategy.locator_by_xpath(
        "//*[@class='columns-container']/div/div[3]/div/div/form/p/button/span")
    payment_page_button = LocatorStrategy.locator_by_xpath("//*[@class='bankwire']")
    confirm_button = LocatorStrategy.locator_by_css_selector("#cart_navigation > button")
    complete_status = LocatorStrategy.locator_by_xpath("//*[@class='box']/p")

    def item_search(self):
        self.enter_text(SearchItem.search_field, text=self.data['item'])
        self.click(SearchItem.search_button)

    def add_item(self):
        self.time_sleep(config.sleep_time)
        self.actions(move1=SearchItem.product, move2=SearchItem.add_to_cart)

    def proceed_to_checkout(self):
        self.time_sleep(config.sleep_time)
        self.click(SearchItem.checkout_button)

    def shopping_cart_checkout(self):
        self.time_sleep(config.sleep_time)
        self.click(SearchItem.shopping_cart_checkout_button)

    def address_page_checkout(self):
        self.time_sleep(config.sleep_time)
        self.click(SearchItem.address_page_checkout_button)

    def shipping_page_checkout(self):
        self.driver_wait(config.wait_time)
        self.click(SearchItem.shipping_page_terms)
        self.click(SearchItem.shipping_page_checkout_button)

    def confirm_order(self):
        self.driver_wait(config.wait_time)
        self.click(SearchItem.payment_page_button)
        self.click(SearchItem.confirm_button)

    def order_status(self):
        self.verify_text_present(SearchItem.complete_status, validatetext='complete')


    def verify_product_name(self):
        self.verify_exact_text(SearchItem.product_description, validatetext=self.data['dress_name'])
        self.log.info("The text is {}".format(SearchItem.product_description))
        self.verify_exact_text(SearchItem.product_description, validatetext=self.data['dress_name'])
Exemplo n.º 8
0
class CreateUser(Common):
    def __init__(self, driver):
        super().__init__(driver)
        self.driver = driver
        self.data = DataRead.json_read('data.json')
        self.log = self.logger()

    login_button = LocatorStrategy.locator_by_class_name('login')
    email_field = LocatorStrategy.locator_by_id("email_create")
    submit_button = LocatorStrategy.locator_by_id("SubmitCreate")
    gender = LocatorStrategy.locator_by_id("id_gender1")
    first_name = LocatorStrategy.locator_by_id("customer_firstname")
    last_name = LocatorStrategy.locator_by_name("customer_lastname")
    password_field = LocatorStrategy.locator_by_name("passwd")
    date_dob = LocatorStrategy.locator_by_id("days")
    month_dob = LocatorStrategy.locator_by_css_selector("#months")
    year_dob = LocatorStrategy.locator_by_css_selector("#years")
    address_firstname = LocatorStrategy.locator_by_id("firstname")
    address_lastname = LocatorStrategy.locator_by_id("lastname")
    address_number = LocatorStrategy.locator_by_css_selector("#address1")
    address_city = LocatorStrategy.locator_by_name("city")
    address_state = LocatorStrategy.locator_by_id("id_state")
    address_postcode = LocatorStrategy.locator_by_id("postcode")
    address_country = LocatorStrategy.locator_by_id("id_country")
    phone_num = LocatorStrategy.locator_by_name("phone_mobile")
    alias = LocatorStrategy.locator_by_id("alias")
    submit = LocatorStrategy.locator_by_id("submitAccount")

    def login_click(self):
        self.click(CreateUser.login_button)

    def enter_email(self):
        self.enter_text(CreateUser.email_field, text=self.data['new_email'])
        self.click(CreateUser.submit_button)
        self.log.info("Entered email is {}".format(self.data['new_email']))

    def fill_title_info(self, password):
        self.time_sleep(config.sleep_time)
        self.click(CreateUser.gender)
        self.enter_text(CreateUser.first_name, text=self.data['firstname'])
        self.enter_text(CreateUser.last_name, text=self.data['lastname'])
        self.enter_text(CreateUser.password_field, text=password)
        self.log.info("Entered First Name is {}".format(
            self.data['firstname']))
        self.log.info("Entered Last Name is {}".format(self.data['lastname']))

    def fill_date_of_birth(self):
        select = self.select_option_from_drop_down(CreateUser.date_dob)
        select.select_by_index(7)
        select = self.select_option_from_drop_down(CreateUser.month_dob)
        select.select_by_index(9)
        select = self.select_option_from_drop_down(CreateUser.year_dob)
        select.select_by_value('1988')
        self.log.info("Selected Birth date is {}".format(
            select.select_by_index(7)))
        self.log.info("Selected Birth Month is {}".format(
            select.select_by_index(9)))
        self.log.info("Selected Birth Year is {}".format(
            select.select_by_value('1988')))

    def fill_address_details(self):
        self.clear_text(CreateUser.address_firstname)
        self.enter_text(CreateUser.address_firstname,
                        text=self.data['firstname'])
        self.clear_text(CreateUser.address_lastname)
        self.enter_text(CreateUser.address_lastname,
                        text=self.data['lastname'])
        self.enter_text(CreateUser.address_number,
                        text=self.data['house_number'])
        self.enter_text(CreateUser.address_city, text=self.data['city'])
        select = self.select_option_from_drop_down(CreateUser.address_state)
        select.select_by_visible_text("Virginia")
        self.enter_text(CreateUser.address_postcode,
                        text=self.data['postcode'])
        select = self.select_option_from_drop_down(CreateUser.address_country)
        select.select_by_visible_text("United States")
        self.log.info("Entered City is {}".format(self.data['city']))
        self.log.info("Entered Postal Code is {}".format(
            self.data['postcode']))

    def misc_info(self):
        self.enter_text(CreateUser.phone_num, text=self.data['phone_number'])
        self.enter_text(CreateUser.alias, text=self.data['alias_text'])
        self.click(CreateUser.submit)
        self.log.info("Entered Phone Number is {}".format(
            self.data['phone_number']))
Exemplo n.º 9
0
class ItemDetails(Common):
    def __init__(self, driver):
        super().__init__(driver)
        self.driver = driver
        self.data = DataRead.json_read('data.json')

    search_field = LocatorStrategy.locator_by_id("search_query_top")
    search_button = LocatorStrategy.locator_by_xpath(
        "//button[@name='submit_search']")
    more_options = LocatorStrategy.locator_by_xpath(
        "//div[@class='product-container']/div[2]/div[2]/a[@title='View']")
    select_size = LocatorStrategy.locator_by_id("group_1")
    add_quantity_tab = LocatorStrategy.locator_by_xpath(
        "//*[@class='box-info-product']/div[2]/p/a[2]")
    quantity_field = LocatorStrategy.locator_by_id("quantity_wanted")
    null_quantity_text = LocatorStrategy.locator_by_xpath(
        "//*[@class='fancybox-outer']/div/p")
    null_quantity_cancel = LocatorStrategy.locator_by_xpath(
        "//*[@title='Close']")
    products = LocatorStrategy.locator_by_xpath(
        "//div[@class='product-container']/div[1]/div/a/img")
    prod_name = LocatorStrategy.locator_by_xpath(
        "//*[@id='center_column']/ul/li[3]/div/div[2]/h5/a")
    datasheet_properties = LocatorStrategy.locator_by_xpath(
        "//*[@class='page-product-box']/table/tbody/tr[3]/td[2]")
    dress_name = LocatorStrategy.locator_by_xpath(
        "//*[@id='center_column']/div/div/div[3]/h1")
    change_color = LocatorStrategy.locator_by_id("color_13")
    write_review = LocatorStrategy.locator_by_class_name("open-comment-form")
    review_title = LocatorStrategy.locator_by_id("comment_title")
    comment = LocatorStrategy.locator_by_id("content")
    send_button = LocatorStrategy.locator_by_id("submitNewMessage")
    comment_ok = LocatorStrategy.locator_by_xpath(
        "//*[@id='product']/div[2]/div/div/div/p[2]/button")
    add_tocart = LocatorStrategy.locator_by_name("Submit")
    proceed_to_checkout_button = LocatorStrategy.locator_by_xpath(
        "//*[@id='layer_cart']/div[1]/div[2]/div[4]/a")

    def item_search(self):
        self.enter_text(ItemDetails.search_field, text=self.data['item'])
        self.click(ItemDetails.search_button)

    def product_details(self):
        self.time_sleep(config.sleep_time)
        self.actions(move1=ItemDetails.products,
                     move2=ItemDetails.more_options)
        select = self.select_option_from_drop_down(ItemDetails.select_size)
        select.select_by_index(1)
        self.click(ItemDetails.change_color)
        self.verify_exact_text(ItemDetails.datasheet_properties,
                               validatetext=self.data['datasheet_properties'])
        self.verify_exact_text(ItemDetails.dress_name,
                               validatetext=self.data['dress_name'])

    def product_review_form(self):
        self.click(ItemDetails.write_review)
        self.enter_text(ItemDetails.review_title,
                        text=self.data['review_title'])
        self.enter_text(ItemDetails.comment, text=self.data['comment'])
        self.click(ItemDetails.send_button)
        self.time_sleep(config.sleep_time)
        self.click(ItemDetails.comment_ok)

    def add_item_to_cart(self):
        self.click(ItemDetails.add_tocart)
        self.time_sleep(config.sleep_time)
        self.click(ItemDetails.proceed_to_checkout_button)

    def add_quantity(self):
        self.time_sleep(config.sleep_time)
        self.click(ItemDetails.add_quantity_tab)

    def delete_quantity(self):
        self.clear_text(ItemDetails.quantity_field)
        self.enter_text(ItemDetails.quantity_field,
                        text=self.data['negative_quantity'])
        self.click(ItemDetails.add_tocart)
        self.time_sleep(config.sleep_time)
        self.get_text(ItemDetails.null_quantity_text)
        self.click(ItemDetails.null_quantity_cancel)