1、iframe的切入和切出

#切入
driver.switch_to.frame(driver.find_element_by_id('iFrame_1'))
# 切换出来
driver.switch_to.default_content()

  

2、句柄的切入和切出

main_windows = driver.current_window_handle
# 获取主窗口句柄
# main_handle = driver.current_window_handle
''' 指纹采集 '''
# 点击采集指纹 新页面
driver.find_element_by_xpath("//input[@id='button_20']").click() time.sleep(3)
# url_1 = "http://192.168.14.249/ywbl/jbyw/dzhz/CheckZw/007001007001334/$B/19940403/1560481330594" # 切换到最小弹出的窗口Windows的最后一个元素
# windows = driver.window_handles
# driver.switch_to.window(windows[-1]) # 切换回主窗口
all_windows = driver.window_handles
print(all_windows)
# 切换进注册页面
for handle in all_windows:
if handle != main_windows:
driver.switch_to.window(handle) # document.querySelector("#couseText").value='{}';
js = '''
document.querySelector('#couseText').value='{}';
'''.format("申请人未满十六周岁")
driver.execute_script(js) driver.find_element_by_xpath("//input[@id='OKButton']").click() rztext = driver.find_element_by_xpath("//span[@id='errorMsg']").get_attribute("value")
if rztext == '该数据已经做过指纹核验审批!':
driver.find_element_by_xpath("//input[@value='取 消']").click() time.sleep(5) # 重先定位到主页面,原来窗口
driver.switch_to.window(main_windows)
# 在切换到iframe里面才能找到下面的元素
driver.switch_to.frame(driver.find_element_by_id('iFrame_1'))

  

3、鼠标悬停

action = ActionChains(driver)
# 鼠标移动到该元素上,鼠标悬停,等待下拉框元素可见
ele = driver.find_element_by_xpath("//div[@id='fzgnbtZw']")
action.move_to_element(ele).perform()

  

4、鼠标定位移动点击

site = driver.find_element_by_xpath("//input[@title='输入关键字查询,双击显示前10条记录!']").location_once_scrolled_into_view
site1 = driver.find_element_by_xpath("//input[@title='输入关键字查询,双击显示前10条记录!']").location
windowsSite = driver.get_window_rect()
x,y = -1*site["x"],site1["y"]+windowsSite["y"]+10
time.sleep(1)
print(site,'\n',site1,'\n',windowsSite)
ActionChains(driver).move_by_offset(x,y).context_click().perform()

  

5、填下拉查询输入表使用延迟

driver.find_element_by_xpath(mainPath+"/input[@id='sbmacID']").send_keys("0021")
time.sleep(1)
driver.find_element_by_xpath("//div[@class='form-group']/div/div/div/input[@name='CODEVALUE_sblx']").send_keys("填表机")
time.sleep(1)
driver.find_element_by_xpath("//div[@class='form-group']/div/div/div/input[@id='CODEVALUE_lclxID']").send_keys("内地申请")
time.sleep(1)
driver.find_element_by_xpath("//input[@name='CODEVALUE_xzqh' and @id='CODEVALUE_xzqhID' and @class='form-control zd-input-sm input-sm form-control required']").send_keys("北京市辖区")
time.sleep(1)
driver.find_element_by_xpath("//div[@class='form-group']/div/div/input[@id='sbwzID']").send_keys("广州")

  

6、alert 弹框确定进行点击处理

# alert 点击弹框确定
Alert(driver).accept()

  

