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

Restart script when error happens and continue with right line in csv file

$
0
0

hi guys its my first time to ask help here i hope you can help me i have this code that i write it

def my_function():
try :
    with open('file.csv', 'r') as f:
        data = list(csv.reader(f, delimiter=','))

        i = 1
        while i <= 10:
            i += 1
            fname = data[i][0]
            lname = data[i][1]

            options = Options()
            driver = webdriver.Chrome(options=options)
            driver.get("https://www.test.net/")


            #Do staff


except Exception as e:
    print(e)
    driver.quit()
    time.sleep(1)
    print('******RESTART******')
    my_function()


my_function()

well i'm trying to make this script run without stop .. the problem that i'm facing is when it stops for example in line number 8 (i = 8) and restart again ,it starts from first line (i = 1) . i want the script to restart from line 8 and continue to 9 , 10 ...

can you please guide me to the right solution .. thank you


Viewing all articles
Browse latest Browse all 98819

Trending Articles



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