Reputation: 1
How can i write a ruby.rb script using watir, that will write a string to the status and then post it. so far i have identified the status form and have been abot to click the post button, but i cant get the text in the status to update programmatically with watir. i have identified the that holds the text but it seems as though the span is updated with some java via a data-text attribute. this is just a guess so it might not actually be the case.
Upvotes: 0
Views: 107
Reputation: 6660
Last I looked, automated/scripted responses to postings on Facebook was disallowed by facebook’s terms of service. (2nd item in third section ‘safety’).
So step 1 is to be employed or otherwise authorized by Facebook to access their site using automation. Eg sign up as a partner developer.
Unless you are specifically testing their site, the way to do automation on their platform is via their API, not via driving a browser.
If this is for a class, print out the Facebook terms of service, hilight the appropriate section and ask your professor for an assignment that would not get you banned from Facebook.
Given current events, most of us do not want to assist with anything remotely resembling creation or upkeep of a ‘bot’ that posts or responds to social media, which is pretty much what you are asking.
Upvotes: 0
Reputation: 6411
Until you update your question with what code you've tried I can give you this idea. If you can get the cursor to show up in the text field you can do:
browser.send_keys 'x'
browser.send_keys :enter
This works for me in Ruby 2.4 with Watir controlling Safari on a Mac.
Upvotes: 0