So basically my code grabs a line from my txt and does its job with selenium. the problem is after every check, my program should give me the status after the selenium check and the line that has been checked. the problem is both of the functions are in different def's. the selenium part and the check status part.
so i could do x = f.readline() and call it after the check is done which will work with no issues tho because the x is needed in the 1. def and it's changing every time, i can't change his position. so i tried to do y = f.readline() in the status def, which should also work but because i call readline again, both of the variables change. i need it to check and report line by line. Also readline() Copies \n which is causing a lot of trouble
Let me make it a little bit more clear. here is the more simple code
f = open('list.txt', 'r')
def part1():
x = f.readline()
xxx = x[0:][:16]
xxxx = x[17:][:2]
driver.get('https://website.com')
elem = driver.find_element_by_name("example")
elem.send_keys(xxx);
elem = driver.find_element_by_name("example2")
elem.send_keys(xxxx);
......
def checkpart():
part1()
(some sleep code)
if driver.find_elements_by_xpath("//*[contains(text(), 'checkprocess')]"):
print('[-] Bad: ', x)
elif driver.find_elements_by_xpath("//*[contains(text(), 'checkprocess2')]"):
print('[+] Good: ', x)
else:
print('[+] Smthelse: ', x)
(some input questions...)
i = 1
register() //other function thats not needed here//
while i <= input:
checkpart()
time.sleep(1)
i += 1
Its a bit complicated and i couldnt found an easier way of readline(). tho it doesnt allow me to display x in the checkpart and it also copies \n
I need to display the current checked line (which is x) without changing it and without copying \n in the end of it.
As i said its a bit complicated for me i've made a lot of research tho didnt come up with anything that will help. i also issue the same in php.