Esempio n. 1
0
class SeleniumDriver():

    log = cl.customLogger(logging.DEBUG)

    def __init__(self, driver):
        self.driver = driver

    def get_Title(self):
        return self.driver.title

    def get_element(self, locator, locator_type=By.XPATH):
        element = None
        try:

            element = self.driver.find_element(locator_type, locator)
            self.log.info("Element Found with locator: " + locator +
                          " and  locatorType: " + locator_type)
        except:
            self.log.info("Element Not Found with locator: " + locator +
                          " and  locatorType: " + locator_type)
        return element

    def get_hackathon_phase(self, url):

        phase = 1
        idea_phase = self.driver.find_element(
            By.XPATH,
            ".//div[@class = 'idea-phase time-location-specification']")
        if idea_phase is None:
            print("Its single phase")
        else:
            phase = 2
            print("Its 2 Phase")
        return phase
class Register(SeleniumDriver):

    log = cl.customLogger(logging.DEBUG)

    _register_Cta = "//a[contains(text(),'REGISTER NOW')]"
    _addInfo_submit = ".//input[@class = 'button btn-green submit-btn inline-block weight-700']"
    _skill_skip = ".//div[@class = 'align-center caps margin-top-50']/a"
    _live_tag = ".//div[@class = 'event-title']/span"
    _update_cta = ".//a[contains(text(),'UPDATE PROJECT')]"
    _submit_project = ".//a[@href = '/sprints/test_hackathon_05-39/dashboard/02df538/submission/']"

    def register(self):
        time.sleep(3)
        hackathon_status = self.get_element(self._live_tag)

        if hackathon_status is None:
            print("Hackathon Over can't Register")
        else:
            regn_cta = self.get_element(self._register_Cta)
            if regn_cta is None:
                print("User Registered")

            else:
                print(regn_cta)
                regn_cta.click()
                time.sleep(3)
                self.add_info()

    def add_info(self):
        time.sleep(3)
        addInfo = self.get_element(self._addInfo_submit)
        addInfo.click()
        time.sleep(3)
        skill = self.get_element(self._skill_skip)
        skill.click()
Esempio n. 3
0
class HideAnimationPage:
    log = cl.customLogger(logging.DEBUG)
    def setup_animation_hide_show(self):
        self.Hide_show = UtilClass()
        self.Hide_show.set_up()
        self.Hide_show.click(readLocators.read_xpaths('animationPage','Animation'))
        self.Hide_show.wait()
        self.Hide_show.click(readLocators.read_xpaths('animationPage','HideShowAnimations'))

    def setup_animation_hide(self):
        self.Hide_show.wait()
        self.Hide_show.click(readLocators.read_xpaths('animationPage','btn0'))
        self.Hide_show.click(readLocators.read_xpaths('animationPage','btn1'))
        self.Hide_show.click(readLocators.read_xpaths('animationPage','btn2'))
        self.Hide_show.click(readLocators.read_xpaths('animationPage','btn3'))

    def setup_animation_show(self):
        self.Hide_show.click(readLocators.read_xpaths('animationPage','showBtn'))
        self.Hide_show.wait()

    def visible(self):
        btn0= self.Hide_show.visiblity(readLocators.read_xpaths('animationPage','btn0'))
        btn1= self.Hide_show.visiblity(readLocators.read_xpaths('animationPage','btn1'))
        btn2= self.Hide_show.visiblity(readLocators.read_xpaths('animationPage','btn2'))
        btn3= self.Hide_show.visiblity(readLocators.read_xpaths('animationPage','btn3'))
        return btn0,btn1,btn2,btn3
