Just Another web automation project 😁😁
I have had some issues regarding the application of Twitter developer account, as it was constantly being rejected citing minor issues. At last I finally geared up doing the same, but using different approach. This project explores Selenium as a Web Automation tool that automates Twitter Login, Logout and Likes and can serve as a base for doing other automations in twitter.
This project is purely intended for educational purpose with not to be used in production environment. Many actions automated here goes against Twitter policy, and this project by any means doesn't intend to violate those policies. Please go through Twitter automation policies before actually using this code. Link: Twitter Developer Policy
- Java 8 as programming language
- Maven for Package Management and Build Automation
- Selenium for Web Automation
- Resteasy as JAX-RS implementation for Restful Services
Basic understanding of Java with Maven.
Steps are listed below to get this project up and running in your development environment.
- Setup Java with JDK 1.8. For reference: Use this official Tutorial
- Setup Maven. Follow this link: Maven Setup
- Clone this repository in your target folder.
git clone https://github.com/bishwa-poudel/twitter-automation-using-selenium-java.git
- Now go to
src/main/resources/twitter.sample.properties
and rename the configuration file totwitter.properties
. And fill the params listed in properties file.
Example:
# file: twitter.properties
#******************************** Twitter account creds ********************************
USERNAME=your_username
PASSWORD=your_password
#******************************** Automation Rate ********************************
LIKE_LIMIT=100
DELAY_IN_MS=3000
REPEAT_AFTER_IN_MINUTES=180
#************************ Twitter Feed URL (with any filters or hashtags) ********************************
TWITTER_FEED_URL=twitter_feed_url
- USERNAME: Your twitter account username
- PASSWORD: Your twitter account password (Credentials are purely used for login to twitter.)
- LIKE_LIMIT: Number of likes that should be done in one cycle.
- DELAY_IN_MS: You donot want to spam twitter with multiple requests at a single time right. To simulate the human behavior, we are adding some delay after every action in automation.
- REPEAT_AFTER_IN_MINUTES: The time interval at which the particular action is to be repeated. Ex: 180 denotes Like action will repeat in every 180 minutes
- TWITTER_FEED_URL: URL of twitter timeline. This might be twitter homepage, timeline of particular hashtags or using any advanced filtering. The URL should open to the tweets timeline.
- After you are sure that everything is setup correctly, run maven build command:
mvn clean install
- Once you see this message in the console, your build is ready. Goto
target/twitter-automation.war
to get the WAR file.
Note: I have used WAR for packaging. If you want to build into the jar file, change the <packaging>
inside pom.xml file to jar.
<packaging>jar</packaging>
Now you can use any application server to deploy the archived java file. For this project I am using Wildfly v22.0.1
Congrats !!! You are now able to run and deploy the project in your own development environment.
Server automatically schedules Twitter Like Action based on the time interval mentioned on twitter.properties
file. There is also APIs exposed for manual login, logout and like actions.
GET /twitter-automation/api/action/login
GET /twitter-automation/api/action/like
GET /twitter-automation/api/action/logout
- Bishwa Poudel - Initial work - Bishwa Poudel
This project is licensed under the MIT License - see the LICENSE.md file for details