This is my battle script.py i wanted to go to the page captcha.py if captcha occurr so what code i can /should add in the script below as this page keep loading if captcha occurs.
def TC_battle(browser):
while True:
try:
time.sleep(2)
browser.find_element_by_class_name("submit").click()
except:
time.sleep(2)
browser.find_element_by_xpath("//a[contains(.,'Restart Battle')]").click()
all the above code is essential for battle script.
the 2nd one is my main.py script
while True:
try:
time.sleep(2)
Captcha(browser, url)
except:
TC_battle(browser)
this one is my captcha.py script
def Captcha(browser, url):
print("ENTER IN TEXT BOX")
yzm = browser.find_element_by_xpath(
"/html/body/div[@id='body']/div[@id='inner']/form/p[@class='center'][2]/input[@id='Validate']")
yzm.send_keys(picture(browser))
time.sleep(10)
print("REDEEM BONUS POINTS")
login_first = browser.find_element_by_xpath(
"/html/body/div[@id='body']/div[@id='inner']/form/p[@class='center'][3]/input[@class='submit']")
login_first.click()
time.sleep(10)
print("Get current page URL")
url_first = browser.get("https://www.tppcrpg.net/battle.php?Battle=TrainingChallenge")
TC_battle(browser)
all three scripts works fine seperately
is there way i can link all three script together so that it keep running in loop forever
What I have tried:
def TC_battle(browser):
while True:
try:
time.sleep(2)
browser.find_element_by_class_name("submit").click()
except:
time.sleep(2)
browser.find_element_by_xpath("//a[contains(.,'Restart Battle')]").click()
else:
Captcha(browser, url)
i tried add
this
else:
Captcha(browser, url)
so that it redirect to captcha page but it doesnt work like i wanted