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

游戏平台网站微信如何分享wordpress

游戏平台网站,微信如何分享wordpress,付网站建设费分录,重庆seo什么意思像 Selenium 这样的自动化工具使我们能够通过不同的语言和浏览器自动化 Web 流程并测试应用程序。 Python 是它支持的众多语言之一#xff0c;并且是一种非常简单的语言。 它的Python客户端帮助我们通过Selenium工具与浏览器连接。 Web 测试对于开发 Web 应用程序至关重要并且是一种非常简单的语言。 它的Python客户端帮助我们通过Selenium工具与浏览器连接。 Web 测试对于开发 Web 应用程序至关重要但更重要的是它使我们能够自动化 Web 流程。 我们需要访问源代码并检查某些元素以自动化此类过程。 本文向您展示如何使用其 Python 客户端和 API 检查某个元素是否存在于 Selenium 中。 使用 find_element() 使用 Selenium Python 检查元素是否存在 要使用 Selenium Python 客户端我们需要通过以下 pip 命令安装其包 pip install selenium除了Python客户端之外如果我们要使用它们还需要安装其他工具例如ChromeDriver。 您可以相当轻松地下载并安装它。 现在我们可以使用 Selenium 模块及其 Exception 部分来检查元素是否存在。 首先我们使用 webdriver 模块访问浏览器代理Chrome并使用 get() 方法访问我们想要检查其元素的网页。 然后使用 find_element() 方法并传递 By.TAG_NAME 参数和要查找的元素例如 h2。 find_element() 方法使用 By 策略和定位器来查找元素。 在下面的代码中我们使用By.TAG_NAME策略来查找我们想要的元素。 我们还可以使用 By.CSS_SELECTOR 来查找元素。 from selenium import webdriver from selenium.webdriver.common.by import By from selenium.common.exceptions import NoSuchElementExceptiondriver webdriver.Chrome(executable_pathC:\chromedriver.exe) driver.implicitly_wait(0.5) driver.get(https://thehackernews.com/)try:element driver.find_element(By.TAG_NAME, h2)hackHead element.textprint(Element exist)print(hackHead) except NoSuchElementException:print(Element does not exist)driver.close()输出: DeprecationWarning: executable_path has been deprecated, please pass in a Service objectdriver webdriver.Chrome(executable_pathC:\chromedriver.exe)DevTools listening on ws://127.0.0.1:57551/devtools/browser/dce0d9db-6c42-402e-8770-13999aff0e79 Element exist Pay What You Want for This Collection of White Hat Hacking Courses我们获得了 Pay What You Want for This Collection of White Hat Hacking Courses 作为元素的内容但您可能会注意到可执行文件路径周围有一个 DeprecationWarning。 DeprecationWarning: executable_path has been deprecated, please pass in a Service objectdriver webdriver.Chrome(executable_pathC:\chromedriver.exe)为了解决这个问题我们需要安装 webdriver-manager 模块来使用 pip 命令处理浏览器交互。 pip install webdriver-manager然后使用以下语句将模块导入到您的代码中。 from webdriver_manager.chrome import ChromeDriverManager from selenium.webdriver.chrome.service import Service并使用service属性而不是executable_path并将 Service() 和 ChromeDriverManager() 方法传递给service属性。 driver webdriver.Chrome(serviceService(ChromeDriverManager().install()))现在代码变成 from selenium import webdriver from selenium.webdriver.common.by import By from selenium.common.exceptions import NoSuchElementException from webdriver_manager.chrome import ChromeDriverManager from selenium.webdriver.chrome.service import Servicedriver webdriver.Chrome(serviceService(ChromeDriverManager().install())) driver.implicitly_wait(0.5) driver.get(https://thehackernews.com/)try:l driver.find_element(By.TAG_NAME, h2)s l.textprint(Element exist - s) except NoSuchElementException:print(Element does not exist)driver.close()输出: [WDM] - Downloading: 100%|████████████████████████████████████████████████████████████████████████████████████████████████| 6.29M/6.29M [00:0300:00, 2.13MB/s]DevTools listening on ws://127.0.0.1:57442/devtools/browser/2856cae0-e665-42c3-a20d-a847d52658c1 Element exist Pay What You Want for This Collection of White Hat Hacking Courses因为这是第一次运行您可能会看到输出的 [WDM] 部分 否则只有 DevTools 消息和代码输出应该是可见的。 这样您可以使用其 Python 客户端轻松检查 Selenium 中是否存在某个元素。
http://www.hkea.cn/news/14482011/

相关文章:

  • 广州个人网站备案要多久如何制作企业网站的版式
  • 做网站哪里有中国企业网官网登录入口
  • 免费外国网站浏览器班级网页制作模板
  • 门户网站如何建设响应式网站做seo
  • 18款禁用网站app入口建 网站 是软件开发
  • 为什么建行网站打不开计算机培训机构排名前十
  • 28网站建设沈阳网站制作网页
  • 兰溪高端网站建设公司公司网站需要备案么
  • wordpress下载站模板下载互联网保险理赔到底有多难
  • 如何提高网站设计能力关于化妆品网页设计的模板
  • 网站定制开发怎么做如何在网站做投票
  • 萍乡做网站的公司长沙网站优化厂家
  • 有什么网站可以免费看电影哪有做企业网站
  • 邯郸市做网站的公司广东建设网工程信息网站
  • 运行一个网站要多少钱网站提供什么服务
  • 温江网站建设网站怎么做超链接
  • 镇海区建设交通局网站网站推广页面 英语
  • 如何做请求队列防止网站高并发网络营销与策划实务
  • 网站建设信息上海建溧建设集团有限公司网站
  • 潍坊做网站的企业wordpress 目录下拉框
  • 梅州市住房和城乡建设局官网网站洛阳网站开发公司
  • 莱阳网站定制电商美工工资一般多少
  • 网络科技公司门户网站傻瓜化免费自助建站
  • 上海高端网站建设公望野原文
  • 深圳市网站开发开发区网站建设在哪
  • 地方门户网站管理系统做网站导流
  • 营销型网站建设公司网络推广郴州网站建设价格
  • 网站做弹窗湿地公园网站建设
  • 做网站要服务器和什么漳州网站开发去博大钱少a
  • 网站开发投入产出分析58网站建设