Thursday 20 September 2018

How can I handle randomized selectors?

I'm trying to post things to Facebook automatically via Puppeteer.The selector I'm trying to click is:#u_0_2e > div._sa_._gsd._fgm._5vsi._192z._1sz4._1i6z > div > div > div > div._3399._a7s._20h6._610i._610j._125r._2h27.clearfix._zw3 > div._524d > div > span:nth-child(3) However, it will randomly change from #u_0_2e to #u_0_2f or something similar. It's incredibly frustrating.Essentially what I'm trying to automate is if I post something to my Facebook page, it will take the link, click "Share" and automatically share it to another page that I select. However, Facebook's randomized selectors makes this next to impossible.I've tried searching for a solution, but I cannot find a single thing that will help me with this that will apply to async code.I just need something that will click the "Share" button, type in a phrase, and click "Share post to page."The usage for this is that if I post something to FB while mobile, it will automatically share it for me so that way I won't have to do it manually on mobile, which takes forever. Additionally, if I schedule posts, I want it to be able to be shared automatically. It's only shared in three locations on FB, so I do not plan on spamming.My backup ideas include:-try/catch. If there's an error finding selector 1, then try selector 2, etc.-clicking specific coordinates on the page-somehow figuring out how to search the text and click it, but ensuring that it matches the specific text I'm looking forAny help would be appreciated, thanks!

Submitted September 20, 2018 at 08:17AM by Lark_vi_Britannia

No comments:

Post a Comment