Is there a robust method for casting all alt values inside the img tags into strings to formulate a sentence, without losing the position of both texts: (Note: the amount of img tags between the two texts can vary)
<img alt="one">
Bobby gave:
<img alt="two">
<img alt="two">
<img alt="two">
and took
<img alt="three">
<img alt="four">
desired output:
sentence = "one Bobby gave: two two two and took three four"
I tried:
images = driver.find_elements(By.TAG_NAME, "img")
sentence = [img.get_attribute("alt") for img in images]
But now i dont get the two texts "Bobby gave" and "and took" between the right tags