Helios-Archives / Twitch-Account-Creator

A selenium based bot to create accounts without the need for paid capcha solves.
MIT License
71 stars 10 forks source link

Login Button Xpath not found #1

Closed Tmdoofking closed 2 years ago

Tmdoofking commented 2 years ago

driver.find_element(By.XPATH, '/html/body/div[1]/div/div[2]/nav/div/div[3]/div[3]/div/div[1]/div[1]/button').click() this event sometime won't work

Helios-fr commented 2 years ago

Can you add some more detail to this can you add:

The problem may be due to slow internet connection you could fix this by:

If the problem is internet connection I will add a Check for the element soon.

Tmdoofking commented 2 years ago

this is from click login buttom (first one) i have let it loop alrerady, only way to fix it's reopen firefox. (i don't know how force finish it and restart from top) image

Helios-fr commented 2 years ago

Hi, it seems that the issue was the xpath of the login button switched between two different values seemingly at random the code for the fix is below and will also be commited to the main project files,

# Clicks login button
    while True:
        try:
            driver.find_element(By.XPATH, '/html/body/div[1]/div/div[2]/nav/div/div[3]/div[2]/div/div[1]/div[1]/button')
            login_xpath = '/html/body/div[1]/div/div[2]/nav/div/div[3]/div[2]/div/div[1]/div[1]/button'
            break
        except:
            try:
                driver.find_element(By.XPATH, '/html/body/div[1]/div/div[2]/nav/div/div[3]/div[3]/div/div[1]/div[1]/button')
                login_xpath = '/html/body/div[1]/div/div[2]/nav/div/div[3]/div[3]/div/div[1]/div[1]/button'
                break
            except:
                sleep(1)

    driver.find_element(By.XPATH, login_xpath).click()

If this fixes your problem please close the issue.


(i don't know how force finish it and restart from top)

To close the current firefox instance run

driver.quit()
return None

Just in case you want to modify the project and need to.