forked from kekewind/Kaleidoscope
-
Notifications
You must be signed in to change notification settings - Fork 0
/
getlatestwebdriver.py
25 lines (23 loc) · 1.27 KB
/
getlatestwebdriver.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import MyUtils
new='edge'
def main():
root=r'D:\standardizedPF\python\310'
root=MyUtils.standarlizedPath(root)
if new=='chrome':
page=MyUtils.Edge('https://chromedriver.chromium.org/downloads')
href=page.element('/html/body/div[1]/div/div[2]/div[3]/div/div[1]/section[2]/div[2]/div/div/div/div/div/div/div/div/ul[1]/li[2]/p/a/@href')
page.get(href)
el=page.element('/html//table//a[text()="chromedriver_win32.zip"]')
href=el.get_attribute('href')
MyUtils.pagedownload(href,root+'/chromedriver_win32.zip',overwrite=True)
MyUtils.unzip(root+'/chromedriver_win32.zip')
MyUtils.move(root+'/chromedriver_win32/chromedriver.exe',root+'/chromedriver.exe',overwrite=True)
if new=='edge':
page=MyUtils.Chrome('https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/')
href=page.element('//*[@id="downloads-channel"]//a[contains(@aria-label,"stable channel")and contains(@aria-label,"x64")]/@href')
MyUtils.pagedownload(href,root+'/edgedriver_win64.zip',overwrite=True,auto=True)
MyUtils.unzip(root+'/edgedriver_win64.zip')
MyUtils.move(root+'/edgedriver_win64/msedgedriver.exe',root+'/msedgedriver.exe',overwrite=True)
page.quit()
if __name__ == '__main__':
main()