练习1:使用数据驱动的方式,登录多个邮箱账号 login_info.txt: youxiang_99@163.com,XXXX youxiang_100@163.com,XXXX main.py: from selenium import webdriver import time with open("login_info.txt") as fp: for data in fp: username_data,password_data = data.strip().split(",") driver=webdriver.Ie(executable_path="c:\IEDriverServer") driver.get("http://mail.163.com") time.sleep(5) frame=driver.find_element_by_xpath("//iframe[@id='x-URS-iframe']") driver.switch_to_frame(frame) username=driver.find_element_by_xpath("//input[@placeholder='邮箱帐号或手机号' and @name='email']") password=driver.find_element_by_xpath("//input[@placeholder='密码']") submit_button=driver.find_element_by_xpath("//a[@id='dologin']") username.clear() password.clear() username.send_keys(username_data) password.send_keys(password_data) submit_button.click() time.sleep(15) driver.switch_to_default_content() assert u"退出" in driver.page_source driver.quit()