How to extract the second strong from innerHTML using Selenium

  python, selenium

So I’m using xpath to find the innerHTML and it prints:

<strong>Player</strong> found a wild <strong>Golbat</strong>!

How would I print out the 2nd since there’s 2 strongs so that it prints out Golbat

I’m currently using:

driver.find_elements_by_xpath("//*[contains(@class, 'markup-2BOw-j messageContent-2qWWxC')]")[-1].get_attribute('innerHTML')

Source: Python Questions

LEAVE A COMMENT