Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

selecting indexed xpath in python

on the following url there are 3 score cards.

https://www.basketball-reference.com/boxscores/?month=4&day=8&year=2023

I’ve tried many different variation of the xpaths to try and access the second one but the first one linking to the box score keeps being returned.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

score_card = WebDriverWait(driver, 2).until(EC.presence_of_element_located((By.XPATH, "(//div[@class='game_summary expanded nohover '])[2]/p/a"))).click()

I’ve tried many different ways of changing it and can’t crack it! please help.

thank you
!

>Solution :

You don’t need to use brackets in your xpath.

Use .//div[@class='game_summary expanded nohover '][2]/p/a and it should work.
Check the attached imageenter image description here

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading