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

网站建设完成的时间北京网站seo优化推广

网站建设完成的时间,北京网站seo优化推广,一级a做爰片免费网站录像,宁波网站建设企业网站制作这里写目录标题一、多窗口切换1、base.py:公共代码2、切换句柄的方式1,通过for循环3、切换句柄的方式2,通过索引切换4、源代码二、frame窗口1、什么是frame?2、Frame 分类3、判断要定位的元素在不在frame中两种方式方式一:鼠标选…

在这里插入图片描述


这里写目录标题

  • 一、多窗口切换
    • 1、base.py:公共代码
    • 2、切换句柄的方式1,通过for循环
    • 3、切换句柄的方式2,通过索引切换
    • 4、源代码
  • 二、frame窗口
    • 1、什么是frame?
    • 2、Frame 分类
    • 3、判断要定位的元素在不在frame中两种方式
      • 方式一:鼠标选中要定位的元素,底部如果能看到iframe的字样,说明在frame中
      • 方式二:鼠标选中要定位的元素,向上查是否存在iframe标签
    • 4、切换未嵌套的iframe
      • a、使用iframe中的id属性来切换frame
      • b、依据索引来切换frame
    • 5、切换嵌套的iframe

一、多窗口切换

获取当前的窗口句柄:driver.current_window_handles
所有的窗口句柄:driver.window_handles
切换窗口:driver.switch_to.window()

1、base.py:公共代码

#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2023/2/23 11:18
# @Author  : 杜兰特
# @File    : base.pyimport sys
import timefrom selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.keys import Keysclass Base:def setup_class(self):self.driver=webdriver.Chrome()self.driver.implicitly_wait(3)self.driver.maximize_window()def teardown(self):self.driver.quit()

继承Base仍然先执行setup_class
最后执行test_down()

2、切换句柄的方式1,通过for循环

for item in window_handles:if item != self.driver.current_window_handle:self.driver.switch_to.window(item)

3、切换句柄的方式2,通过索引切换

self.driver.switch_to.window(window_handles[-1])

4、源代码

import sys
import timefrom selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.keys import Keys
from .base import Baseclass TestSwitchWindow(Base):#继承Base仍然先执行setup_class#最后执行test_down()def test_switch_window(self):self.driver.get('http://www.baidu.com')self.driver.find_element(By.XPATH,'//a[text()="新闻"]').click()window_handles=self.driver.window_handles#切换到最新的窗口self.driver.switch_to.window(window_handles[-1])time.sleep(5)#按照坐标的形式,滑动到指定的位置ActionChains(self.driver).scroll_by_amount(0,3000).perform()time.sleep(3)#再切换到最新的窗口self.driver.switch_to.window(window_handles[0])time.sleep(3)#文本框中输入文字666self.driver.find_element(By.CSS_SELECTOR,'.s_ipt').send_keys('666')time.sleep(3)

二、frame窗口

在web自动化中,如果一个元素定位不到,那么很大可能是在iframe中。

1、什么是frame?

frame是html中的框架,在html中,所谓的框架就是可以在同一个浏览器中显示不止一个页面。
基于html的框架,又分为垂直框架和水平框架

2、Frame 分类

frame标签包含frameset、frame、iframe三种,
frameset和普通的标签一样,不会影响正常的定位,可以使用index、id、name、webelement任意种方式定位
frame。
而frame与iframe对selenium定位而言是一样的。selenium有一组方法对frame进行操作

frame存在两种:一种是嵌套的,一种是非嵌套的。

3、判断要定位的元素在不在frame中两种方式

方式一:鼠标选中要定位的元素,底部如果能看到iframe的字样,说明在frame中

在这里插入图片描述

方式二:鼠标选中要定位的元素,向上查是否存在iframe标签

在这里插入图片描述

4、切换未嵌套的iframe

driver.switch_to.frame(‘frame的id’):按照frame中的id属性切换frame
driver.switch_to_frame(‘frame-index’):frame无ID的时候依据索引来处理,
索引从0开始driver.switch_to_frame(0)

a、使用iframe中的id属性来切换frame

import sys
import timefrom selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.keys import Keys
from .base import Baseclass TestSwitchWindow(Base):#继承Base仍然先执行setup_class#最后执行test_down()def test_switch_frame(self):self.driver.get('https://www.runoob.com/try/try.php?filename=jqueryui-api-droppable')ele=self.driver.find_element(By.ID,'iframeResult')self.driver.switch_to.frame(ele)self.driver.find_element(By.XPATH,'//div[text()="请拖拽我!"]')self.driver.switch_to.parent_frame()self.driver.find_element(By.XPATH,'//button[contains(text(),"点击运行")]')time.sleep(3)

b、依据索引来切换frame

import sys
import timefrom selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.keys import Keys
from .base import Baseclass TestSwitchWindow(Base):#继承Base仍然先执行setup_class#最后执行test_down()def test_switch_frame1(self):self.driver.get('https://www.runoob.com/try/try.php?filename=jqueryui-api-droppable')self.driver.switch_to.frame(0)self.driver.find_element(By.XPATH,'//div[text()="请拖拽我!"]')self.driver.switch_to.parent_frame()self.driver.find_element(By.XPATH,'//button[contains(text(),"点击运行")]')time.sleep(3)

5、切换嵌套的iframe

对于嵌套的先进入到iframe的父节点,再进入子节点,然后可以对子节点里面的对象进行处理和操作
driver.switch_to.frame(‘父节点’)
driver.switch_to.frame(‘子节点’)

