2021年3月6日星期六

How to modify Python XPATH code using OR operator

Below is my code. I want to click the button that says "load all" if it exists. If not, I want to click the "load next". However, with my code below, it's only clicking the "load next" even though a "load all" btn is present. How can I fix this?

try:     load_btn = WebDriverWait(driver,10).until(EC.element_to_be_clickable((By.XPATH,"/html/body/div[2]/div[7]/div/div/div[8]/a[contains(text(),'Load all') or contains(text(),'Load next')]")))      load_btn.click()     time.sleep(3)                   except:     pass  

I've tried using the | operator, but that doesn't give me the answer I need. How can I fix this?

Thank you.

https://stackoverflow.com/questions/66512557/how-to-modify-python-xpath-code-using-or-operator March 07, 2021 at 10:04AM

没有评论:

发表评论