Best Python code snippet using robotframework-pageobjects_python
monitor_tob_pc.py
Source: monitor_tob_pc.py
...11index_xhr = [12 {"name":"è·åç¨æ·ä¿¡æ¯","url":"https://bpm.yktour.com.cn/ykly-tob-web/getUserInfo"},13 {"name":"è·åç¨æ·èåå表","url":"https://bpm.yktour.com.cn/ykly-tob-web/b/login/getUserMenus"},14]15def get_default_arg():16 file_name = sys.argv[0].split(".")[0]17 return time.strftime("%Y-%m-%d %X", time.localtime())+" "+file_name + " " 18def user_login(data):19 data={'password': '1qaw3','username': 'anliming'}20 url = "https://bpm.yktour.com.cn/ykly-tob-web/b/login/formLogin"21 s_requests=requests.Session()22 html = s_requests.post(url=url,data=data) 23 return s_requests24def get_url(url):25 name = url["name"]26 url = url["url"]27 html = s_requests.get(url=url,timeout=10)28 if html.status_code == 200:29 if name == "è·åé¦é¡µå¾ç":30 if html.content:31 print get_default_arg()+name+" æ£æ¥æ£å¸¸"32 else:33 print get_default_arg()+name+" æ£æ¥å¤±è´¥ï¼è¯·åæ¶å¤ç"34 msg={'name':name+" æ£æ¥å¼å¸¸","errmsg":get_default_arg()+name+" å¼å¸¸"}35 result = send_mail.delay(msg)36 print result.status37 else:38 res = json.loads(html.content)39 if res:40 print get_default_arg()+name+" æ£æ¥æ£å¸¸"41 else: 42 print get_default_arg()+name+" æ£æ¥å¤±è´¥ï¼è¯·åæ¶å¤ç"43 msg={'name':name+" æ£æ¥å¼å¸¸","errmsg":get_default_arg()+name+" å¼å¸¸"}44 result = send_mail.delay(msg)45 print result.status46 else:47 html = s_requests.post(url)48 if html.status_code == 200:49 res = json.loads(html.content)50 if res:51 print get_default_arg() +name+" æ£æ¥æ£å¸¸"52 else: 53 print get_default_arg() +name+" æ£æ¥å¤±è´¥ï¼è¯·åæ¶å¤ç"54 msg={'name':name+" æ£æ¥å¼å¸¸","errmsg":get_default_arg()+name+" å¼å¸¸"}55 result = send_mail.delay(msg)56 print result.status57 58if __name__ == "__main__":59 s_requests=user_login(data)60 for url in index_xhr:61 try:62 get_url(url)63 except Exception as e:64 print e65 msg={'name':"è¦å!!!æ£æ¥TOB-PC"+" "+url["name"]+"失败","errmsg":get_default_arg()+"\n"+e.message}...
monitor_toc_app.py
Source: monitor_toc_app.py
...7index_xhr = [8 {"name":"é¦é¡µ","url":"http://m.yktour.com.cn/#/home"},9 {"name":"åºå¢æ¸¸","url":"http://m.yktour.com.cn/index/getCmsRecommendedProducts?sid=0&start_city_name=%E5%8C%97%E4%BA%AC&_json=true&_=1519267991592"},10 ]11def get_default_arg():12 return time.strftime("%Y-%m-%d %X", time.localtime())+" "+sys.argv[0] + " " 13def get_url(url):14 name = url["name"]15 url = url["url"]16 html = requests.get(url=url,timeout=10)17 if html.status_code == 200:18 if name == "é¦é¡µ":19 if html.content:20 print get_default_arg()+name+" æ£æ¥æ£å¸¸"21 else:22 print get_default_arg()+name+" æ£æ¥å¤±è´¥ï¼è¯·åæ¶å¤ç"23 msg={'name':name+" æ£æ¥å¼å¸¸","errmsg":get_default_arg()+name+" å¼å¸¸"}24 result = send_mail.delay(msg)25 print result.status26 else:27 res = json.loads(html.content)28 if res:29 print get_default_arg()+name+" æ£æ¥æ£å¸¸"30 else: 31 print get_default_arg()+name+" æ£æ¥å¤±è´¥ï¼è¯·åæ¶å¤ç"32 msg={'name':name+" æ£æ¥å¼å¸¸","errmsg":get_default_arg()+name+" å¼å¸¸"}33 result = send_mail.delay(msg)34 print result.status35 else:36 html = requests.post(url)37 if html.status_code == 200:38 res = json.loads(html.content)39 if res:40 print get_default_arg() +name+" æ£æ¥æ£å¸¸"41 else: 42 print get_default_arg() +name+" æ£æ¥å¤±è´¥ï¼è¯·åæ¶å¤ç"43 msg={'name':name+" æ£æ¥å¼å¸¸","errmsg":get_default_arg()+name+" å¼å¸¸"}44 result = send_mail.delay(msg)45 print result.status46 47if __name__ == "__main__":48 for url in index_xhr:49 try:50 get_url(url)51 except Exception as e:52 print e53 msg={'name':"è¦å!!!æ£æ¥ToC_app"+" "+url["name"]+"失败","errmsg":get_default_arg()+"\n"+e.message}...
input_args.py
Source: input_args.py
1from constants import method_constants2def get_default_arg(arg_input):3 default_input = '{}: '.format(arg_input)4 return input(default_input)5boolean_map = {6 'T': True,7 'F': False,8}9def get_boolean_arg(arg_input):10 boolean_input = '{} (T/F): '.format(arg_input)11 arg_string = input(boolean_input)12 while arg_string and arg_string not in boolean_map:13 arg_string = input(boolean_input)14 return arg_string15type_map = {16 str: get_default_arg,...
Check out the latest blogs from LambdaTest on this topic:
People love to watch, read and interact with quality content — especially video content. Whether it is sports, news, TV shows, or videos captured on smartphones, people crave digital content. The emergence of OTT platforms has already shaped the way people consume content. Viewers can now enjoy their favorite shows whenever they want rather than at pre-set times. Thus, the OTT platform’s concept of viewing anything, anytime, anywhere has hit the right chord.
Building a website is all about keeping the user experience in mind. Ultimately, it’s about providing visitors with a mind-blowing experience so they’ll keep coming back. One way to ensure visitors have a great time on your site is to add some eye-catching text or image animations.
Agile has unquestionable benefits. The mainstream method has assisted numerous businesses in increasing organizational flexibility as a result, developing better, more intuitive software. Distributed development is also an important strategy for software companies. It gives access to global talent, the use of offshore outsourcing to reduce operating costs, and round-the-clock development.
There are times when developers get stuck with a problem that has to do with version changes. Trying to run the code or test without upgrading the package can result in unexpected errors.
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!