# Path: page_objects/zero_mobile_page.py
# class Zero_Mobile_Page(Mobile_Base_Page):
#     "Page Object for the dummy page"
# 
#     def start(self):
#         "Use this method to go to specific URL -- if needed"
#         pass
# 
# Path: page_objects/zero_page.py
# class Zero_Page(Base_Page):
#     "Page Object for the dummy page"
# 
#     def start(self):
#         "Use this method to go to specific URL -- if needed"
#         pass
# 
# Path: page_objects/tutorial_main_page.py
# class Tutorial_Main_Page(Base_Page,Form_Object,Header_Object,Table_Object,Footer_Object):
#     "Page Object for the tutorial's main page"
# 
#     def start(self):
#         "Use this method to go to specific URL -- if needed"
#         url = 'selenium-tutorial-main'
#         self.open(url)
# 
# Path: page_objects/tutorial_redirect_page.py
# class Tutorial_Redirect_Page(Base_Page,Header_Object,Footer_Object):
#     "Page Object for the tutorial's redirect page"
# 
#     #locators
#     heading = locators.heading
# 
#     def start(self):
#         "Use this method to go to specific URL -- if needed"
#         url = 'selenium-tutorial-redirect'
#         self.open(url)
# 
#     @Wrapit._exceptionHandler
#     def check_heading(self):
#         "Check if the heading exists"
#         result_flag = self.check_element_present(self.heading)
#         self.conditional_write(result_flag,
#             positive='Correct heading present on redirect page',
#             negative='Heading on redirect page is INCORRECT!!',
#             level='debug')
# 
#         return result_flag
# 
# Path: page_objects/contact_page.py
# class Contact_Page(Base_Page,Contact_Form_Object,Header_Object,Footer_Object):
#     "Page Object for the contact page"
# 
#     def start(self):
#         "Use this method to go to specific URL -- if needed"
#         url = 'contact'
#         self.open(url)
# 
# Path: page_objects/bitcoin_price_page.py
# class Bitcoin_Price_Page(Mobile_Base_Page):
#     "Page object for real time prices of bitcoin page."
# 
#     # Locators of the bitcoin real time price page elements.
#     bitcoin_price_in_usd = locators.bitcoin_price_in_usd
# 
# 
#     @Wrapit._screenshot
#     def get_bitcoin_real_time_price(self):
#         "This method is to get the real time price of the bitcoin."
#         # Final result flag is to return False if expected price and real time price is different.
#         try:
#             # Get real time price of the bitcoin in usd.
#             result_flag = None
#             bitcoin_price_in_usd = self.get_text_by_locator(self.bitcoin_price_in_usd)
#             if bitcoin_price_in_usd is not None:
#                 result_flag = True
#             else:
#                 result_flag = False
# 
#             self.conditional_write(result_flag,
#                 positive='Get the bitcoin real time price in usd.',
#                 negative='Failed to get the bitcoin real time price in usd.',
#                 level='debug')
# 
#         except Exception as e:
#             self.write("Exception while getting real time price of the bitcoin.")
#             self.write(str(e))
# 
#         return result_flag
# 
# Path: page_objects/bitcoin_main_page.py
# class Bitcoin_Main_Page(Mobile_Base_Page):
#     "Page object bitcoin main page."
# 
#     #Locators of the mobile page elements.
#     bitcoin_real_time_price_button = locators.bitcoin_real_time_price_button
#     bitcoin_price_page_heading = locators.bitcoin_price_page_heading
# 
# 
#     @Wrapit._screenshot
#     def click_on_price_button(self):
#         "This method is to click on real time price page button."
#         try:
#             # Click on real time price page button.
#             result_flag = None
#             if self.click_element(self.bitcoin_real_time_price_button):
#                 result_flag = True
#             else:
#                 result_flag = False
# 
#             self.conditional_write(result_flag,
#                 positive='Click on the bitcoin real time price page button.',
#                 negative='Failed to click on the bitcoin real time price page button.',
#                 level='debug')
# 
#         except Exception as e:
#             self.write("Exception while clicking on the bitcoin real time price button.")
#             self.write(str(e))
# 
#         return result_flag
# 
# 
#     @Wrapit._screenshot
#     def check_redirect(self, expected_bitcoin_price_page_heading):
#         "This method is to check if we have been redirected to the bitcoin real time price page."
#         result_flag = False
#         bitcoin_price_page_heading = self.get_text_by_locator(self.bitcoin_price_page_heading)
#         if bitcoin_price_page_heading.decode('utf-8') == expected_bitcoin_price_page_heading:
#             result_flag = True
#             self.switch_page("bitcoin price page")
# 
#         return result_flag
# 
# 
#     @Wrapit._screenshot
#     def click_on_real_time_price_button(self, expected_bitcoin_price_page_heading):
#         "This method is to visit bitcoin real time price page and verify page heading."
#         result_flag = self.click_on_price_button()
#         result_flag &= self.check_redirect(expected_bitcoin_price_page_heading)
# 
#         return result_flag


