class AutoPinner(BasePage):
    def __init__(self, driver):
        super().__init__(self)
        self.driver = driver
        self.sl = SeleniumDriver(driver)

    #Locators
    _search_bar = "//input[@data-test-id='search-box-input']"
    _save_button = "//div[@data-test-id='SaveButton']"
    _board_selection = "//div[@data-test-id='board-selection'][1]"
    _already_posted_img = "//div[@data-test-id='already-pinned']"
    _close_image_button = "//button[@aria-label='Close']"
    counter = 0

    def inputSearch(self, search="Save the bees"):
        element = self.sl.getElement(self._search_bar, locatorType="xpath")
        element.send_keys(search)
        element.send_keys(Keys.ENTER)

    def clickImages(self):
        for i in range(1, 7):
            _images = "//*[@id='__PWS_ROOT__']/div[1]/div[3]/div/div/div/div[2]/div[1]/div/div/div/div[1]/div[" + str(
                i) + "]/div/div/div/div/div/div/div[1]/a"
            self.elementClick(_images, locatorType="xpath")
            time.sleep(2)
            self.clickSaveButton()
            time.sleep(1)

            alreadyHaveImage = self.elementPresenceCheck(
                self._already_posted_img, byType="xpath")

            if alreadyHaveImage is not True:
                self.boardSelection()
                time.sleep(2)
                self.inputSearch()
            else:
                self.elementClick(self._close_image_button,
                                  locatorType="xpath")
                self.inputSearch()

    def clickSaveButton(self):
        isSaveThere = self.elementPresenceCheck(self._save_button,
                                                byType="xpath")
        self.elementClick(self._save_button, locatorType="xpath")

    def boardSelection(self):
        self.elementClick(self._board_selection, locatorType="xpath")

    def PinningAutomation(self):
        self.inputSearch()
        time.sleep(2)
        self.clickImages()
        time.sleep(2)
Exemplo n.º 2
0
class Login(BasePage):

    log = cl.customLogger(logging.DEBUG)

    def __init__(self, driver):
        super().__init__(self)
        self.driver = driver
        self.sl = SeleniumDriver(driver)
        self.actions = ActionChains(driver)

    # Locators
    _login_option = "//a[contains(text(), 'Already a member? Log in')]"
    _email_field = "email"
    _password_field = "password"
    _login_button = "//div[contains(text(), 'Log in')]//parent::button"
    _fb_button = "//*[@id='u_0_1']/div"
    _fb_frame = "//iframe[@title='fb:login_button Facebook Social Plugin']"

    def clickAlreadyAMemeber(self):
        self.elementClick(self._login_option, locatorType="xpath")

    def enterEmailField(self, email="*****@*****.**"):
        self.sendKeys(email, self._email_field)

    def enterPasswordField(self, password="******"):
        self.sendKeys(password, self._password_field)

    def clickLoginButton(self):
        self.elementClick(self._login_button, locatorType="xpath")

    def switchFBFrame(self):
        fbFrame = self.sl.getElement(self._fb_frame, locatorType="xpath")
        self.driver.switch_to.frame(fbFrame)

    def clickFBButton(self):
        self.elementClick(self._fb_button, locatorType="xpath")

    def loginMethod(self):
        self.clickAlreadyAMemeber()
        time.sleep(2)
        self.enterEmailField()
        time.sleep(2)
        self.enterPasswordField()
        time.sleep(2)
        self.clickLoginButton()
        time.sleep(1)
Exemplo n.º 3
0
class AutoFollower(BasePage):
    def __init__(self, driver):
        super().__init__(self)
        self.driver = driver
        self.sl = SeleniumDriver(driver)

    #Locators
    _search_bar = "//input[@data-test-id='search-box-input']"
    _follow_button = "//button[@aria-label='Follow']"

    def inputSearch(self, search="Save the bees"):
        element = self.sl.getElement(self._search_bar, locatorType="xpath")
        element.send_keys(search)
        element.send_keys(Keys.ENTER)

    def followUser(self):
        for i in range(1, 50):
            _images = "//*[@id='__PWS_ROOT__']/div[1]/div[3]/div/div/div/div[2]/div[1]/div/div/div/div[1]/div[" + str(
                i) + "]/div/div/div/div/div/div/div[1]/a"

            self.elementClick(_images, locatorType="xpath")
            time.sleep(2)

            isUserFollowed = self.elementPresenceCheck(self._follow_button,
                                                       byType="xpath")

            if isUserFollowed:
                self.elementClick(self._follow_button, locatorType="xpath")
                self.inputSearch()
            else:
                self.inputSearch()

    def FollowingAutomation(self):
        self.inputSearch()
        time.sleep(1)
        self.followUser()
Exemplo n.º 4
0
class AutoCommenting(BasePage):
    def __init__(self, driver):
        super().__init__(self)
        self.driver = driver
        self.sl = SeleniumDriver(driver)

    #Locator
    _comment_tab_1 = "//a[@aria-selected='false']"
    _comment_tab_2 = "//button[@aria-label='Show more']"
    _comment_input = "//div[@role='textbox']"
    _comment_send_button = "//div[contains(text(), 'Done')]//parent::button"

    def inputSearch(self, search="Save the bees"):
        element = self.sl.getElement(self._search_bar, locatorType="xpath")
        element.send_keys(search)
        element.send_keys(Keys.ENTER)

    def pressCommentTab(self):
        commentTab1 = self.elementPresenceCheck(self._comment_tab_1,
                                                byType="xpath")
        commentTab2 = self.elementPresenceCheck(self._comment_tab_2,
                                                byType="xpath")

        if commentTab1:
            self.elementClick(self._comment_tab_1, locatorType="xpath")
        elif commentTab2:
            self.elementClick(self._comment_tab_2, locatorType="xpath")
        else:
            self.inputSearch()

    def inputComment(self, comment="Awesome picture! "):
        self.sendKeys(comment, self._comment_input, locatorType="xpath")

    def sendComment(self):
        self.elementClick(self._comment_send_button, locatorType="xpath")

    def imageCommenting(self, username="******"):
        for i in range(1, 11):
            _images = "//*[@id='__PWS_ROOT__']/div[1]/div[3]/div/div/div/div[2]/div[1]/div/div/div/div[1]/div[" + str(
                i) + "]/div/div/div/div/div/div/div[1]/a"

            self.elementClick(_images, locatorType="xpath")
            time.sleep(2)
            self.pressCommentTab()
            time.sleep(1)

            userMessage = "//img[@alt='" + str(username) + "']"
            didIMessage = self.elementPresenceCheck(username, byType="xpath")

            if didIMessage is not True:
                self.inputComment()
                time.sleep(1)
                self.sendComment()
                time.sleep(1)
                self.inputSearch()
                time.sleep(2)
            else:
                self.inputSearch()

    def CommentingAutomation(self):
        self.inputSearch()
        self.imageCommenting()