def execute(self): # asLogin = self.aslogin # asPassword = self.aspwd self.links = self.make_json_list('json_lists/write-msg/links.json') if not testcase.TestObject.execute(self): self.log.write('error', 'login failed') return False msg = myrandom.random_phrase() if not self.send_msg_by_title(u'™', msg): self.log.write('error', 'error sending msg, see above') return False self.login, self.password, self.aslogin, self.aspwd = self.aslogin, self.aspwd, self.login, self.password if not self.logout(): self.log.write('error', 'error logging out') return False if not self.do_login(): self.log.write('error', 'error logging in as %s' % self.aslogin) return False if not self.check_appeared_msg(msg): self.log.write('error', 'msg not received, see above') return False self.log.write('info', '%s PASSED' % sys.argv[0]) return True
def execute(self): title_fragment = u'™' # asLogin = '******' # asPassword = '******' asLogin = self.aslogin asPassword = self.aspwd message = myrandom.random_phrase() if not testcase.TestObject.execute(self): self.log.write('error', 'login failed') return False try: self.info['brandName'] = self.json_info()['common_data']['brandName'][:18] except KeyError: self.log.write('error', 'error getting brandName') return False if not self.request_recommendation_by_title(u'™', msg=message): self.log.write('error', 'error requesting recommendation') return False self.log.write('info', 'requested recommendation successfully') self.sleep(2) if not self.logout(): self.log.write('error', 'error logging out') return False self.login,self.password,asLogin,asPassword = asLogin,asPassword,self.login,self.password if not self.do_login(): self.log.write('error', 'error logging in as %s' % self.login) return False if not self.confirm_recommendation(msg=message): self.log.write('error', 'error confirming as %s' % self.login) return False self.log.write('info', 'confirmed recommendation successfully') self.go(self.url) if not self.check_recommended_by_title(title_fragment, self.info['brandName']): self.log.write('error', 'not recommended') return False self.log.write('info', 'checked: recommended') if not self.undo_recommend(self.info['brandName']): self.log.write('error', 'error unrecommending finally') return False self.log.write('info', 'cleanup after work done') self.log.write('info', '%s PASSED' % sys.argv[0]) return True
def execute(self): if not testcase.TestObject.execute(self): self.log.write('error', 'login failed') return False comment_text = myrandom.random_phrase() commented = False for elem_id in range(1, 30): if not self.click_btn_in_xpath('//ul/li[%d]/table' % elem_id, u'Комментировать'): self.log.write('warning', 'no comment link @ post # %d' % elem_id) else: self.log.write('info', 'found a post to comment #%d' % elem_id) self.sleep(2) if not self.edit_control('//ul/li[%d]/table/tbody/tr/td[2]/div/div/textarea' % elem_id, comment_text, by='xpath'): self.log.write('error', 'error adding comment') return False if not self.click_btn(u'Отправить'): self.log.write('error', 'error submitting comment') return False commented = True break if not commented: self.log.write('error', 'failed to find a comment link') return False self.log.write('info', 'wrote a comment, finding it in news') self.go(self.driver.current_url) if not self.check_div_value('news-view', comment_text): self.log.write('error', 'no comment in news') return False self.log.write('info', 'found comment in news!') if not self.visit_link('//ul/li[%d]/table/tbody/tr/td[2]/div/div/div/h3/a' % elem_id, 'news', by='xpath', sleep=True): self.log.write('error', 'error visiting OP\'s news') return False if not self.check_div_value('news', comment_text): self.log.write('error', 'no comment in their news') return False self.log.write('info', 'found comment in their news') self.log.write('info', '%s PASSED' % sys.argv[0]) return True
def send_msg_by_title(self, title_fragment, msg=myrandom.random_phrase()): ''' Sends msg to company found by title_fragment ''' if not self.find_stuff(title_fragment): self.log.write('error', 'search error') return False for link in self.links: if link['link'] == '%%title_fragment%%': link_ = re.sub('%%title_fragment%%', title_fragment, link['link']) else: link_ = link['link'] if not self.visit_link(link_, link['url'], link['by'], sleep=True): self.log.write('error', 'error visiting %s, see above' % link['url']) return False if not self.edit_control('chat_message_ta', msg, ctl_type='text', by='id'): self.log.write('error', 'error editing message textarea') return False self.log.write('debug', 'entered msg successfully') self.log.write('debug', 'msg is: %s' % msg) if not self.click_btn('send_message_btn', by='id'): self.log.write('error', 'error submitting msg') return False self.log.write('debug', 'submitted entered msg successfully') self.sleep(2) if not self.check_div_value('//ul[@class="messages"]', msg, by='xpath'): self.log.write('error', 'no msg appeared: NOK') return False self.log.write('info', 'sent msg successfully') return True
def execute(self): if not testcase.TestObject.execute(self): self.log.write('error', 'login failed') return False news_text = myrandom.random_phrase() if not self.edit_control('add_event', news_text, clear=True, click=True): self.log.write('error', 'unable to add news: no edit or error editing') return False self.sleep(2) if not self.click_btn(u'Опубликовать'): self.log.write('error', 'no submit btn or error submitting') return False self.log.write('info', 'wrote %s into news' % news_text) self.sleep(2) if not self.check_div_value('news-view', news_text): self.log.write('error', 'no post in news') return False self.log.write('info', 'appeared in news...') if not self.visit_link('mc_sidebar_news', 'news', sleep=True): self.log.write('error', 'error visiting news') return False if not self.check_div_value('news-view', news_text): self.log.write('error', 'no post in self-news') return False self.log.write('info', 'appeared in self-news!') self.log.write('info', '%s PASSED' % sys.argv[0]) return True