from page_objects.zero_mobile_page import Zero_Mobile_Page
from page_objects.zero_page import Zero_Page
from page_objects.tutorial_main_page import Tutorial_Main_Page
from page_objects.tutorial_redirect_page import Tutorial_Redirect_Page
from page_objects.contact_page import Contact_Page
from page_objects.bitcoin_price_page import Bitcoin_Price_Page
from page_objects.bitcoin_main_page import Bitcoin_Main_Page
import conf.base_url_conf
"""
PageFactory uses the factory design pattern.
get_page_object() returns the appropriate page object.
Add elif clauses as and when you implement new pages.
Pages implemented so far:
1. Tutorial main page
2. Tutorial redirect page
3. Contact Page
4. Bitcoin main page
5. Bitcoin price page
"""



class PageFactory():
    "PageFactory uses the factory design pattern."
    def get_page_object(page_name,base_url=conf.base_url_conf.base_url):
        "Return the appropriate page object based on page_name"
        test_obj = None
        page_name = page_name.lower()
        if page_name in ["zero","zero page","agent zero"]:
            test_obj = Zero_Page(base_url=base_url)
        elif page_name in ["zero mobile","zero mobile page"]:
            test_obj = Zero_Mobile_Page()
        elif page_name == "main page":

# Path: page_objects/zero_mobile_page.py
# class Zero_Mobile_Page(Mobile_Base_Page):
#     "Page Object for the dummy page"
# 
#     def start(self):
#         "Use this method to go to specific URL -- if needed"
#         pass
# 
# Path: page_objects/zero_page.py
# class Zero_Page(Base_Page):
#     "Page Object for the dummy page"
# 
#     def start(self):
#         "Use this method to go to specific URL -- if needed"
#         pass
# 
# Path: page_objects/tutorial_main_page.py
# class Tutorial_Main_Page(Base_Page,Form_Object,Header_Object,Table_Object,Footer_Object):
#     "Page Object for the tutorial's main page"
# 
#     def start(self):
#         "Use this method to go to specific URL -- if needed"
#         url = 'selenium-tutorial-main'
#         self.open(url)
# 
# Path: page_objects/tutorial_redirect_page.py
# class Tutorial_Redirect_Page(Base_Page,Header_Object,Footer_Object):
#     "Page Object for the tutorial's redirect page"
# 
#     #locators
#     heading = locators.heading
# 
#     def start(self):
#         "Use this method to go to specific URL -- if needed"
#         url = 'selenium-tutorial-redirect'
#         self.open(url)
# 
#     @Wrapit._exceptionHandler
#     def check_heading(self):
#         "Check if the heading exists"
#         result_flag = self.check_element_present(self.heading)
#         self.conditional_write(result_flag,
#             positive='Correct heading present on redirect page',
#             negative='Heading on redirect page is INCORRECT!!',
#             level='debug')
# 
#         return result_flag
# 
# Path: page_objects/contact_page.py
# class Contact_Page(Base_Page,Contact_Form_Object,Header_Object,Footer_Object):
#     "Page Object for the contact page"
# 
#     def start(self):
#         "Use this method to go to specific URL -- if needed"
#         url = 'contact'
#         self.open(url)
# 
# Path: page_objects/bitcoin_price_page.py
# class Bitcoin_Price_Page(Mobile_Base_Page):
#     "Page object for real time prices of bitcoin page."
# 
#     # Locators of the bitcoin real time price page elements.
#     bitcoin_price_in_usd = locators.bitcoin_price_in_usd
# 
# 
#     @Wrapit._screenshot
#     def get_bitcoin_real_time_price(self):
#         "This method is to get the real time price of the bitcoin."
#         # Final result flag is to return False if expected price and real time price is different.
#         try:
#             # Get real time price of the bitcoin in usd.
#             result_flag = None
#             bitcoin_price_in_usd = self.get_text_by_locator(self.bitcoin_price_in_usd)
#             if bitcoin_price_in_usd is not None:
#                 result_flag = True
#             else:
#                 result_flag = False
# 
#             self.conditional_write(result_flag,
#                 positive='Get the bitcoin real time price in usd.',
#                 negative='Failed to get the bitcoin real time price in usd.',
#                 level='debug')
# 
#         except Exception as e:
#             self.write("Exception while getting real time price of the bitcoin.")
#             self.write(str(e))
# 
#         return result_flag
# 
# Path: page_objects/bitcoin_main_page.py
# class Bitcoin_Main_Page(Mobile_Base_Page):
#     "Page object bitcoin main page."
# 
#     #Locators of the mobile page elements.
#     bitcoin_real_time_price_button = locators.bitcoin_real_time_price_button
#     bitcoin_price_page_heading = locators.bitcoin_price_page_heading
# 
# 
#     @Wrapit._screenshot
#     def click_on_price_button(self):
#         "This method is to click on real time price page button."
#         try:
#             # Click on real time price page button.
#             result_flag = None
#             if self.click_element(self.bitcoin_real_time_price_button):
#                 result_flag = True
#             else:
#                 result_flag = False
# 
#             self.conditional_write(result_flag,
#                 positive='Click on the bitcoin real time price page button.',
#                 negative='Failed to click on the bitcoin real time price page button.',
#                 level='debug')
# 
#         except Exception as e:
#             self.write("Exception while clicking on the bitcoin real time price button.")
#             self.write(str(e))
# 
#         return result_flag
# 
# 
#     @Wrapit._screenshot
#     def check_redirect(self, expected_bitcoin_price_page_heading):
#         "This method is to check if we have been redirected to the bitcoin real time price page."
#         result_flag = False
#         bitcoin_price_page_heading = self.get_text_by_locator(self.bitcoin_price_page_heading)
#         if bitcoin_price_page_heading.decode('utf-8') == expected_bitcoin_price_page_heading:
#             result_flag = True
#             self.switch_page("bitcoin price page")
# 
#         return result_flag
# 
# 
#     @Wrapit._screenshot
#     def click_on_real_time_price_button(self, expected_bitcoin_price_page_heading):
#         "This method is to visit bitcoin real time price page and verify page heading."
#         result_flag = self.click_on_price_button()
#         result_flag &= self.check_redirect(expected_bitcoin_price_page_heading)
# 
#         return result_flag


