forked from mishraaditya595/WhatsApp-Automater
-
Notifications
You must be signed in to change notification settings - Fork 0
/
whatsapp_automation_using_selenium.py
56 lines (34 loc) · 1.23 KB
/
whatsapp_automation_using_selenium.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# -*- coding: utf-8 -*-
"""WhatsApp automation using selenium.ipynb
Automatically generated by Colaboratory.
Original file is located at
https://colab.research.google.com/drive/1tL4XzzPlwtS6G3ODF7w9VSd6z1lM6iuc
"""
from selenium import webdriver
browser=webdriver.Chrome("/Users/Desktop/chromedriver")
browser.get("https://www.selenium.dev/")
download=browser.find_element_by_link_text("Downloads")
search=browser.find_element_by_id('gsc-i-id1')
serch.send_keys("Downloads")
#whatsapp automation
from selenium import webdriver
from selenium.webdriver.support import expected_conditions as ec
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
import time
browser=webdrive.Chrome("/Users/Desktop/chromedriver")
browser.get("https://web.whatsapp.com")
wait=WebDriverWait(browser,600)
#for sending message
target="Aditya"
string="hello"
#enter the span code
x_arg="//span[]"
target=wait.until(ec.presence_of_element_located(By.XPATH,x_arg))
target.click()
#enter the class code of your whatsapp
input_box=browser.find_element_by_class_name("class code")
#send message for 50 times
for i in range(50):
input_box.send_Keys(string+Keys.ENTER)