selenium switch_to.frame

# -*- coding:utf-8 -*-

from selenium import webdriver


class Login():
    def userLogin(self,driver):
        driver =webdriver.Firefox()
        driver.implicitly_wait(10)
        driver.get("http://www.126.com")

        driver.switch_to.frame('x-URS-iframe')
        driver.find_element_by_name("email").clear()
        driver.find_element_by_name('email').send_keys("yourname")
        driver.find_element_by_name('password').clear()
        driver.find_element_by_name('password').send_keys('yourpassword')
        driver.find_element_by_id('dologin').click()

    def userLogout(self,driver):
        driver.find_element_by_link_text('退出').click()
        driver.quit()

你可能感兴趣的:(python)