def mark_major_marks_standart_comment(self,marks): comments = Comments(self.browser, self.logger) buttons = Buttons(self.browser, self.logger) for mark in marks: photo_href1 = self.get_photo2mark_href() self.click(mark) compliments = self.get_random_compliments() self.logger.log("Amount of compliments avaliable = " + str(len(compliments))) compliments_error_threshold = math.ceil(len(compliments)/2) self.logger.log("Compliments change error threshold = " + str(compliments_error_threshold)) error_count = 0 for compliment in compliments: self.click(compliment) sleep(3) try: comments.validate_high_mark_comment_value(compliment.text) except Exception: error_count += 1 if error_count >= compliments_error_threshold: raise TestFailedException("Faield standart comment sending functionality. " +\ "Error count during sending comments = " + str(error_count)) buttons.send_comment("topmark") photo_href2 = self.get_photo2mark_href() try: self.click( self.get_element_by_xpath(self._fb_popup_close_link_xpath)) except Exception: self.logger.log("Fb Popup was not found") try: print photo_href1 print photo_href2 assert photo_href1 != photo_href2 except AssertionError: raise TestFailedException("User photo hasn't changed")
def mark_major_marks_custom_comment(self,marks): error_count = 0 comments = Comments(self.browser, self.logger) alerts = AlertPopups(self.browser, self.logger) for mark in marks: if error_count < self.custom_top_mark_message_treshold: photo_href1 = self.get_photo2mark_href() self.click(mark) top_mark_comment = comments.get_high_mark() comments.is_initial_top_mark_comment(top_mark_comment) if top_mark_comment.get_attribute("style") != "": error_count += 1 comments.click(top_mark_comment) # reload comment element from web interface top_mark_comment = comments.get_high_mark() print top_mark_comment.get_attribute("style") if top_mark_comment.get_attribute("style").count(comments.get_top_mark_comment_height()) <= 0: error_count += 1 # validate that comment textarea still contains initial text # BUG NEXT LINE # comments.is_initial_top_mark_comment(top_mark_comment) # send single key comments.send_comment(top_mark_comment, u'1', "topmark") alerts.too_short_comment_close() comments.click(top_mark_comment) comments.send_comment(top_mark_comment, u"Привет", "topmark") photo_href2 = self.get_photo2mark_href() try: assert photo_href1 != photo_href2 except AssertionError: raise TestFailedException("User haven't been changed after marking") try: self.click( self.get_element_by_xpath(self._fb_popup_close_link_xpath)) except Exception: self.logger.log("Fb Popup was not found") else: raise TestFailedException("User standart message failure. Error count >= " + str(self.custom_top_mark_message_treshold))