# Path: page_objects/PageFactory.py
from page_objects.zero_mobile_page import Zero_Mobile_Page
from page_objects.zero_page import Zero_Page
from page_objects.tutorial_main_page import Tutorial_Main_Page
from page_objects.tutorial_redirect_page import Tutorial_Redirect_Page
from page_objects.contact_page import Contact_Page
from page_objects.bitcoin_price_page import Bitcoin_Price_Page
from page_objects.bitcoin_main_page import Bitcoin_Main_Page
import conf.base_url_conf

"""
PageFactory uses the factory design pattern.
get_page_object() returns the appropriate page object.
Add elif clauses as and when you implement new pages.
Pages implemented so far:
1. Tutorial main page
2. Tutorial redirect page
3. Contact Page
4. Bitcoin main page
5. Bitcoin price page
"""



class PageFactory():
    "PageFactory uses the factory design pattern."
    def get_page_object(page_name,base_url=conf.base_url_conf.base_url):
        "Return the appropriate page object based on page_name"
        test_obj = None
        page_name = page_name.lower()
        if page_name in ["zero","zero page","agent zero"]:
            test_obj = Zero_Page(base_url=base_url)
        elif page_name in ["zero mobile","zero mobile page"]:
            test_obj = Zero_Mobile_Page()
        elif page_name == "main page":

            test_obj = Tutorial_Main_Page(base_url=base_url)