一、 window
from selenium import webdriver
from selenium.webdriver.common.by import By
import time
chrome = webdriver.Chrome()
url='https://www.12306.cn/index/'
chrome.get(url)
print(chrome.window_handles)
print('0===>',id(chrome.window_handles[0]))
chrome.switch_to.window(chrome.window_handles[-1])
start=chrome.find_element("xpath",'//*[@id="fromStationText"]')
start.click()
chrome.find_element('xpath','//*[@id="ul_list1"]/li[32]').click()
end=chrome.find_element("xpath",'//*[@id="toStationText"]')
end.click()
chrome.find_element('xpath','//*[@id="ul_list1"]/li[9]').click()
chrome.find_element('xpath','//*[@id="isStudentDan"]').click()
chrome.find_element('id','search_one').click()
default = chrome.current_window_handle
chrome.switch_to.window(chrome.window_handles[-1])
chrome.find_element('id','search-input').send_keys('北京')
time.sleep(2)
chrome.switch_to.window(default)
chrome.find_element('id','search-input').send_keys('长沙')
二、iframe
from selenium import webdriver
from time import sleep
chrome = webdriver.Chrome()
chrome.get('https://mail.qq.com/')
chrome.implicitly_wait(5)
d=chrome.find_element('id','login_frame')
chrome.switch_to.frame(d)
chrome.find_element('xpath','//*[@id="u"]').send_keys('123')
sleep(2)
chrome.switch_to.default_content()
chrome.find_element('link text','帮助中心').click()
三、鼠标悬停
from selenium import webdriver
from selenium.webdriver import ActionChains
from time import sleep
chrome = webdriver.Chrome()
chrome.get('https://www.baidu.com/')
chrome.maximize_window()
d=chrome.find_element('id','s-usersetting-top')
ActionChains(chrome).move_to_element(d).perform()
chrome.find_element('xpath','//*[@id="s-user-setting-menu"]/div/a[1]').click()
sleep(2)
chrome.find_element('xpath','//*[@id="se-setting-7"]/a[2]').click()
sleep(2)
chrome.switch_to.alert.accept()
sleep(2)
chrome.quit()
四、 jenkins定时构建语法
* * * * *
(五颗星,中间用空格隔开)
第一个*表示分钟,取值0~59
第二个*表示小时,取值0~23
第三个*表示一个月的第几天,取值1~31
第四个*表示第几月,取值1~12
第五个*表示一周中的第几天,取值0~7,其中0和7代表的都是周日
每天下午下班前18点定时构建一次
0 18 * * *
每天早上8点构建一次
0 8 * * *
每30分钟构建一次:
H/30 * * * *
每2个小时构建一次
H H/2 * * *
每天早上 8点 12点 22点多个时间点进行构建
* 08,12,22 * * *