Click here to Skip to main content
14,921,505 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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 separately
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 have tried to add this
else:
Captcha(browser, url)
Posted
Updated 4-May-21 1:08am

1 solution

This is exactly the same question as Need assistance regarding connecting 3 .py files together selenium Python[^] posted yesterday. Please do not repost, and do not create multiple accounts.
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900