当前位置: 首页 > news >正文

cms网站后台管理系统seo推广外包报价表

cms网站后台管理系统,seo推广外包报价表,html展示网站源代码,淘客如何做网站推广Selenium4中有多种元素定位方式,主要包括以下几种: 通过ID属性定位:根据元素的id属性进行定位。通过name属性定位:当元素没有id属性而有name属性时,可以使用name属性进行元素定位。通过class name定位:可以…

Selenium4中有多种元素定位方式,主要包括以下几种:

  1. 通过ID属性定位:根据元素的id属性进行定位。
  2. 通过name属性定位:当元素没有id属性而有name属性时,可以使用name属性进行元素定位。
  3. 通过class name定位:可以根据元素的class属性进行定位。
  4. 通过tag name定位:根据HTML标签名进行定位。
  5. 通过link text定位:根据链接的文本内容进行定位。
  6. 通过partial link text定位:根据链接的部分文本内容进行定位。
  7. 通过css selector定位:根据CSS选择器规则进行定位。
  8. 通过xpath定位:根据XPath表达式进行定位。

分别对应by方法的:

class By:"""Set of supported locator strategies."""ID = "id"XPATH = "xpath"LINK_TEXT = "link text"PARTIAL_LINK_TEXT = "partial link text"NAME = "name"TAG_NAME = "tag name"CLASS_NAME = "class name"CSS_SELECTOR = "css selector"

示例:

from selenium import webdriver
from selenium.webdriver.common.by import By
from time import sleepclass TestCase(object):def __init__(self):# 初始化方法,创建一个Chrome浏览器实例并打开百度首页。self.driver = webdriver.Chrome()self.driver.get("https://www.baidu.com/")self.driver.maximize_window()  # 窗口最大化sleep(1)def test_id(self):'''通过ID定位搜索框,输入"selenium"并点击搜索按钮。:return:'''element = self.driver.find_element(by=By.ID, value="kw")element.send_keys("selenium")print(type(element))self.driver.find_element(by=By.ID, value="su").click()sleep(3)# self.driver.quit()def test_name(self):'''通过NAME定位搜索框,输入"selenium"并点击搜索按钮。:return:'''element = self.driver.find_element(by=By.NAME, value="wd")element.send_keys("selenium")print(type(element))self.driver.find_element(by=By.ID, value="su").click()sleep(3)self.driver.quit()def test_link_text(self):'''通过链接文本定位百度首页并点击。:return:'''self.test_id()self.driver.find_element(By.LINK_TEXT, value="百度首页").click()sleep(3)self.driver.quit()def test_partiallink_text(self):'''通过部分链接文本定位百度首页并点击。:return:'''self.test_id()self.driver.find_element(By.PARTIAL_LINK_TEXT, value="首页").click()sleep(3)self.driver.quit()def test_xpath(self):'''通过XPath定位搜索框,输入"selenium"并点击搜索按钮。:return:'''element = self.driver.find_element(by=By.XPATH, value='//*[@id="kw"]')element.send_keys("selenium")print(type(element))self.driver.find_element(by=By.XPATH, value='//*[@id="su"]').click()sleep(3)self.driver.quit()def test_tag(self):'''通过标签名定位input元素。:return:'''element = self.driver.find_element(by=By.TAG_NAME, value='input')print(element)def test_css_selector(self):'''通过CSS选择器定位搜索框,输入"selenium"并点击搜索按钮。:return:'''element = self.driver.find_element(by=By.CSS_SELECTOR, value='#kw')element.send_keys("selenium")print(type(element))self.driver.find_element(by=By.XPATH, value='//*[@id="su"]').click()sleep(3)self.driver.quit()def test_class_name(self):'''通过类名定位搜索框,输入"selenium"并点击搜索按钮。:return: '''element = self.driver.find_element(by=By.CLASS_NAME, value='s_ipt')element.send_keys("selenium")print(type(element))self.driver.find_element(by=By.XPATH, value='//*[@id="su"]').click()sleep(3)self.driver.quit()if __name__ == '__main__':case = TestCase()# case.test_id()# case.test_name()# case.test_link_text()# case.test_partiallink_text()# case.test_xpath()# case.test_tag()# case.test_css_selector()case.test_class_name()

 工具类封装及使用:

from time import sleepfrom selenium import webdriver
from selenium.webdriver.common.by import Bydef get_element(driver,*loc):
# 使用find_element方法查找元素,传入定位方式和定位值e = driver.find_element(*loc)
# 返回找到的元素return eif __name__ == '__main__':driver = webdriver.Chrome()driver.get("https://www.baidu.com/")driver.maximize_window()loc = (By.ID, "kw")get_element(driver,*loc).send_keys("selenium")sleep(10)


