Automating Google meet using selenium in Python
Last Updated :
26 Oct, 2022
Prerequisites: Selenium Python basics, Browser Automation using Selenium
Selenium is a powerful tool for controlling web browsers through programs and performing browser automation. It is functional for all browsers, works on all major OS and its scripts are written in various languages i.e Python, Java, C#, etc, we will be working with Python.
Selenium can be used to automate the web browser. In this article, we will learn how to sign in a Google account and join a meeting through Google meet with a camera and microphone turned off using selenium.
Installation:
The selenium module can be installed using the below command:
pip install selenium
Step-by-step Approach:
Step 1: Import modules
Python3
# import required modules
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.options import Options
import time
Step 2: Create an instance of Chrome browser with some required prerequisite Chrome Options().
Python3
# creating chrome instance
opt = Options()
opt.add_argument('--disable-blink-features=AutomationControlled')
opt.add_argument('--start-maximized')
opt.add_experimental_option("prefs", {
"profile.default_content_setting_values.media_stream_mic": 1,
"profile.default_content_setting_values.media_stream_camera": 1,
"profile.default_content_setting_values.geolocation": 0,
"profile.default_content_setting_values.notifications": 1
})
driver = webdriver.Chrome(options=opt)
Step 3: Go to Google meet using this command
Python3
# go to google meet
driver.get('https://meet.google.com/xby-zehb-ncf')
Step 4: Calling the below function will turn off the camera and the microphone. In this function, turnOffMicCam(), we find the microphone & camera buttons by their xpaths using a function in selenium named find_element_by_xpath().
Python3
# explicit function to turn off mic and cam
def turnOffMicCam():
# turn off Microphone
time.sleep(2)
driver.find_element(By.XPATH,
'//*[@id="yDmH0d"]/c-wiz/div/div/div[8]/div[3]/div/div/div[2]/div/div[1]/div[1]/div[1]/div/div[4]/div[1]/div/div/div').click()
driver.implicitly_wait(3000)
# turn off camera
time.sleep(1)
driver.find_element(By.XPATH,
'//*[@id="yDmH0d"]/c-wiz/div/div/div[8]/div[3]/div/div/div[2]/div/div[1]/div[1]/div[1]/div/div[4]/div[2]/div/div').click()
driver.implicitly_wait(3000)
Step 5: Below function would help us join the meeting at Google meet. In this function, joinNow(), we find the join now button by its css selector using a function in selenium named find_element_by_css_selector() and click it to join the meeting! (we do the same in AskToJoin() function).
Python3
def AskToJoin():
# Ask to Join meet
time.sleep(5)
driver.implicitly_wait(2000)
driver.find_element(By.CSS_SELECTOR,
'div.uArJ5e.UQuaGc.Y5sE8d.uyXBBb.xKiqt').click()
# Ask to join and join now buttons have same xpaths
Step 6: Below is the function that would log in the Google account using the credentials provided. In this function, Glogin(mail,pw), we find the email text box by its id using a function in selenium named find_element_by_id() and type in the email using send_keys() & click next button again using its id and find password text box using its xpath, type in the password using send_keys & again click login using its id
Python3
def Glogin(mail_address, password):
# Login Page
driver.get(
'https://accounts.google.com/ServiceLogin?hl=en&passive=true&continue=https://www.google.com/&ec=GAZAAQ')
# input Gmail
driver.find_element(By.XPATH, "identifierId").send_keys(mail_address)
driver.find_element(By.ID, "identifierNext").click()
driver.implicitly_wait(10)
# input Password
driver.find_element(By.XPATH,
'//*[@id="password"]/div[1]/div/div[1]/input').send_keys(password)
driver.implicitly_wait(10)
driver.find_element(By.ID, "passwordNext").click()
driver.implicitly_wait(10)
# go to google home page
driver.get('https://google.com/')
driver.implicitly_wait(100)
Below is the complete program based on the above step-wise approach:
Python3
# import required modules
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.options import Options
import time
def Glogin(mail_address, password):
# Login Page
driver.get(
'https://accounts.google.com/ServiceLogin?hl=en&passive=true&continue=https://www.google.com/&ec=GAZAAQ')
# input Gmail
driver.find_element(By.ID, "identifierId").send_keys(mail_address)
driver.find_element(By.ID, "identifierNext").click()
driver.implicitly_wait(10)
# input Password
driver.find_element(By.XPATH,
'//*[@id="password"]/div[1]/div/div[1]/input').send_keys(password)
driver.implicitly_wait(10)
driver.find_element(By.ID, "passwordNext").click()
driver.implicitly_wait(10)
# go to google home page
driver.get('https://google.com/')
driver.implicitly_wait(100)
def turnOffMicCam():
# turn off Microphone
time.sleep(2)
driver.find_element(By.XPATH,
'//*[@id="yDmH0d"]/c-wiz/div/div/div[8]/div[3]/div/div/div[2]/div/div[1]/div[1]/div[1]/div/div[4]/div[1]/div/div/div').click()
driver.implicitly_wait(3000)
# turn off camera
time.sleep(1)
driver.find_element(By.XPATH,
'//*[@id="yDmH0d"]/c-wiz/div/div/div[8]/div[3]/div/div/div[2]/div/div[1]/div[1]/div[1]/div/div[4]/div[2]/div/div').click()
driver.implicitly_wait(3000)
def joinNow():
# Join meet
print(1)
time.sleep(5)
driver.implicitly_wait(2000)
driver.find_element(By.CSS_SELECTOR,
'div.uArJ5e.UQuaGc.Y5sE8d.uyXBBb.xKiqt').click()
print(1)
def AskToJoin():
# Ask to Join meet
time.sleep(5)
driver.implicitly_wait(2000)
driver.find_element(By.CSS_SELECTOR,
'div.uArJ5e.UQuaGc.Y5sE8d.uyXBBb.xKiqt').click()
# Ask to join and join now buttons have same xpaths
# assign email id and password
mail_address = 'emaild@gmail.com'
password = 'geeksforgeeks'
# create chrome instance
opt = Options()
opt.add_argument('--disable-blink-features=AutomationControlled')
opt.add_argument('--start-maximized')
opt.add_experimental_option("prefs", {
"profile.default_content_setting_values.media_stream_mic": 1,
"profile.default_content_setting_values.media_stream_camera": 1,
"profile.default_content_setting_values.geolocation": 0,
"profile.default_content_setting_values.notifications": 1
})
driver = webdriver.Chrome(options=opt)
# login to Google account
Glogin(mail_address, password)
# go to google meet
driver.get('https://meet.google.com/xby-zehb-ncf')
turnOffMicCam()
# AskToJoin()
joinNow()
Output:
Similar Reads
Google Maps Selenium automation using Python
Prerequisites: Browser Automation using Selenium Selenium is a powerful tool for controlling a web browser through the program. It is functional for all browsers, works on all major OS, and its scripts are written in various languages i.e Python, Java, C#, etc, we will be working with Python. It can
4 min read
Download Google Image Using Python and Selenium
In this article, we are going to see how to download google Image using Python and Selenium. Installation On the terminal of your PC, type the following command. If it triggers any error regarding pip then you need to 1st install pip on windows manually by python get-pip.py command then you can run
3 min read
Twitter Automation using Selenium Python
If you are someone like me who considers Twitter to be far better than Instagram, then I might be having something for you. We all know gaining followers on twitter can be pretty tough but sometimes retweeting quality content can gain you, followers, too. Obviously, you are a busy person and you don
6 min read
Python - Opening links using Selenium
Selenium is a powerful tool for controlling the web browser through the program. It is functional for all browsers, works on all major OS and its scripts are written in various languages i.e Python, Java, C#, etc, we will be working with Python. Selenium Python bindings provide a convenient API to a
2 min read
Python | Automating Happy Birthday post on Facebook using Selenium
As we know Selenium is a tool used for controlling web browsers through a program. It can be used in all browsers, OS, and its program are written in various programming languages i.e Java, Python (all versions). Selenium helps us automate any kind of task that we frequently do on our laptops, PCs
3 min read
Search Google Using Python Selenium
Selenium's Python Module is built to perform automated testing with Python. Selenium Python bindings provides a simple API to write functional/acceptance tests using Selenium WebDriver. Through Selenium Python API you can access all functionalities of Selenium WebDriver in an intuitive way. This art
1 min read
Browser Automation Using Selenium
Selenium is a powerful tool for controlling a web browser through the program. It is functional for all browsers, works on all major OS and its scripts are written in various languages i.e Python, Java, C#, etc, we will be working with Python. Mastering Selenium will help you automate your day to da
3 min read
Non blocking wait in selenium using Python
Prerequisite : Browser Automation Using SeleniumWhen we want to do web automation, we require to wait for some javascript elements to load before we perform some action. For that matter, generally people use Python3 time.sleep(in_seconds) which is a blocking call.By blocking call I mean, it waits or
3 min read
Automated Browser Testing with Edge and Selenium in Python
Cross-browser testing is mandatory in the software industry. We all know that there are many browsers like Firefox, Chrome, Edge, Opera etc., are available. Rather than writing separate code to each and every browser, it is always a decent approach to go towards automated testing. Let us see how to
5 min read
Text Searching in Google using Selenium in Python
Selenium is a powerful tool for controlling web browsers through programs and performing browser automation. It is functional for all browsers, works on all major OS and its scripts are written in various languages i.e Python, Java, C#, etc, we will be working with Python. In this article, we are go
3 min read