Quantcast
Channel: Active questions tagged selenium - Stack Overflow
Viewing all articles
Browse latest Browse all 97774

While loop doesn't add up my variable python3

$
0
0

I'm doing a data scraper in python using selenium, I want to navigate through pages in a website using a while loop for execute the scraper but i can't change my navigate variable, here is my code

numeros = 2
all_texts = driver.find_elements_by_class_name('list')
btn = driver.find_element_by_xpath('//*[@id="listadoAgencias"]/div/div/div[3]/nav/ul/li['+str(numeros)+']/a')
veces = 1


def showall():
    for text in all_texts:
        print(text.text)
        sleep(2)


while veces < 6:
    showall()
    print('------------------------------------------')
    driver.execute_script("window.scrollTo(0, 3000)")
    sleep(1)
    btn.click()
    numeros += 1
    sleep(3)

my variable "numeros" still the same (int 2) so the numeros += 1 is not taking effect and the app crash after go through the second page


Viewing all articles
Browse latest Browse all 97774

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>