I'm trying to locate the button element "Follow" because it contains the text of the user that you're going to follow.
Element:
<div aria-label="Follow @Visiongeo" role="button" tabindex="0" class="css-18t94o4 css-1dbjc4n r-42olwf r-sdzlij r-1phboty r-rs99b7 r-15ysp7h r-4wgw6l r-1ny4l3l r-ymttw5 r-o7ynqc r-6416eg r-lrvibr" data-testid="1676648952-follow" style="background-color: rgb(239, 243, 244);"><div dir="auto" class="css-901oao r-1awozwy r-6koalj r-18u37iz r-16y2uox r-37j5jr r-a023e6 r-b88u0q r-1777fci r-rjixqe r-bcqeeo r-q4m81j r-qvutc0" style="color: rgb(15, 20, 25);"><span class="css-901oao css-16my406 css-bfa6kz r-poiln3 r-1b43r93 r-1cwl3u0 r-bcqeeo r-qvutc0"><span class="css-901oao css-16my406 r-poiln3 r-bcqeeo r-qvutc0">Follow</span></span></div></div>
But the thing is, the text after Follow, which is @Visiongeo changes, so I don't want to particularly locate the element with specific text.
Instead, I want to locate this element, and then get the text that starts with "@" and write it to a text file.
My code:
for followers in wait.until(EC.element_to_be_clickable((By.XPATH, "//div[starts-with(@aria-label, 'Follow')]"))):
file = open("testfile.txt", "a")
file.write(followers)
file.write("\n")
file.close()
I get TimeoutException message when I use the above code. I think I'm way off from what I intend to do.