This portion of my code submits a request for sms verification. I want it to restart a portion of the script if the sms verification code is not received within 90 seconds, so it will restart that step and try for a new number.
EC.presence_of_element_located((By.XPATH, "//*[@id='mobile-container']/div/div/form/div[2]/div[4]/div/div/div/div[2]/button")))
time.sleep(0.5)
addPn.click()
time.sleep(1)
numberBox = driver.find_element(By.XPATH, "//*[@type='tel']")
global nId
global num
noNum = True
while noNum:
r = requests.get("https://sms-activate.ru/stubs/handler_api.php?api_key=00000000000000000&action=getNumber&service=ew&country=0")
if "ACCESS_NUMBER" in r.text:
info = r.text.split(":")
nId = str(info[1])
num = str(info[2])
noNum = False
c = driver.find_element(By.XPATH, "//*[@class='country']")
c.click()
z = driver.find_element(By.XPATH, "//*[@class='country']/option[38]")
z.click()
time.sleep(0.5)
numberBox.click()
for character in num[1:]:
numberBox.send_keys(character)
time.sleep(0.2)
sendCode = driver.find_element(By.XPATH, "//*[@class='sendCodeButton']")
sendCode.click()
requests.get(f"https://sms-activate.ru/stubs/handler_api.php?api_key=00000000000000000&action=setStatus&status=1&id={nId}")
code = ""
noCode = True
while noCode:
r = requests.get(f"https://sms-activate.ru/stubs/handler_api.php?api_key=00000000000000000&action=getStatus&id={nId}")
if "STATUS_OK" in r.text:
code = r.text.split(":")[1]
noCode = False
codeBox = driver.find_element(By.XPATH, "//*[@type='number']")
for character in code:
codeBox.send_keys(character)
time.sleep(0.5)
check = driver.find_element(By.XPATH, "//*[@class='checkbox']")
check.click()
time.sleep(0.4)
cont = driver.find_element(By.XPATH, "//*[@value='CONTINUE']")
cont.click()