17 lines
507 B
Python
17 lines
507 B
Python
import random
|
|
from contextlib import _GeneratorContextManager
|
|
from seleniumbase import BaseCase, SB as _SB
|
|
|
|
|
|
def random_string(n: int, format = '[a-zA-Z0-9]') -> str:
|
|
format = format[1:-1]
|
|
chars = ''
|
|
for i in range(0, len(format), 3):
|
|
for j in range(ord(format[i]), ord(format[i+2]) + 1):
|
|
chars += chr(j)
|
|
return ''.join(random.choice(chars) for _ in range(n))
|
|
|
|
|
|
# make seleniumbase somewhat typed
|
|
def SB() -> _GeneratorContextManager[BaseCase]:
|
|
return _SB(uc = True)
|