class Submisson(SeleniumDriver):

    log = cl.customLogger(logging.DEBUG)

    # Locators
    _submitProject_cta = ".//a[contains(text(),'SUBMIT PROJECT')]"
    _updateProject_cta = ".//a[contains(text(),'UPDATE PROJECT')]"
    _projectTitle = ".//input[@placeholder = 'Project title']"
    _theme = ".//*[@id='id_theme']"
    _projectDesc = ".//textarea[@placeholder='Project description']"
    _tags = ".//div[@class= 'react-tags__selected']"
    _submit_cta = ".//span[contains(text(),'Submit')]"
    _edit_pencil = ".//div[@class='float-right edit_button']/a/div"

    #_edit_pencil = ".//*[@id='sprint-root']/div/div/div/div/div[2]/div/div/div/div[1]/div[1]/div[2]/a/div"

    # Verify the state of phase and make submission

    def make_Submission(self, hackathon_status=1):
        if hackathon_status == 1:
            self.project_Submission_Status()
        else:
            ("Two phase hackathon")

    # Project submission form
    def project_Submission_Status(self):
        if self.get_element(self._submitProject_cta) is not None:
            print("Submitting....")
            self.get_element(self._submitProject_cta).click()
            self.submission_form()
        elif self.get_element(self._updateProject_cta) is not None:
            print("Updating Submission")
            self.get_element(self._updateProject_cta).click()
            time.sleep(5)
            self.get_element(self._edit_pencil).click()
            time.sleep(3)
            #Not able to click on edit
            #self.get_element(self._projectTitle).send_keys("My Test project Updated")

        else:
            print("Element Not found")

    def submission_form(self):
        self.get_element(
            self._projectTitle).send_keys("My Test project Updated")
        self.get_element(self._theme).send_keys("General")
        self.get_element(
            self._projectDesc).send_keys("It's a project about Innovation")
        self.get_element(self._submit_cta).click()

    '''# Idea submission Phase
class user_Jorney(SeleniumDriver):

    log = cl.customLogger(logging.DEBUG)

    def user_Register(self):
        regn = Register(self.driver)
        regn.register()

    def user_Submission(self, hackathon_status=1):
        sub = Submisson(self.driver)
        sub.make_Submission(hackathon_status=1)

    '''def submission(self):
        sub = Submisson(self.driver)'''
    '''
class login_page(SeleniumDriver):

    log = cl.customLogger(logging.DEBUG)

    #Locators
    _loginlink = ".//*[@id='header-primary']/div/ul/li[4]/a"
    _id = ".//*[@id='id_email']"
    _pwd = ".//*[@id='id_password']"
    _logincta = ".button.btn-large.btn-blue.full-width.medium-margin.weight-700.mp-login-cta"
    _usermenu = ".//*[@id='hacker-dd-icon']/a/div/i"
    _sprint_opt = "Sprint Dashboard"
    _dashboard_title = "Sprint Dashboard | HackerEarth"
    _login_page_title = "HackerEarth Recruit | Log In | HackerEarth"

    def click_LoginLink(self):
        self.get_element(self._loginlink).click()

    def verify_Login(self, id='', pwd=''):
        try:
            self.click_LoginLink()
            self.get_element(self._id).clear()
            self.get_element(self._id).send_keys(id)
            self.get_element(self._pwd).send_keys(pwd)
            self.get_element(self._logincta, By.CSS_SELECTOR).click()
            '''self.get_element(self._usermenu).click()
            self.get_element(self._sprint_opt,By.LINK_TEXT).click()
            print("done")'''

        except:
            self.log.info("Login failed")

    def verify_login_pass(self):
        #currenturl = self.driver.current_url
        current_title = self.get_Title()
        if current_title == self._dashboard_title:
            self.log.info("Login Successful")
        return True

    def verify_login_fail(self):
        #currenturl = self.driver.current_url
        current_title = self.get_Title()
        if current_title == self._login_page_title:
            self.log.info("Login Fail")
        return True
Esempio n. 7
0
class DisplayOptPage:
    log = cl.customLogger(logging.DEBUG)

    def setup_display_options(self):

        self.Display = UtilClass()
        self.Display.set_up()
        self.Display.click(
            readLocators.read_xpaths('displayOptionsPage', 'app'))
        self.Display.wait()
        self.Display.click(
            readLocators.read_xpaths('displayOptionsPage', 'actionBar'))
        self.Display.wait()
        self.Display.click(
            readLocators.read_xpaths('displayOptionsPage', 'displayOptions'))
        self.Display.wait()
        self.Display.click(
            readLocators.read_xpaths('displayOptionsPage', 'displayTitle'))
        self.Display.wait()

    def visible(self):
        title = self.Display.visiblity(
            readLocators.read_xpaths('displayOptionsPage', 'title'))
        return title
Esempio n. 8
0
from Pages.animationPage import HideAnimationPage
import pytest
import utility.custom_logger as cl
import logging

log = cl.customLogger(logging.DEBUG)