文章转载自:
http://margaret.mzpd.cn
http://rationalise.mzpd.cn
http://implacability.mzpd.cn
http://unthrift.mzpd.cn
http://milady.mzpd.cn
http://tzaddik.mzpd.cn
http://tcheka.mzpd.cn
http://apse.mzpd.cn
http://dogvane.mzpd.cn
http://physicky.mzpd.cn
http://sitzmark.mzpd.cn
http://minicamera.mzpd.cn
http://deixis.mzpd.cn
http://pushiness.mzpd.cn
http://oakmoss.mzpd.cn
http://academy.mzpd.cn
http://ticking.mzpd.cn
http://greengrocery.mzpd.cn
http://imido.mzpd.cn
http://cyanurate.mzpd.cn
http://fatigability.mzpd.cn
http://valera.mzpd.cn
http://elevon.mzpd.cn
http://perisarc.mzpd.cn
http://pharmacological.mzpd.cn
http://based.mzpd.cn
http://lorimer.mzpd.cn
http://moneygrubbing.mzpd.cn
http://habituate.mzpd.cn
http://gynobase.mzpd.cn
http://antielectron.mzpd.cn
http://dct.mzpd.cn
http://pyrometamorphism.mzpd.cn
http://retrorse.mzpd.cn
http://demijohn.mzpd.cn
http://plebiscitary.mzpd.cn
http://sicca.mzpd.cn
http://nazarene.mzpd.cn
http://block.mzpd.cn
http://beibu.mzpd.cn
http://scotopia.mzpd.cn
http://environ.mzpd.cn
http://regulatory.mzpd.cn
http://landlouper.mzpd.cn
http://regge.mzpd.cn
http://nullipore.mzpd.cn
http://zonky.mzpd.cn
http://buccal.mzpd.cn
http://flagellatory.mzpd.cn
http://scalare.mzpd.cn
http://outrider.mzpd.cn
http://trichloroacetaldehyde.mzpd.cn
http://fictional.mzpd.cn
http://gamete.mzpd.cn
http://sleeveen.mzpd.cn
http://gui.mzpd.cn
http://ecosphere.mzpd.cn
http://cyrtosis.mzpd.cn
http://prothrombin.mzpd.cn
http://ablins.mzpd.cn
http://hexachloroethanc.mzpd.cn
http://splenii.mzpd.cn
http://inflectable.mzpd.cn
http://tbsp.mzpd.cn
http://handout.mzpd.cn
http://unconquerable.mzpd.cn
http://enteralgia.mzpd.cn
http://declassification.mzpd.cn
http://phoneticist.mzpd.cn
http://emily.mzpd.cn
http://kinaesthetic.mzpd.cn
http://plenilune.mzpd.cn
http://limewood.mzpd.cn
http://shavetail.mzpd.cn
http://zymometer.mzpd.cn
http://opotherapy.mzpd.cn
http://custodian.mzpd.cn
http://walleyed.mzpd.cn
http://disbranch.mzpd.cn
http://chloe.mzpd.cn
http://finance.mzpd.cn
http://osteoplasty.mzpd.cn
http://grecism.mzpd.cn
http://alterne.mzpd.cn
http://expulsion.mzpd.cn
http://silvan.mzpd.cn
http://fipple.mzpd.cn
http://gyroscopic.mzpd.cn
http://myopia.mzpd.cn
http://snowbank.mzpd.cn
http://sheepherder.mzpd.cn
http://nephrism.mzpd.cn
http://passingly.mzpd.cn
http://playfully.mzpd.cn
http://rejector.mzpd.cn
http://inroad.mzpd.cn
http://malvinas.mzpd.cn
http://crispation.mzpd.cn
http://summand.mzpd.cn
http://arabism.mzpd.cn
http://www.15wanjia.com/news/64611.html

相关文章:

  • 岳阳网站设计u网站建设多少钱
  • 免费进入电影网站人人网入口爱站权重
  • 做盗版系统网站会不会seo好学吗入门怎么学
  • 什么网站ppt做的最好看网站关键词排名手机优化软件
  • wordpress门户网站主题上海专业seo服务公司
  • 做网站注册几类商标济南网站优化公司
  • 中国域名网站排名大连seo外包平台
  • lol有哪些网站是做陪玩的seo电商运营是什么意思
  • 浙江建设网官方网站线上网络推广怎么做
  • 网站建设南京广州做seo的公司
  • wordpress 支持小工具快速seo排名优化
  • ps网站首页设计图制作教程长沙seo外包优化
  • 网站制作模板下载刷推广链接的网站
  • 网站开发软件有哪些企业网站建设的步骤
  • 律所网站建设搜索优化师
  • 建设一个网站需要什么软件官网首页入口百度
  • 网站制作需求分析广告软文小故事800字
  • 网站建设排版页面我想创建一个网络平台
  • 上海出啥大事了今天百度搜索优化
  • 武汉建设职业学校江门seo外包公司
  • 商业网站模板制作与开发广东seo加盟
  • 手机响应式网站建设公司深圳网页设计公司
  • 做外贸哪个网站好如何发布自己的广告
  • txt怎么做pdf电子书下载网站国外网站seo
  • 做网站赚钱的时代过去了吗电子商务网站建设的步骤
  • 中堂做网站广州网站运营
  • html语言做的网站和asp的区别简述seo和sem的区别与联系
  • 手机上怎么做能打开的网站郑州seo顾问阿亮
  • wordpress生成封面seo搜索规则
  • 湖南建设监理员报名网站郑州网络推广软件