Best Python code snippet using SeleniumBase
test_auth.py
Source:test_auth.py
...88 user = self.session.query(User).filter_by(username='foo').first()89 self.testapp.post('/auth/ga', status=302, params={90 'submit': 'Authenticate',91 'username': 'foo',92 'code': get_google_auth_code(user.secret)93 })94 self.testapp.get('/')95 def test_submit_success_with_code_check_headers(self):96 from factored.utils import get_google_auth_code97 from factored.models import User98 user = self.session.query(User).filter_by(username='foo').first()99 resp = self.testapp.post('/auth/ga', status=302, params={100 'submit': 'Authenticate',101 'username': 'foo',102 'code': get_google_auth_code(user.secret)103 })104 assert 'pnutbtr=' in resp.headers['Set-Cookie']105class TestEmailAuth(BaseTest):106 def setUp(self):107 super(TestEmailAuth, self).setUp()108 from factored.models import User109 self.user = User(110 username='foo@bar.com', secret=generate_random_google_code())111 self.session.add(self.user)112 self.session.commit()113 def test_email_blank_form(self):114 resp = self.testapp.get('/auth/em', status=200)115 resp.mustcontain('name="username')116 def test_not_send_mail_without_username(self):...
hpool_xch_withdraw.py
Source:hpool_xch_withdraw.py
...97 t2=int(time.time() * 1000)98 res = requests.get(url=f'https://www.hpool.in/api/security/requestsession?_t={t2}', headers=header)99 session = json.loads(res.text).get('data')100 return session101def get_google_auth_code(path):102 '''103 使ç¨`oathtool`çæè°·æéªè¯ç ,èæ¬éè¦ææ§è¡æé,104 èæ¬å
容:`oathtool -b --totp 'key'`.105 éæä½³æ¹æ¡ï¼æ³¨æä¿æ¤å¥½`key`è°¨é²æ³å¯ï¼é æ财产æ失.106 '''107 code = subprocess.getoutput(path)108 # return int(code)109 print(code)110 return code111def xch_withdraw(url, session, code, amount, address, **kwargs):112 '''113 session:请æ±sessionæ¥å£çè¿å,114 code:è°·æéªè¯ç ,115 aomount:å©ä½å
¨é¨xch,116 address:æç°é±å
å°å117 118 æç°å°æå®é±å
å°åpayloadï¼119 '{"session":"","code":"","type":"chia","address":"","amount":""}'120 '''121 type = 'chia'122 payload = {123 "session": f"{session}",124 "code": f"{code}",125 "type": "chia",126 "address": f"{address}",127 "amount": f"{amount}"128 }129 payload = json.dumps(payload)130 # print(payload)131 res = requests.post(url=url, headers=header, data=payload)132 result_code = json.loads(res.text).get('code')133 print(res.text)134 if result_code == 200:135 msg=f'æç°æå,æ¬æ¬¡æç°éé¢ä¸º:{amount}xch,请注ææ¥æ¶.'136 logger.info(f'{msg}')137 send_tg_msg(text=msg)138 return result_code139 else:140 msg='æç°å¤±è´¥,æªç¥é误.'141 logger.error(f"{msg}")142 send_tg_msg(text=msg)143 return None144if __name__ == "__main__":145 # parser = argm(prog='hpool_xch_withdraw',description="hpool xch withdraw helper")146 # parser.add_argument("-K", "--code", dest='code', type=int,help="Google Authenticator Code.")147 # parser.add_argument("-P","--percent", dest='withdraw_percent', default=1,help="Withdraw ratio.")148 # parser.add_argument("-M","--tg",help="Send telegram message.")149 # args = parser.parse_args()150 # code = args.code151 # withdraw_percent = args.withdraw_percent152 # if len(str(code)) == 6:153 # remain_xch=get_total_assets('https://www.hpool.in/api/assets/totalassets')154 # #sign_url=f'https://www.hpool.in/api/assets/totalassets'155 # # print(sign_url)156 # t = int(time.time() * 1000)157 # session=get_token(f'https://www.hpool.in/api/security/requestsession?_t={t}')158 # ## é²æ¢è¢«å«æï¼å¼ºå¶åæ»æç°address.ä¹å¯ä»¥éè¿æ¥å£è·å159 # xch_withdraw(session=session,code=code,amount=remain_xch,address='')160 # else:161 # parser.print_help()162 remain_xch = get_total_assets(163 'https://www.hpool.in/api/assets/totalassets')164 # t = int(time.time() * 1000)165 session = get_token()166 code = get_google_auth_code('/home/chaos/lab/scripts/totp.sh')167 withdraw_url = 'https://www.hpool.in/api/assets/withdraw'168 ## é²æ¢è¢«å«æï¼å¼ºå¶åæ»æç°address.ä¹å¯ä»¥éè¿æ¥å£è·å169 pay_address = ''170 xch_withdraw(url=withdraw_url,171 session=session,172 code=code,173 amount=remain_xch,...
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!!