Twitter Compose New Tweet XPaths

noellarkin

Senior Member
Joined
Mar 14, 2021
Messages
1,006
Reaction score
1,492
It's so weird I've been working on a whole bunch of sites, and I did NOT expect to get stuck on Twitter.
Example: the Tweet button;

Rel. XPath:
//div[@class='css-18t94o4 css-1dbjc4n r-1vtznih r-42olwf r-sdzlij r-1phboty r-rs99b7 r-19u6a5r r-2yi16 r-1qi8awa r-1ny4l3l r-ymttw5 r-o7ynqc r-6416eg r-lrvibr']//span[@class='css-901oao css-16my406 r-poiln3 r-bcqeeo r-qvutc0'][normalize-space()='Tweet']

JS Path:
document.querySelector("div[class='css-18t94o4 css-1dbjc4n r-1vtznih r-42olwf r-sdzlij r-1phboty r-rs99b7 r-19u6a5r r-2yi16 r-1qi8awa r-1ny4l3l r-ymttw5 r-o7ynqc r-6416eg r-lrvibr'] span[class='css-901oao css-16my406 r-poiln3 r-bcqeeo r-qvutc0']")

AbsXPath:
/html[1]/body[1]/div[1]/div[1]/div[1]/div[1]/div[2]/div[1]/div[1]/div[1]/div[1]/div[1]/div[2]/div[2]/div[1]/div[3]/div[1]/div[1]/div[1]/div[1]/div[1]/div[1]/div[1]/div[1]/div[2]/div[3]/div[1]/div[1]/div[2]/div[4]

CSS Selector:
.css-18t94o4.css-1dbjc4n.r-1vtznih.r-42olwf.r-sdzlij.r-1phboty.r-rs99b7.r-19u6a5r.r-2yi16.r-1qi8awa.r-1ny4l3l.r-ymttw5.r-o7ynqc.r-6416eg.r-lrvibr

All of these are perfectly monstrous lol, is there an easier way to do this?
 
Edit: just to clarify, I was a little perturbed by that ridiculous XPath string and was wondering if I would do anything to make it simpler - - I tried opening twitter with a mobile useragent, hoping it'd simplify the layout. No luck with that, same/similar result. I tried opening the compose tweet dialog in a new window so it doesn't just form a javascript box over the existing timeline/feed, but that's not possible, it seems.
 
More bootstrap than American army! I remember things where a bit easier with my twitter programs in ubot, but I don't fancy normal coding for twitter if thats what it looks like! lol
 
Can you get this attribute data-testid="tweetButtonInline"?
I found data-testid="tweetButton",
1633882859744.png

XPath: /html/body/div[@id='react-root']/div/div/div[@id='layers']/div[2]/div/div/div/div/div/div[2]/div[2]/div/div[3]/div/div/div/div[1]/div/div/div/div/div[2]/div[3]/div/div/div[2]/div
 
Canyou get the data-testid="tweetButton", then get the Tweet span from that?
Something like this? //div[@data-testid='tweetButton']//span[text()='Tweet']
 
Back
Top