python selenium 实战涉及很多知识点的更多相关文章

  1. python+selenium 自动化测试实战

    一.前言: 之前的文章说过, 要写一篇自动化实战的文章, 这段时间比较忙再加回家过11一直没有更新博客,今天整理一下实战项目的代码共大家学习.(注:项目是针对我们公司内部系统的测试,只能内部网络访问, ...

  2. Python爬虫实战八之利用Selenium抓取淘宝匿名旺旺

    更新 其实本文的初衷是为了获取淘宝的非匿名旺旺,在淘宝详情页的最下方有相关评论,含有非匿名旺旺号,快一年了淘宝都没有修复这个. 可就在今天,淘宝把所有的账号设置成了匿名显示,SO,获取非匿名旺旺号已经 ...

  3. 第一章 python+selenium自动化测试实战

    @序章 自动化测试是软件测试的主流方向之一: 教程从测试的根本需求出发,讲解如何开展自动化测试. 首先,我们要明白,自动化仅仅是满足我们某种需求的一种工具:没有必要花费时间把它全部弄懂:我们只需要学会 ...

  4. 《一头扎进》系列之Python+Selenium自动化测试框架实战篇6 - 价值好几K的框架,呦!这个框架还真牛叉哦!!!

    1. 简介 本文开始介绍如何通过unittest来管理和执行测试用例,这一篇主要是介绍unittest下addTest()方法来加载测试用例到测试套件中去.用addTest()方法来加载我们测试用例到 ...

  5. 《一头扎进》系列之Python+Selenium框架实战篇7 - 年底升职加薪,年终奖全靠它!Merry Christmas

    1. 简介 截止到上一篇文章为止,框架基本完全搭建完成.那么今天我们要做什么呢????聪明如你的小伙伴或者是童鞋一定已经猜到了,都测试完了,当然是要生成一份高端大气上档次的测试报告了.没错的,今天宏哥 ...

  6. 学霸笔记系列 - Python Selenium项目实战(一)—— 怎么去验证一个按钮是启用的(可点击)?

    Q: 使用 Python Selenium WebDriver 怎么去验证一个按钮是启用的(可点击)? A:Selenium WebDriver API 里面给出了解决方法is_enabled() 使 ...

  7. bootstrap实战练习中涉及的知识点(很有用哦!)

    看的有关视频做的笔记,对bootstrap中涉及的知识点做了一定的解析,很有用哦!(新手上路,有不合适的地方可以指出哦!) 下面进入正题: Bootstrap是当下最流行的前端框架(界面工具集) 特点 ...

  8. 《Python开发实战》

    <Python开发实战> 基本信息 作者: (日)BePROUD股份有限公司 译者: 盛荣 丛书名: 图灵程序设计丛书 出版社:人民邮电出版社 ISBN:9787115320896 上架时 ...

  9. 历时一年《Python自动化测试实战》终于出版!!!

    一.为什么会写这本书 1.系统梳理.可以加深自己对测试知识体系的系统梳理 2.名气.增加个人的名气,比如:面试时,可以很自豪的说,我是xxxx书的作者 3.利他.帮助有需要的学习者更系统.完备的学习和 ...

随机推荐

  1. JAVA-产生唯一32位GUID

    import java.net.*; import java.util.*; import java.security.*; import org.apache.log4j.Logger; /** * ...

  2. HDU-4513-完美队形2(Manacher变形)

    链接: http://acm.hdu.edu.cn/showproblem.php?pid=4513 题意: 吉哥又想出了一个新的完美队形游戏! 假设有n个人按顺序站在他的面前,他们的身高分别是h[1 ...

  3. [Functional Programming] Examples: When and Unless

    /** * When */ const _branch = (x) => { const result = (x && x.isPublic) ? dissoc('private ...

  4. 【Winfrom-禁止重复启动程序】 程序不能重复启动

    using System; using System.Collections.Generic; using System.Linq; using System.Reflection; using Sy ...

  5. 在Ubuntu 18.04系统中蓝牙鼠标连接失败问题的解决

    2018-08-22 16:00:35作者:谖瓞稿源:linux站 如果你在Ubuntu 18.04操作系统中有蓝牙鼠标连接失败问题,那就参考下面的解决方法处理. 解决方法 首先在系统终端下输入: b ...

  6. Confluence 6.15 使用附件宏

    希望添加附件宏到一个页面中: 从编辑工具栏中,选择 插入(Insert)   > 其他宏(Other Macros) 找到并且选择需要的宏. 可用使用自动完成加快这个过程:输入 { 然后开始输入 ...

  7. Ubuntu完全删除nginx

    1.删除nginx,-purge包括配置文件 sudo apt-get --purge remove nginx 2.移除全部不使用的软件包 sudo apt-get autoremove 3.罗列出 ...

  8. Http请求优化

    Http请求优化 我们在做项目开发或多或少的都会使用SpringCloud,其中做远程调度的时候会将HTTP请求Http请求优化. HTTP请求Client存在很多种. JDK原生的URLConnec ...

  9. Python基于Pymssql模块实现连接SQL Server数据库的方法

    首先,安装pymssql第三方库pip install pymssql 其次,导入pymssql库 最后们就可以连接数据库了 import pymssql server = "10.10.9 ...

  10. Java-数据类型与编码(ASCII、Unicode 和 UTF-8)

    机械硬盘硬件结构(了解)https://diy.pconline.com.cn/cpu/study_cpu/1009/2215404_all.html 一.数据储存单位 1.bit(位) https: ...