@pytest.mark.a
def test_animation_page_show_option():
    anim = HideAnimationPage()
    anim.setup_animation_hide_show()
    anim.setup_animation_hide()
    try:
        anim.visible() == (True, True, True, True)
    except:
        assert True  #buton0, button1, button2, button3 are hidden

    anim.setup_animation_show()
    assert anim.visible() == (True, True, True, True
                              )  ##buton0, button1, button2, button3 are shown
Esempio n. 9
0
class new_Hackathon(SeleniumDriver):

    log = cl.customLogger(logging.DEBUG)
    # Locators Details :
    _create_link = "+ Create Hackathon"
    #wiszard ele:
    _hackathonName = ".//*[@id='create-sprint-modal']/div[2]/form/div/input"
    _createCTA = ".//*[@id='create-sprint-modal']/div[3]/div[1]/a"
    #5 steps:
    _getStarted = "Get Started"
    #.//*[@id='create-sprint-wizard-modal']/div[2]/a     2. ".//*[@id='get-started']"
    _banner_save = ".//*[@id='save-cover']"
    _team_save = ".//*[@id='wizard-description-submit']"
    _date = ".//*[@id='id_end_date']"
    _time = ".//*[@id='id_end_time']"
    _setdate = "Oct 30, 2018"
    _settime = "02:30 PM"
    _dateTime_CTA = "#wizard-schedule-submit"
    #".//*[@id='wizard-schedule-submit']"
    _theme_Acct = ".//*[@id='create-sprint-wizard-modal']/div[1]/div[3]/div[2]/div[2]/div[2]"
    _theme_digital = ".//*[@id='create-sprint-wizard-modal']/div[1]/div[3]/div[2]/div[3]/div[2] "
    _theme_save = "Save & Continue"
    #".//a[@id='wizard-themes-submit']"
    _loc_save = "#wizard-location-submit"
    #"Check your Hackathon"
    _title = ".//*[@id='create-sprint-wizard-modal']/div[1]/div[1]"

    #locator details for edit:
    _edit = "//a[@class = 'button btn-blue btn-small']/i[@ class='fa fa-pencil']"
    _publish = "//a/i[@ class='fa fa-file-text']"
    _popPublish = ".//*[@class='modal-window small-modal simplemodal-data']/div[3]/a"

    #"Publish"
    #"//a[@clicked = 'Publishing...']"
    #".//*[@id='publish-sprint-modal']/div[3]/a"
    #"Publish"
    #"//*[@id='publish-sprint-modal']/div[3]/a"
    # "Publish"
    #".//a[@class = 'button btn-blue float-right']"

    #".//a[@id='wizard-location-submit']"
    #"#wizard-location-submit"
    #"Check your Hackathon"
    #".//*[@id='wizard-location-submit']"

    def create_Hackathon(self, name):

        self.get_element(self._create_link, By.LINK_TEXT).click()
        time.sleep(2)
        #self.driver.implicitly_wait(3)
        # Fill widzard value
        self.get_element(self._hackathonName).send_keys(name)
        time.sleep(2)
        self.get_element(self._createCTA).click()
        time.sleep(2)
        ele = self.get_element(self._getStarted, By.LINK_TEXT)
        time.sleep(2)
        ele.click()
        self.get_element(self._banner_save).click()
        time.sleep(2)
        self.get_element(self._team_save).click()
        time.sleep(2)
        self.get_element(self._date).send_keys(self._setdate)
        self.get_element(self._date).click()
        self.get_element(self._time).send_keys(self._settime)
        self.get_element(self._time).click()
        scd_ele = self.get_element(self._dateTime_CTA, By.CSS_SELECTOR)
        time.sleep(2)
        scd_ele.click()
        ele_theme = self.get_element(self._theme_save, By.LINK_TEXT)
        print(ele_theme)
        ele_theme.click()
        print("clicked on theme")
        time.sleep(3)
        ele_loc = self.get_element(self._loc_save, By.CSS_SELECTOR)
        print(ele_loc)
        ele_loc.click()

    def edit_Hackathon(self):
        self.get_element(self._edit).click()
        time.sleep(2)
        '''self.get_element(self._publish).click()
        time.sleep(2)
        pop = self.get_element(self._popPublish)

        print(pop)
        #pop.click()
        print("clicked on publish")'''

    '''def create_Hackthon(self):