-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
method.py
61 lines (55 loc) · 1.91 KB
/
method.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
57
58
59
60
61
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from time import sleep
class Method:
def __init__(self, driver):
self.driver = driver
self.wait = self.waittemp(temp=1)
self.newmsg = '_31gEB',
self.nome = '_3ko75',
self.chatdados = '_3Whw5',
self.aguarde = self.waittemp(slp=3)
def chatatual(self):
return self.wait.until(EC.presence_of_element_located((By.XPATH, "(//div[@contenteditable='true'])[2]")))
def sendResponse(self, response):
self.chatatual().send_keys(response)
botao_enviar = self.driver.find_element_by_xpath("//span[@data-icon='send']")
self.waittemp(slp=1)
botao_enviar.click()
def sendMedia(self, file=False, captiontext=False):
try:
clip = self.driver.find_element_by_xpath("//span[@data-icon='clip']")
clip.click()
sleep(0.5)
media = self.wait.until(EC.presence_of_element_located((By.XPATH, '//input[@accept="image/*,video/mp4,video/3gpp,video/quicktime"]')))
media.send_keys(file)
self.aguarde
if (captiontext):
caption = self.driver.switch_to.active_element
caption.send_keys(captiontext)
self.aguarde
botao_enviar = self.driver.find_element_by_xpath("//span[@data-icon='send']")
botao_enviar.click()
except Exception as error:
print(error)
def sendDocument(self, file=False):
try:
clip = self.driver.find_element_by_xpath("//span[@data-icon='clip']")
clip.click()
sleep(0.5)
media = self.wait.until(EC.presence_of_element_located((By.XPATH, '//input[@accept="*"]')))
media.send_keys(file)
self.aguarde
botao_enviar = self.driver.find_element_by_xpath("//span[@data-icon='send']")
botao_enviar.click()
except Exception as error:
print(error)
def waittemp(self, temp=False, slp=False):
if (temp):
return WebDriverWait(self.driver, temp)
elif (slp):
sleep(slp)
return "ok"
else:
return False