Python+Selenium基础1-6:Selenium常用函数

时间:2022-02-27 22:07:32

1.#coding=cp936代表国标2312,只能放前两行

from Selenium import webdriver引库

wd=webdriver.Firefox()启动浏览器

wd.get('https://www.baidu.com/')

baidu_keyword=wd.find_element_by_id('XX')

.................................................................._name('XX')

.................................................................._class_name('XX')

.................................................................._tag_name('XX')

.................................................................._link_text('XX')

.................................................................._partail_link_text('XX')

.................................................................._Xpath('XX')

.................................................................._css_selecrtor('XX')

baidu_keyword.send_keys(u'副哥杂记')这里的u代表unicode

wd.find_element_by_id('').click()

.clear()清空

wd.maximize()窗口最大化

wd.get('')跳转URL

wd.forward()前进

wd.back() 后退

wd.refresh()刷新


wd.quit()

.quit()关闭所有窗口

.close()关闭当前窗口