示例#1
0
 def send_ticket_back(self) -> None:
     self.driver.find_element_by_id("hgbar_messages").click()
     try:
         notifications = self.driver.find_elements_by_xpath(
             "//div[@class='tab active']"
             "//div[@class='message daily_draw notification ballot']")
     except NoSuchElementException:
         logger.info(color_green("No raffle tickets to return"))
         return
     for n in notifications:
         self.driver.implicitly_wait(0.3)
         n.find_element_by_class_name("sendBallot").click()
         sleep(1)
         # Daily limit reached
         try:
             err_msg = n.find_element_by_class_name("error")
             if "You have already entered" in err_msg.text:
                 pass
             else:
                 logger.info(color_green("Daily limit reached"))
                 self.driver.implicitly_wait(5)
                 break
         except NoSuchElementException:
             pass
     logger.info(color_green("Finished resending raffle tickets"))
     self.driver.implicitly_wait(5)
     self.go_to_main_page()
示例#2
0
 def sound_horn(self) -> None:
     hunters_horn = self.driver.find_elements_by_class_name(
         "mousehuntHud-huntersHorn")[0]
     try:
         hunters_horn.click()
         self.go_to_main_page()
         self.horncount += 1
         logger.info(
             color_green(f"Horn is sounded, taking a break for 12 minutes"))
         sleep(1)
         if "Treasure Map Clue" in str(get_latest_journal_entry(self)):
             logger.info("has found a Treasure Map Clue")
             notify("has found a Treasure Map Clue")
         for _ in range(12):
             sleep(60)
             if int(datetime.now().strftime("%M")) == 45:
                 logger.debug(f"refreshing")
                 self.go_to_main_page()
                 sleep(2)
                 if "Treasure Map Clue" in str(
                         get_latest_journal_entry(self)):
                     logger.info("has found a Treasure Map Clue")
                     notify("has found a Treasure Map Clue")
                 break
     except ElementClickInterceptedException:
         self.refresh()
     except ElementNotInteractableException:
         self.refresh()
     except Exception as e:
         logger.exception(e)
         sys.exit(1)
示例#3
0
 def send_gift_to_recently_active(self) -> None:
     # click on friend
     self.driver.find_elements_by_class_name(
         "mousehuntHud-menu-item")[5].click()
     tickets = self.driver.find_elements_by_class_name("sendGift")
     for t in tickets:
         sleep(1)
         t.click()
     logger.info(
         color_green("Finished sending daily gifts to recently active"))
     self.go_to_main_page()
示例#4
0
 def delete_daily_ticket(self) -> None:
     """
     Delete ticket from notification
     """
     self.driver.find_element_by_id("hgbar_messages").click()
     notifications = self.driver.find_elements_by_xpath(
         "//div[@class='tab active']"
         "//div[@class='message daily_draw notification ballot']")
     for n in notifications:
         action_chains = ActionChains(self.driver)
         sleep(1)
         action_chains.move_to_element(n).context_click().perform()
         sleep(1)
         n.find_element_by_class_name("delete").click()
         sleep(1)
     logger.info(color_green("Finished cleaning up tickets notifications"))
     self.go_to_main_page()
示例#5
0
    def collect_dailies(self) -> None:
        sleep(1)
        # click on gift
        self.driver.find_element_by_id("hgbar_freegifts").click()
        sleep(1)

        # click on view more
        self.driver.find_element_by_class_name(
            "giftSelectorView-inbox-footer-viewMore").click()
        sleep(1)

        # click on send free gifts
        self.driver.find_elements_by_class_name(
            "giftSelectorView-tabHeader")[1].click()
        sleep(1)

        gift_of_the_day = (
            self.driver.find_elements_by_class_name("gift_of_the_day")[1].
            find_elements_by_class_name("giftSelectorView-gift-name")[0].text)
        logger.info(f"Gift of the day is {gift_of_the_day}.")

        self.go_to_main_page()
        sleep(1)
        self.driver.find_element_by_id("hgbar_freegifts").click()
        sleep(1)

        gifts = self.driver.find_elements_by_class_name(
            "giftSelectorView-inbox-giftRow")

        for g in gifts:
            if gift_of_the_day in g.text:
                g.find_element_by_class_name("claim").click()
                sleep(2)

        self.go_to_main_page()
        logger.info(color_green(f"Finished collecting {gift_of_the_day}"))
示例#6
0
    def send_free_gift(self) -> None:
        sleep(1)
        # click on gift
        self.driver.find_element_by_id("hgbar_freegifts").click()
        sleep(1)

        # click on view more
        self.driver.find_element_by_class_name(
            "giftSelectorView-inbox-footer-viewMore").click()
        sleep(1)

        # click on send free gifts
        self.driver.find_elements_by_class_name(
            "giftSelectorView-tabHeader")[1].click()
        sleep(1)

        # select gift of the day
        self.driver.find_elements_by_class_name("gift_of_the_day")[1].click()
        sleep(1)

        favorites = self.driver.find_elements_by_xpath(
            "//a[@class='giftSelectorView-friend favorite']")
        for f in favorites:
            sleep(0.250)
            f.click()
        try:
            send_gift_button = self.driver.find_element_by_xpath(
                "//div[@class='giftSelectorView-content-viewState selectFriends']"  # noqa: E501 pylint: disable=C0301
                "//a[@class='mousehuntActionButton giftSelectorView-action-confirm small']"  # noqa: E501 pylint: disable=C0301
            )
            send_gift_button.click()
        except NoSuchElementException:
            logger.info(color_red("Daily gifts was already send"))
            pass
        self.go_to_main_page()
        logger.info(color_green("Finished sending daily gifts"))