标签:pycha bin file chrome usr get 需要 software toc
# #!/usr/bin/python3
# -*- coding: utf-8 -*-
# @Time : 2020/7/24 15:32
# @Author : Gengwu
# @FileName: By_css_seleclor.py
# @Software: PyCharm
from selenium import webdriver
from time import sleep
driver=webdriver.Chrome()
#driver.get(‘https://www.baidu.com/‘)
#1:通过id来定位
#driver.find_element_by_css_selector("#kw").send_keys("seleniumw我要自学网") #dlement后面不需要s,通过id来定位前面需要加#号+id
#2:通过class来定位
#driver.find_element_by_css_selector(‘.s_ipt‘).send_keys(‘seleniumw我要自学网‘) #class来定位,class前面+.
#3:通过属性来定位
#driver.find_element_by_css_selector("[autocomplete=‘off‘]").send_keys(‘seleniumw我要自学网‘) #属性要在[]里面
sleep(2)
driver.find_element_by_id(‘su‘).click()
sleep(2)
driver.quit()
Selenium之find_element_by_css_selector三种定位方法,附代码!
标签:pycha bin file chrome usr get 需要 software toc
原文地址:https://www.cnblogs.com/gengwulovestudy/p/13373151.html