The main issue I am not able to properly navigate to the login form and fill email and password to enable login button. I tried below code to fill the login form into www.moneycontrol.com but it seems little bit complicated. Login form is multi-layered,  hover or click "Hello, Login". click Log-in button inside floating form Login with password tab then fill email and password to enable login button.  Help is appreciated, code is from selenium import webdriver from selenium.webdriver.chrome.options import Options from selenium.webdriver.common.by import By from selenium.webdriver.common.keys import Keys import time import pandas as pd from io import StringIO from bs4 import BeautifulSoup chrome_options = Options() chrome_options.add_argument('--headless') chrome_options.add_argument('--no-sandbox') chrome_options.add_argument('--disable-dev-shm-usage') driver = webdriver.Chrome(options=chrome_options) driver.get('https://www.moneycontrol.com') email = "xxxxxxx@gmail.com" password = "Qxxxxxxx" # Click on the "Login" button print(driver.page_source) login_button = driver.find_element(By.XPATH, '//a[contains(text(), "Hello, Login")]') login_button.click() time.sleep(3) # Wait for login popup to appear # Click on the "Login" button login_button = driver.find_element(By.XPATH, '//a[contains(text(), "Log-in")]') login_button.click() time.sleep(3) # Wait for login popup to appear # Click on the "Login" button login_button = driver.find_element(By.XPATH, '//a[contains(text(), "Login with Password")]') login_button.click() time.sleep(3) # Wait for login popup to appear # Switch to login iframe if present try: iframe = driver.find_element(By.TAG_NAME, "iframe") driver.switch_to.frame(iframe) time.sleep(2) except: pass # If no iframe, continue normally # Enter email/username email_field = driver.find_element(By.CSS_SELECTOR, '#mc_login > form > div:nth-child(1) > div > input[type=text]') email_field.send_keys(email) # Enter password password_field = driver.find_element(By.CSS_SELECTOR, '#mc_login > form > div:nth-child(2) > div > input[type=password]') password_field.send_keys(password) # Click on Login button submit_button = driver.find_element(By.CSS_SELECTOR, '#mc_login button[type="submit"]') submit_button.click() # Wait for login to process time. Sleep(5)  website has too much ad, use ad blocker to avoid frustration
As others in the comment have mentioned, this site is plagued with popup ads. Instead of logging in from the main page, try the dedicated login URL. https://accounts.moneycontrol.com/mclogin You'll be able to log in easily using this URL. Then go to the main page. Your code has another problem. The site detects headless chrome and blocks access. You have to set the window size and user agent explicitly to avoid detection. Also, use explicit waits instead of sleep. That way you have to wait a minimum time. The site loads a promo URL first, then redirects to the main site. You have to navigate through the site using page URLs, instead of clicking on menus. That way you'll be able to avoid handling those annoying ads. Try the following code: from selenium import webdriver from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.chrome.options import Options from selenium.webdriver.common.by import By from selenium.webdriver.common.keys import Keys import time import pandas as pd from io import StringIO from bs4 import BeautifulSoup chrome_options = Options() chrome_options.add_argument('--headless') chrome_options.add_argument('----window-size=1980,1080') #set window size chrome_options.add_argument("--user-agent=Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.212 Safari/537.36") # Set user agent driver = webdriver.Chrome(options=chrome_options) wait = WebDriverWait(driver, 60) # Add explicit wait for minimum wait # First go to the login page driver.get('https://accounts.moneycontrol.com/mclogin') email = "xxxxxxx@gmail.com" password = "Qxxxxxxx" # Enter email/username email_field = driver.find_element(By.CSS_SELECTOR, "form#login_form input#email") email_field.send_keys(email) # Enter password password_field = driver.find_element(By.CSS_SELECTOR, "form#login_form input#pwd") password_field.send_keys(password) # Click on Login button submit_button = driver.find_element(By.CSS_SELECTOR, "form#login_form #ACCT_LOGIN_SUBMIT") submit_button.click() # Wait for authenticating screen wait.until(EC.presence_of_element_located((By.CSS_SELECTOR, "div.signinblock[style='display: block;']"))) print("logged in") # Go to main site driver.get('https://www.moneycontrol.com/') # wait for main site to load wait.until(EC.url_to_be('https://www.moneycontrol.com/')) print(driver.page_source) driver.quit() 