dimanche 3 janvier 2021

Multiple if conditions in Python Selenium (Firefox)

Yes, I read other threads like: Styling multi-line conditions in 'if' statements?

I have this code and I want to check if a specific texts exists on the given page. The code does only work with one condition for some reasons, not with 2 or more.

import requests

r = requests.get('http://example.com/')

if 'ghcjdfghfgh' or 'fgxhdfghdfyh' in r.text:
    print ('Yes')
else:
    print ('No')

It says yes, even though it not true. I tried the same code with a comma instead of the "or" but still, the same issue.

import requests
r = requests.get('http://example.com/')

if 'ghcjdfghfgh','fgxhdfghdfyh' in r.text:
    print ('Yes')
else:
    print ('No')

Aucun commentaire:

Enregistrer un commentaire