I am trying to send email automatically from my office outlook web app. I have successfully automated the login process of outlook. But after login, there is no inspect element on new tab for sending mail. So how can i click on this new tab with selenium. Do i need to use some other framework for that.
Flow of automation is: Selenium will first click on webapps->email->india after that login in outlook web app and outlook web app will open after login
here is my code: here is my code:class LoginTest(unittest.TestCase):
def setUp(self):
self.driver=webdriver.Firefox()
userName="username"
password="password"
self.driver.get("http://sparshv2/")
'''
aa=self.driver.switch_to.alert;
aa.send_keys(userName+ Keys.COMMAND + "t")
aa.send_keys(password+ Keys.COMMAND + "t")
aa.accept()
'''
def test_outlook(self):
driver=self.driver
userName="username"
password="password"
#time.sleep(10)
aa=driver.switch_to.alert;
#aa.authenticate(userName, password)
aa.send_keys(userName)
#aa.send_keys(Keys.TAB)
#ele_id=driver.execute_script("return window.document.activeElement.id")
#time.sleep(5)
aa.send_keys(password)
#aa.send_keys(Keys.TAB)
aa.accept()
web_apps_link="Web Apps"
emailId="Email **"
country="India"
webAppsElementId=WebDriverWait(driver,10).until(lambda driver:driver.find_element_by_link_text(web_apps_link))
webAppsElementId.click()
#time.sleep(20)
#webAppsElementId.send_keys(Keys.CONTROL + Keys.RETURN)
aa=driver.switch_to.alert;
aa.send_keys(userName+ str(KEY_ENTER))
aa.send_keys(password+ str(KEY_ENTER))
aa.accept()
ahdElementId=WebDriverWait(driver,10).until(lambda driver:driver.find_element_by_partial_link_text(emailId))
ahdElementId.click()
#time.sleep(20)
driver.switch_to_window(driver.window_handles[1])
# country=input("You are from which country: india or outside india")
# if(country.lower()=="india"):
countryElementId=WebDriverWait(driver,10).until(lambda driver:driver.find_element_by_link_text(country))
countryElementId.click()
#elif(country.lower()=="outside india"):
# countryElementId=WebDriverWait(driver,20).until(lambda driver:driver.find_element_by_link_text("Overseas"))
# countryElementId.click()
driver.switch_to_window(driver.window_handles[2])
emailElementId = WebDriverWait(driver, 10).until(lambda driver: driver.find_element_by_id(userNameId))
emailElementId.clear()
emailElementId.send_keys(userName)
passwordElementId = WebDriverWait(driver, 10).until(lambda driver: driver.find_element_by_id(passwordId))
passwordElementId.clear()
passwordElementId.send_keys(password)
signElementId = WebDriverWait(driver, 10).until(lambda driver: driver.find_element_by_class_name(signInButton))
signElementId.click()