A Multithreaded Social Media User Engagement Automation implemented using Python Appium, Selenium Web Driver, and Android Debug Bridge
git clone https://github.com/MarianneRario/appium_automation.gitappium_automation is a multithreaded social media user engagement automation tool built with Python, Appium, Selenium Web Driver, and Android Debug Bridge. It automates repetitive engagement tasks across social media platforms by controlling mobile and web interfaces programmatically. The skill leverages industry-standard automation frameworks to handle concurrent operations efficiently.
["Install prerequisites: Python 3.8+, Appium Server, Android Studio with ADB, and required Python packages (`appium-python-client`, `selenium`, `uiautomator2`).","Configure Appium server with the correct capabilities for your Android device/emulator, including `platformName`, `deviceName`, `appPackage`, and `appActivity`.","Modify the script to include your specific social media platform details (e.g., package name for Instagram is `com.instagram.android`).","Replace placeholder credentials and target usernames/hashtags with your actual marketing campaign data.","Run the script with `python social_media_automation.py` and monitor the logs in `social_media_automation.log` for progress and errors.","For better results, test the script on a single account first to verify element locators and timing, then scale to multiple threads."]
Automate likes, comments, and follows across multiple social media accounts simultaneously
Scale user engagement testing on Android applications using real device control
Batch process social media interactions across different platforms with multithreaded execution
Test social media UI workflows on mobile devices using Appium and Selenium integration
No install command available. Check the GitHub repository for manual installation instructions.
git clone https://github.com/MarianneRario/appium_automationCopy the install command above and run it in your terminal.
Launch Claude Code, Cursor, or your preferred AI coding agent.
Use the prompt template or examples below to test the skill.
Adapt the skill to your specific use case and workflow.
Write a Python script using Appium, Selenium WebDriver, and Android Debug Bridge (ADB) to automate [SOCIAL_MEDIA_PLATFORM] user engagement tasks. The script should [SPECIFIC_TASKS], such as liking posts, following users, or commenting with [CUSTOM_MESSAGES]. Include multithreading to handle [NUMBER] accounts simultaneously. Ensure the script logs all actions to [LOG_FILE_PATH] and includes error handling for common issues like network timeouts or element not found errors. Test the script on [DEVICE_MODEL] running Android [VERSION].
```python
import threading
import logging
from appium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
import time
import subprocess
# Configure logging
logging.basicConfig(filename='social_media_automation.log', level=logging.INFO)
# Appium capabilities for Samsung Galaxy S22 (Android 13)
capabilities = {
'platformName': 'Android',
'deviceName': 'Galaxy_S22',
'appPackage': 'com.instagram.android',
'appActivity': 'com.instagram.mainactivity.MainActivity',
'automationName': 'UiAutomator2',
'noReset': True,
'newCommandTimeout': 600
}
# ADB command to check internet connectivity
ADB_PATH = 'adb'
class InstagramAutomation(threading.Thread):
def __init__(self, account_email, account_password, thread_id):
threading.Thread.__init__(self)
self.account_email = account_email
self.account_password = account_password
self.thread_id = thread_id
self.driver = None
def setup_driver(self):
try:
self.driver = webdriver.Remote('http://localhost:4723/wd/hub', capabilities)
logging.info(f'Thread {self.thread_id}: Driver initialized successfully')
except Exception as e:
logging.error(f'Thread {self.thread_id}: Failed to initialize driver - {str(e)}')
raise
def login(self):
try:
# Navigate to login screen
wait = WebDriverWait(self.driver, 10)
email_field = wait.until(EC.presence_of_element_located((By.XPATH, '//*[@text="Phone number, username, or email"]')))
email_field.send_keys(self.account_email)
password_field = self.driver.find_element(By.XPATH, '//*[@text="Password"]')
password_field.send_keys(self.account_password)
login_button = self.driver.find_element(By.XPATH, '//*[@text="Log In"]')
login_button.click()
# Handle "Save Info" prompt if it appears
try:
save_info_button = wait.until(EC.presence_of_element_located((By.XPATH, '//*[@text="Save Info"]')))
save_info_button.click()
except:
pass
logging.info(f'Thread {self.thread_id}: Successfully logged in')
except Exception as e:
logging.error(f'Thread {self.thread_id}: Login failed - {str(e)}')
raise
def like_posts(self, hashtag, count=10):
try:
# Navigate to hashtag search
search_button = self.driver.find_element(By.XPATH, '//*[@content-desc="Search and Explore"]')
search_button.click()
search_field = wait.until(EC.presence_of_element_located((By.XPATH, '//*[@content-desc="Search input"]')))
search_field.send_keys(hashtag)
# Select the first hashtag result
first_result = wait.until(EC.presence_of_element_located((By.XPATH, f'//*[@text="{hashtag}"]')))
first_result.click()
# Scroll and like posts
for _ in range(count):
posts = self.driver.find_elements(By.XPATH, '//*[@content-desc="Like"]')
if posts:
posts[0].click()
logging.info(f'Thread {self.thread_id}: Liked a post')
else:
logging.warning(f'Thread {self.thread_id}: No posts found to like')
# Scroll down
self.driver.swipe(500, 1500, 500, 500, 500)
time.sleep(2)
except Exception as e:
logging.error(f'Thread {self.thread_id}: Error in like_posts - {str(e)}')
def follow_users(self, username_list):
try:
for username in username_list:
# Navigate to user profile
search_button = self.driver.find_element(By.XPATH, '//*[@content-desc="Search and Explore"]')
search_button.click()
search_field = wait.until(EC.presence_of_element_located((By.XPATH, '//*[@content-desc="Search input"]')))
search_field.send_keys(username)
# Select the user from results
user_result = wait.until(EC.presence_of_element_located((By.XPATH, f'//*[@text="{username}"]')))
user_result.click()
# Follow the user
follow_button = wait.until(EC.presence_of_element_located((By.XPATH, '//*[@text="Follow"]')))
follow_button.click()
logging.info(f'Thread {self.thread_id}: Followed user {username}')
time.sleep(3) # Rate limiting
except Exception as e:
logging.error(f'Thread {self.thread_id}: Error in follow_users - {str(e)}')
def run(self):
try:
self.setup_driver()
self.login()
self.like_posts('#travel', count=15)
self.follow_users(['@wanderlust', '@explore', '@adventure'])
except Exception as e:
logging.error(f'Thread {self.thread_id}: Automation failed - {str(e)}')
finally:
if self.driver:
self.driver.quit()
# Create and start threads for 3 accounts
accounts = [
{'email': '[email protected]', 'password': 'pass123'},
{'email': '[email protected]', 'password': 'pass456'},
{'email': '[email protected]', 'password': 'pass789'}
]
threads = []
for i, account in enumerate(accounts):
thread = InstagramAutomation(account['email'], account['password'], i+1)
threads.append(thread)
thread.start()
# Wait for all threads to complete
for thread in threads:
thread.join()
print('All automation threads completed. Check logs for details.')
```Take a free 3-minute scan and get personalized AI skill recommendations.
Take free scan