I wrote some codes and I want it to run 10 times. I tried to find ways to do it from the internet, but I couldn't figure it out how to apply them in my code.
from selenium import webdriver
import time
import random
import string
def random_string(length=32, uppercase=True, lowercase=True, numbers=True):
character_set = ''
if uppercase:
character_set += string.ascii_uppercase
if lowercase:
character_set += string.ascii_lowercase
if numbers:
character_set += string.digits
return ''.join(random.choice(character_set) for i in range(length))
my_random = random_string(length=13, uppercase=False) + '@gmail.com'
my_pw = random_string(length=30, uppercase=True, numbers=True)
with open('C:\\m2sifre\\demo2.txt', 'a') as fh:
fh.write(f'{my_random}\n {my_pw}\n')
browser = webdriver.Firefox()
browser.get("https://gameforge.com/tr-TR/sign-up")
# //*[@id="root"]/section/div/div/div/div/div/form/fieldset/footer/div[2]/button/span/p
time.sleep (2)
username = browser.find_element_by_name("username")
password = browser.find_element_by_name("password")
username.send_keys(my_random)
password.send_keys(my_pw)
kayit_ol = browser.find_element_by_xpath("//*[@id='root']/section/div/div/div/div/div/form/fieldset/footer/div[2]/button/span/p")
kayit_ol.click()
time.sleep (2)
browser.close()