Jan-07-2022, 10:59 AM
Hi @Bipinjohnson ,
In the documentation of
The question mark means the previous character must appear 0 or 1 time. The parenthesis also have a meaning of capturing substrings. So you should escape those characters:
I am not sure if this works. Play it safe and just check for:
Then also: you do not check if the string is found. You should check the returned value.
In the documentation of
expect()
you can read: Quote:Strings will be compiled to re types. This means your expected string is a dangerous one because it will be treated as a regular expression:
'Enable QSE API? (Y/n)'
The question mark means the previous character must appear 0 or 1 time. The parenthesis also have a meaning of capturing substrings. So you should escape those characters:
'Enable QSE API\? \(Y\/n\)'
I am not sure if this works. Play it safe and just check for:
'Enable QSE API'
Then also: you do not check if the string is found. You should check the returned value.
return_val=child.expect(['Enable QSE API']) #if i receive the same string then i want to pass y to the terminal if return_val == 0: child.sendline('y') else: print("The expected string was not found") sys.exit()