Report this

What is the reason for this report?

selenium python is opening 2 chrome windows instead of one

Posted on January 13, 2021

So I am trying to automate my google meet classes using selenium and python. So when I run the code it opens up chrome and then it freezes and opens another chrome and all the commands are executed in the second window. I can’t understand why because I only need 1 window and it’s opening 2. anyway pls help me fix this . and also my code is split into different files so I am only going to give the main file. Some of the imports are from the other files so just check my main code if u want I can give the rest. this is my code:

import time
from test import *
from do import *
from datetime import datetime

from datetime import date
from selenium import webdriver
from selenium.webdriver.common.keys import Keys

from selenium.webdriver.chrome.options import Options

chrome_options = webdriver.ChromeOptions()
prefs = {"profile.default_content_setting_values.media_stream_mic" : 1,
         "profile.default_content_setting_values.notifications": 2,
         "profile.default_content_setting_values.media_stream_camera": 1}

chrome_options.add_experimental_option("prefs",prefs)


path = r'C:\Users\User\Documents\chromedriver_win32 (2)\chromedriver.exe'
driver = webdriver.Chrome(path, chrome_options=chrome_options)

email = "example@gmail.com"
password = "blah123"



driver.get('https://accounts.google.com/o/oauth2/v2/auth/oauthchooseaccount?redirect_uri=https%3A%2F%2Fdevelopers.google.com%2Foauthplayground&prompt=consent&response_type=code&client_id=407408718192.apps.googleusercontent.com&scope=email&access_type=offline&flowName=GeneralOAuthFlow')
time.sleep(3)
driver.find_element_by_xpath('//*[@id="yDmH0d"]').click()
driver.find_element_by_xpath('//input[@type="email"]').send_keys(email)
driver.find_element_by_xpath('//*[@id="identifierNext"]').click()
time.sleep(3)
driver.find_element_by_xpath('//input[@type="password"]').send_keys(password)
driver.find_element_by_xpath('//*[@id="passwordNext"]').click()
time.sleep(2)


e = datetime.now()
day = e.strftime ( "%A" )
print ( day )

if day == "Monday":
    driver.get(joinmath())
    time.sleep(3000)
    driver.get(joinphy())
    time.sleep(3000)
    driver.get ( joinhistory() )
    time.sleep ( 3000 )
    driver.get ( joinenglish )

elif day == "Tuesday":
    driver.get ( joinmath() )
    time.sleep ( 3000 )
    driver.get ( joinhistory() )
    time.sleep ( 3000 )
    driver.get ( joinmal())
    time.sleep ( 3000 )
    driver.get ( joinbio() )

elif day == "Wednesday":
    driver.get ( joinchem() )
    time.sleep ( 180 )
    driver.get ( joinmath() )
    time.sleep ( 180 )
    driver.get ( joinenglish())
    time.sleep ( 180 )
    driver.get ( joinhindi() )

elif day == "Thursday":
    driver.get ( joinmath () )
    time.sleep ( 3000 )
    driver.get ( joinface () )
    time.sleep ( 3000 )
    driver.get ( joinenglish () )
    time.sleep ( 3000 )
    driver.get ( joinmal () )

elif day == "Friday":
    driver.get ( joinmath () )
    time.sleep ( 3000 )
    driver.get ( joingeo () )
    time.sleep ( 3000 )
    driver.get ( joinmal() )
    time.sleep ( 3000 )
    driver.get ( joinphy () )

elif day == "Saturday":
    print('its saturday bro lmao ')

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Start building today

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.