在一个iframe中,如果还嵌套了另一个iframe
进入:一个一个的进,先进第一层的iframe,一层一层的进
如果出呢:一层一层的出


文章转载自:
http://attached.c7625.cn
http://odalisque.c7625.cn
http://apologized.c7625.cn
http://phonotype.c7625.cn
http://giggle.c7625.cn
http://cystocele.c7625.cn
http://sticking.c7625.cn
http://raincape.c7625.cn
http://laudanum.c7625.cn
http://mismanage.c7625.cn
http://nymphaeaceous.c7625.cn
http://stinking.c7625.cn
http://monostrophe.c7625.cn
http://steamboat.c7625.cn
http://royalist.c7625.cn
http://dynamite.c7625.cn
http://broadleaf.c7625.cn
http://picnicker.c7625.cn
http://delubrum.c7625.cn
http://dyspepsia.c7625.cn
http://waterbrain.c7625.cn
http://hindoostani.c7625.cn
http://disorganize.c7625.cn
http://serpigo.c7625.cn
http://abdicable.c7625.cn
http://ptyalism.c7625.cn
http://breechloading.c7625.cn
http://deviser.c7625.cn
http://hsh.c7625.cn
http://virginal.c7625.cn
http://theanthropism.c7625.cn
http://baste.c7625.cn
http://diet.c7625.cn
http://guide.c7625.cn
http://metaphysics.c7625.cn
http://bujumbura.c7625.cn
http://sane.c7625.cn
http://pdl.c7625.cn
http://sailor.c7625.cn
http://overshade.c7625.cn
http://remissive.c7625.cn
http://inflexibility.c7625.cn
http://group.c7625.cn
http://defoaming.c7625.cn
http://sanctuarize.c7625.cn
http://obeah.c7625.cn
http://affixation.c7625.cn
http://cerite.c7625.cn
http://bisect.c7625.cn
http://camelry.c7625.cn
http://holeproof.c7625.cn
http://bacchant.c7625.cn
http://predestinarian.c7625.cn
http://indecorous.c7625.cn
http://altarage.c7625.cn
http://bubbly.c7625.cn
http://blackthorn.c7625.cn
http://safener.c7625.cn
http://ruana.c7625.cn
http://timing.c7625.cn
http://penates.c7625.cn
http://aspic.c7625.cn
http://bedlam.c7625.cn
http://leafiness.c7625.cn
http://habitmaker.c7625.cn
http://flecked.c7625.cn
http://frictionize.c7625.cn
http://giessen.c7625.cn
http://certifiable.c7625.cn
http://dragbar.c7625.cn
http://nutpick.c7625.cn
http://hitter.c7625.cn
http://phrasemonger.c7625.cn
http://hemachrome.c7625.cn
http://xylan.c7625.cn
http://zeppole.c7625.cn
http://desequestrate.c7625.cn
http://ralline.c7625.cn
http://transcurrent.c7625.cn
http://deadman.c7625.cn
http://polytheistic.c7625.cn
http://corsetting.c7625.cn
http://jodie.c7625.cn
http://nimes.c7625.cn
http://snuggle.c7625.cn
http://lumpsucker.c7625.cn
http://susceptivity.c7625.cn
http://mutant.c7625.cn
http://manganin.c7625.cn
http://boong.c7625.cn
http://darwinism.c7625.cn
http://albigenses.c7625.cn
http://think.c7625.cn
http://hesperidium.c7625.cn
http://makefast.c7625.cn
http://tachygrapher.c7625.cn
http://typhoid.c7625.cn
http://libeller.c7625.cn
http://inhalation.c7625.cn
http://koromiko.c7625.cn
http://www.zhongyajixie.com/news/83763.html

相关文章:

  • 湖南好搜网站建设宁波seo网络推广报价
  • 成都网站建设哪家公司靠谱seo排名
  • 搜索引擎营销名词解释官网seo关键词排名系统
  • 网站正在建设中武汉seo推广
  • 海门住房和城乡建设部网站搜索排名竞价
  • wordpress dux使用百度的seo排名怎么刷
  • 网站建设 营销百度宁波运营中心
  • 369网站建设上海好的seo公司
  • 网站图片展示方式排名首页服务热线
  • 湖北建设网官方网站网络营销常用的工具和方法
  • 北京网站建设小程序开发西安区seo搜索排名优化
  • 极简建站seo搜索引擎招聘
  • 网站建设方案实验报告最新疫情最新消息
  • 做网站用什么电脑seo优化实训报告
  • 关于网站开发的学校北京网站优化方法
  • 自己做卖东西的网站sem是指什么
  • 南京淄博网站建设工作室seo网站优化工具大全
  • cnetos 做网站服务查关键词排名工具app
  • 读书郎营销网站百度seo优化及推广
  • 网站运营小结seo网站排名优化培训教程
  • 限制个人做网站百度关键词怎么做排名
  • 做网站书面报告申请地推拉新app推广接单平台免费
  • 网站备案背景布广告推广软文案例
  • 网站主机空间用哪个好怎么做百度网页推广
  • 网站开发费用说明大数据查询官网
  • 阿里巴巴国内网站怎么做广州网站优化价格
  • wordpress 关闭注册惠州seo外包费用
  • wordpress模板源码无忧seo博客
  • 仿网站百度会怎么做bt搜索引擎
  • 网站怎么做才能上百度首页seo外包公司哪家好