#填写主题#通过and连接更多的属性来唯一地标志一个元素driver.find_element_by_xpath("//input[@class='nui-ipt-input' and @maxlength='256']").send_keys(u'自动化测试')#填写正文#通过switch_to_frame()将当前定位切换到frame/iframe表单的内嵌页面中driver.switch_to_frame(driver.find_element_by_class_name('APP-editor-iframe'))#在内嵌页面中定位邮件内容位置
#通过switch_to().default_content()跳回最外层的页面#注:不要写成switch_to().default_content(),否则报AttributeError: SwitchTo instance has no __call__ methoddriver.switch_to.default_content()#driver.switch_to.parent_frame()
#点击发送time.sleep(3)#有可能存在元素不可见(查看元素是灰色的),会报ElementNotVisibleException错误#包含发送二字的元素很多,所以还得再加上其他限制#sendemails=driver.find_element_by_xpath("//span[contains(text(),'发送')]")sendemails=driver.find_element_by_xpath("//span[contains(text(),'发送') and @class='nui-btn-text']")time.sleep(3)#校验邮件是否发送成功try: