-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsignup_for.py
More file actions
28 lines (24 loc) · 808 Bytes
/
signup_for.py
File metadata and controls
28 lines (24 loc) · 808 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import math
import random
from abc import ABC
from time import sleep
from selenium.webdriver.remote.webelement import WebElement
class SignUpFor(ABC):
@staticmethod
def _printing(field: WebElement, text: str):
field.click()
SignUpFor.imitation_of_human_delay(2, 4)
for char in text:
field.send_keys(char)
SignUpFor.imitation_of_human_delay()
SignUpFor.imitation_of_human_delay(2, 6)
@staticmethod
def wait(seconds: float):
print("Waiting for", f"{math.floor(seconds / 60.0)}m:{round(seconds % 60, 2)}s")
sleep(seconds)
@staticmethod
def imitation_of_human_delay(t1=0.1, t2=0.3):
if t1 > t2:
t1 = t2
delay = t1 + random.random() * (t2 - t1)
SignUpFor.wait(round(delay, 2))