Getting email id from a child window and paste in parent window to login and catching the error message
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.firefox.service import Service
from selenium.webdriver.support import expected_conditions
from selenium.webdriver.support.wait import WebDriverWait
service_obj= Service("C://Users//ancha//geckodriver-v0.33.0-win64//geckodriver.exe")
driver= webdriver.Firefox(service=service_obj)
driver.get("http://www.rahulshettyacademy.com//loginpagePractise/")
driver.find_element(By.CLASS_NAME, "blinkingText").click()
windowsOpened = driver.window_handles
driver.switch_to.window(windowsOpened[1])
driver.implicitly_wait(2)
message = driver.find_element(By.CSS_SELECTOR, ".red").text
# var= message.slice(message,"at")
print(message)
var = message.split()
# Variable containing the email
em = ""
print(var)
for i in var:
if "@" in i:
em = i
print(em)
driver.close()
driver.switch_to.window(windowsOpened[0])
driver.find_element(By.ID,"username").send_keys(em)
driver.find_element(By.ID,"password").send_keys(em)
driver.find_element(By.ID,"terms").click()
driver.find_element(By.ID,"signInBtn").click()
wait = WebDriverWait(driver,10)
wait.until(expected_conditions.visibility_of_element_located((By.CSS_SELECTOR, ".alert-danger")))
print(driver.find_element(By.CSS_SELECTOR, ".alert-danger").text)
Comments
Post a Comment