打开
driver = webdriver.Chrome()
#打开相应的网页
driver.get(‘http://passport2.chaoxing.com/login?fid=&refer=http://i.mooc.chaoxing.com’)
登录
name = ‘用户名’
password = ‘密码’
yanzhengma = input(‘请输入验证码:’)
#找到登陆输入框
input_name = driver.find_element_by_id(‘unameId’)
input_password = driver.find_element_by_id(‘passwordId’)
input_yanzheng = driver.find_element_by_id(‘numcode’)
#向登陆输入框中输入值
input_name.send_keys(name)
input_password.send_keys(password)
input_yanzheng.send_keys(yanzhengma)
time.sleep(1)
#找到登陆按钮
button = driver.find_element_by_class_name(‘zl_btn_right’)
#模拟点击
button.click()
跳转到考试界面
time.sleep(1)
#跳转到该页的子Fream,拿到对应的网页源码
driver.switch_to.frame(‘frame_content’)
time.sleep(2)