selenium-1-python

Posted kylingx

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了selenium-1-python相关的知识,希望对你有一定的参考价值。

python selenium

from selenium import webdriver
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.support.select import Select
import time
path = r'D:seleniumchromedriver_win32chromedriver.exe'

链接跳转
def ithome():
    driver = webdriver.Chrome(path)
    driver.get('https://www.ithome.com')
    driver.find_element_by_css_selector('div.clearfix > div:nth-of-type(1) > a:first-child').click()
    time.sleep(1)
    driver.quit()

OA自动登录
def oalogon():
    driver = webdriver.Chrome(path)
    driver.get('http://ip/login/Login.jsp?logintype=1')
    driver.find_element_by_name('loginid').send_keys('user')
    driver.find_element_by_name('userpassword').send_keys('password')
    driver.find_element_by_css_selector('#login').click()
    driver.quit()

以上是关于selenium-1-python的主要内容,如果未能解决你的问题,请参考以下文章

VSCode自定义代码片段——CSS选择器

谷歌浏览器调试jsp 引入代码片段,如何调试代码片段中的js

片段和活动之间的核心区别是啥?哪些代码可以写成片段?

VSCode自定义代码片段——.vue文件的模板

VSCode自定义代码片段6——CSS选择器

VSCode自定义代码片段——声明函数