Information:
So currently im writing a Python programm which allows me to check if any four letter usernames are still valid on Ps4 website.
Problem: It works pretty fine until a random error comes up. I have literally tried everything to avoid this error, but haven't found a solution. My program works like this:
On the PSN website there is a field where u can change your username. I have all my four-letter names in a text file. To try each of them I wrote this:
with open("names.txt", "r+", encoding="utf-8") as file:
lines = file.readlines()
wait.until(EC.element_to_be_clickable((By.ID, input_id))) # Waits for input after redirect
for line in lines: # goes through every four-letter name
driver.find_element(By.ID, input_id).send_keys(line)
driver.find_element(By.CLASS_NAME, primary_button_class).click()
time.sleep(0.5) #This is where it fails
driver.find_element(By.ID, input_id).clear()
wait.until(EC.element_to_be_clickable((By.ID, input_id)))
On the time.sleep(0.5)
it throws an error because it doesnt find the field after the first try. I figured out that it needs more time, so I tried 1sec which works fine until it gets to 300-1000 tries. Than it fails randomly. I also have tried to wait for the element with EC.wait
until...
Question:
Why does it fail after a view thousend or hundrets of tries if I time.sleep(1)
. And why does it fail if I "wait" for the element to load with wait.until(EC.element_to_be_clickable((By.ID, input_id)))
how do i fix it, that it throws no error after n tries?