Article From:https://www.cnblogs.com/ppkq/p/9075525.html

#coding:gbk

from selenium import webdriver
from time import sleep
from selenium.webdriver.common.keys import Keys
browser=webdriver.Chrome()
url=’https://www.csdn.net’
browser.get(url)
browser.maximize_window()
sleep(3)

browser.find_element_by_link_text(‘Log in ‘).Click ()
sleep(2)
browser.find_element_by_link_text(‘Account login ‘).Click ()
sleep(2)

browser.find_element_by_id(“username”).clear()
browser.find_element_by_id(“username”).send_keys(‘11580****15@qq.com’) #Input account number
browser.find_element_by_id(“password”).clear()
browser.find_element_by_id(“password”).send_keys(‘AAA*****1995’)#Password
sleep(2)
browser.find_element_by_id(‘rememberMe’).send_keys(Keys.SPACE)#Remove the next automatic login
sleep(2)

browser.find_element_by_xpath(“//form[@id=’fm1′]/input[8]”).click() #Sign in
sleep(3)

browser.find_element_by_link_text(‘Blogging ‘).Click ()
sleep(3)

handles=browser.window_handles
browser.switch_to_window(handles[-1]) #switch windows
browser.find_element_by_xpath(‘/html/body/div/div/div/p/button’).click()
sleep(3)
browser.find_element_by_id(‘txtTitle’).send_keys(“Shenzhen weather “)
sleep(2)

sh=browser.find_element_by_xpath(“//iframe[@id=’xhe0_iframe’]”)
browser.switch_to_frame(sh)
sleep(2)
browser.find_element_by_xpath(“//html/body[@class=’editMode htmledit_views’]”).send_keys(“Very hot recently “)
sleep(2)
browser.switch_to_default_content() #Switch out the form
sleep(2)
browser.find_element_by_xpath(“//button[@id=’addTag’]”).click() #Article label
browser.find_element_by_xpath(“//div[@id=’articleTagBox’]/div/span”).send_keys(‘Shenzhen ‘)
sleep(2)
browser.find_element_by_xpath(“//button[@id=’addCategorie’]”).click()
browser.find_element_by_xpath(“//div[@id=’categorieBox’]/div/span”).send_keys(“python”)
sleep(2)

browser.find_element_by_id(‘selType’).click()#Dropdown box
browser.find_element_by_xpath(“//select[@id=’selType’]/option[2]”).click()
sleep(2)
browser.find_element_by_id(‘radChl’).click()
browser.find_element_by_xpath(“//select[@id=’radChl’]/option[6]”).click()
sleep(3)

browser.find_element_by_id(“btnPublish”).click()
sleep(3)
browser.quit()

Link of this Article: Micro-blog automation release

Leave a Reply

Your email address will not be published. Required fields are marked *