-
Notifications
You must be signed in to change notification settings - Fork 0
/
automation.py
110 lines (94 loc) · 4.58 KB
/
automation.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
from requests.api import request
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support import expected_conditions as EC
import time
import requests
class WebexAutomation:
def __init__(self, url):
options = webdriver.ChromeOptions()
options.add_argument('--ignore-certificate-errors')
options.add_argument('--ignore-ssl-errors')
options.add_experimental_option('excludeSwitches', ['enable-logging'])
self.driver = webdriver.Chrome(
r"chromedriver.exe", chrome_options=options)
self.url = url
def _connect(self):
try:
self.driver.get(self.url)
except:
raise requests.exceptions.ConnectTimeout
def joinMeeting(self, name, email):
try:
self._connect()
# join in browser button
WebDriverWait(self.driver, 8).until(EC.presence_of_element_located((
By.XPATH, "/html/body/div[1]/div[3]/div/div[1]/div/div[2]/div[1]/div[2]/div[2]/div[3]/a")))
self.driver.find_element_by_xpath(
"/html/body/div[1]/div[3]/div/div[1]/div/div[2]/div[1]/div[2]/div[2]/div[3]/a").click()
frame_xpath = "/html/body/section/iframe"
# switching i frame
WebDriverWait(self.driver, 10).until(EC.presence_of_element_located((
By.XPATH, frame_xpath)))
frame = self.driver.find_element_by_xpath(frame_xpath)
self.driver.switch_to.frame(frame)
time.sleep(2)
print("TextFeils")
# name text feild
WebDriverWait(self.driver, 10).until(EC.presence_of_element_located((
By.XPATH, "/html/body/div[1]/div/div[2]/div[2]/div/input")))
self.driver.find_element_by_xpath(
"/html/body/div[1]/div/div[2]/div[2]/div/input").send_keys(name)
# email id textfeild
self.driver.find_element_by_xpath(
"/html/body/div[1]/div/div[2]/div[3]/div/input").send_keys(email)
# next button
self.driver.find_element_by_xpath(
"/html/body/div[1]/div/div[2]/div[4]/button").click()
# # got it button
# got_it_button = "/html/body/div[4]/div[2]/div/div/div/div/div[1]/button"
# WebDriverWait(self.driver, 15).until(EC.presence_of_element_located((
# By.XPATH, got_it_button)))
# self.driver.find_element_by_xpath(
# got_it_button).click()
#Pressing Mute Button
WebDriverWait(self.driver, 10).until(EC.presence_of_element_located((
By.XPATH, "/html/body/div[1]/div[1]/div[3]/div[2]/div[1]/div[1]/button")))
self.driver.find_element_by_xpath(
"/html/body/div[1]/div[1]/div[3]/div[2]/div[1]/div[1]/button").click()
# Pressing video Button
self.driver.find_element_by_xpath(
"/html/body/div[1]/div[1]/div[3]/div[2]/div[2]/div[1]/button").click()
# join meeting
join = "/html/body/div[1]/div/div[3]/div[2]/span/button"
WebDriverWait(self.driver, 15).until(EC.presence_of_element_located((
By.XPATH, join)))
self.driver.find_element_by_xpath(
join).click()
return True, ""
except requests.exceptions.ConnectTimeout:
return False, "Something went wrong check your internetConnection and tryagain"
except requests.exceptions.ConnectionError:
return False, "Something went wrong check your internetConnection and tryagain"
except Exception as e:
print(str(e))
return False, "Something went wrong"
def close_meeting(self):
# close meeting
print("closing the connection")
self.driver.close()
def message(self, msg):
try:
chatBtn = "/html/body/div[3]/div[18]/div[2]/div[2]/div/button[2]/span[1]/i"
WebDriverWait(self.driver, 8).until(
EC.presence_of_element_located((By.XPATH, chatBtn)))
self.driver.find_element_by_xpath(chatBtn).click()
text_area = "/html/body/div[3]/div[4]/div/div/div/div[8]/div/div/div[3]/textarea"
text_area_box = self.driver.find_element_by_xpath(text_area)
text_area_box.send_keys(msg, Keys.ENTER)
return True, "message"
except Exception as e:
print(str(e))
return False, str(e)