python+selenium输入中文编码问题(一)


#-*- coding: GB2312 -*-

#上面这一行是解决输入文本框中的问题
from selenium import webdriver
from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.common.keys import Keys
import time


browser = webdriver.Firefox() # Get local session of firefox
browser.get("http://XXXX.XXXX.com") # Load page

time.sleep(0.2)
username=browser.find_element_by_id("XXXX");
passwd=browser.find_element_by_id("XXXX");
submit=browser.find_element_by_id("XXXX")

username.send_keys("XXXX")

passwd.send_keys("XXXX")

time.sleep(0.2) # Let the page load, will be added to the API
submit.click()


print("Login Success!")
time.sleep(2)


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM