python+selenium

1339 단어 python 연습
# coding:utf-8
from selenium.webdriver.common.action_chains import ActionChains
import time
class Login():
    #   
    def user_login(self,driver,username,password):
        driver.find_element_by_xpath(
            "/html/body/div/div[1]/div[2]/div[3]/div[2]/form/div[1]/input[2]").clear()
        driver.find_element_by_xpath(
            "/html/body/div/div[1]/div[2]/div[3]/div[2]/form/div[1]/input[2]").send_keys(username)
        driver.find_element_by_xpath(
            "/html/body/div/div[1]/div[2]/div[3]/div[2]/form/div[2]/input[2]").clear()
        driver.find_element_by_xpath(
            "/html/body/div/div[1]/div[2]/div[3]/div[2]/form/div[2]/input[2]").send_keys(password)
        # driver.find_element_by_xpath("/html/body/div/div[1]/div[2]/div[3]/div[2]/form/div[4]/button").click()
        #    submit()    
        driver.find_element_by_xpath("/html/body/div/div[1]/div[2]/div[3]/div[2]/form/div[2]/input[2]").submit()

    #   
    def user_logout(self,driver):
        exit_1 = driver.find_element_by_xpath("/html/body/div/div[1]/div[2]/header/div[2]/div/p/span[1]")
        ActionChains(driver).move_to_element(exit_1).perform()
        exit_1.click()
        time.sleep(3)
        print("     ")
        driver.quit()

좋은 웹페이지 즐겨찾기