# coding=utf-8
'''
下拉框实战思路
导包:from selenium.webdriver.support.select import Select #下拉框select
from selenium.webdriver.common.action_chains import ActionChains #鼠标操作
先定位到下拉框-->>实例化Select类-->>实例化后调用select类的任何一个方法
定位方式分为索引 select_by_index()
value select_by_value()
文本 select_by_visible_text()
'''
from selenium import webdriver
from selenium.webdriver.support.select import Select #下拉框select
from selenium.webdriver.common.action_chains import ActionChains #鼠标操作
from time import sleep #索引定位实战
dr=webdriver.Chrome()
dr.maximize_window()
dr.implicitly_wait(30)
dr.get('http://www.baidu.com') #实现鼠标悬浮在百度首页的设置
ele=dr.find_element_by_xpath("//span[@class='setting-text']")
sleep(3)
ActionChains(dr).move_to_element(ele).perform()
sleep(3) #点击设置中的搜索设置按钮
dr.find_element_by_css_selector('.setpref').click()
sleep(3) #定位下拉框的元素属性
nr=dr.find_element_by_name('NR') #索引定位实战(先实例化select类)
select=Select(nr)
select.select_by_index(2) #value定位实战(先实例化select类)
select=Select(nr)
select.select_by_value('20') #文本定位实战(先实例化select类)
select=Select(nr)
select.select_by_visible_text('每页显示20条')

web自动化测试—selenium游览器下拉框操作的更多相关文章

  1. web自动化测试—selenium游览器多窗口操作

    # coding=utf-8'''web游览器多窗口操作: 获取当前窗口句柄 current_window_handle 获取所有窗口句柄 window_handles 切换窗口 switch_to_ ...

  2. Python3 Selenium自动化-select下拉框

    Python3 Selenium自动化-select下拉框 selenium介绍select下拉框相关的操作方法:

  3. selenium - 下拉框操作

    # 9. 下拉框操作# (1)等待下拉列表和下拉列表中值存在# (2)在下拉列表中选择一个值 # 三种方式# A. 获取所有的下拉列表值,然后用循环去匹配相同的值 select_by_index(下标 ...

  4. selenium基础(下拉菜单操作)

    selenium基础(下拉菜单操作) 非select/option元素: 1.触发下拉列表出现 2.等待下拉列表中的元素出现,然后进行选择元素即可. select/option元素: 下拉框操作-Se ...

  5. jQuery下拉框操作系列$("option:selected",this) &&(锋利的jQuery)

    jQuery下拉框操作系列$("option:selected",this)  &&(锋利的jQuery) <!DOCTYPE html> <ht ...

  6. selenium中的下拉框处理模块Select

    在UI自动化测试过程中,经常会遇到一些下拉框,如果我们基于Webdriver操作的话就需要click两次,而且很容易出现问题,实际上Selenium给我们提供了专门的Select(下拉框处理模块). ...

  7. python+selenium七:下拉框、选项框、select用法

    # from selenium import webdriverfrom selenium.webdriver.common.action_chains import ActionChainsimpo ...

  8. Java+selenium 如何定位下拉框select

    场景:需要进行下拉选择定位元素.   一.select菜单       select也是比较常见的,selenium封装了以下方法, 创建select WebElement selector = dr ...

  9. selenium select 选择下拉框

    实战百度首页设置,浏览偏好设置. 打开首页,在非登录的情况下,查看分析页面元素,我们可以看到,我们首先要点击的是设置, 接着点击,搜索设置, 然后select选择下拉框. select_by_inde ...

随机推荐

  1. <Zookeeper>入门 概念

    分布式协调服务 Zookeeper 分布式环境的特点 1.分布性 基于一个硬件或者多个硬件设备以及多个软件组成的分布在不同网络计算机上的系统架构,通过消息传递进行通信协调.在空间上部署是可以任意的,网 ...

  2. 洛谷 3833 SHOI 2012 魔法树

    [题解] 树链剖分模板题.. #include<cstdio> #include<algorithm> #include<queue> #define N 5000 ...

  3. codeforces 373 A - Efim and Strange Grade(算数模拟)

    codeforces 373 A - Efim and Strange Grade(算数模拟) 原题:Efim and Strange Grade 题意:给出一个n位的实型数,你可以选择t次在任意位进 ...

  4. clipboard.js兼容ios

    再使用clipboard.js做项目时,项目需求是在非input,button等可以点击的标签(span,p,div)上实现点击来复制内容,在PC端和移动端android没问题,但是到了ios毫无反应 ...

  5. 【Codeforces 1036C】Classy Numbers

    [链接] 我是链接,点我呀:) [题意] 让你求出只由3个非0数字组成的数字在[li,ri]这个区间里面有多少个. [题解] 只由3个非0数字组成的数字在1~10^18中只有60W个 dfs处理出来之 ...

  6. Neo4j 的一些使用心得

    由对图数据的处理需求,看到了图数据库(GraphDataBase)这种比较新的数据库模式,并且通过比较发现用的相对多的要属Neo4j了,现在来看网上对Neo4j的介绍还比较少,内容主要来源于三个地方: ...

  7. 通过代码学习python之@property,@staticmethod,@classmethod

    URL: https://www.the5fire.com/python-property-staticmethod-classmethod.html #coding=utf-8 class MyCl ...

  8. 6、Java并发性和多线程-并发性与并行性

    以下内容转自http://tutorials.jenkov.com/java-concurrency/concurrency-vs-parallelism.html(使用谷歌翻译): 术语并发和并行性 ...

  9. Maticsoft Code Generator

    源码:https://github.com/easonjim/MaticsoftCodeGenerator bug提交:https://github.com/easonjim/MaticsoftCod ...

  10. HDFS2.0之简单总结

    新特性 NameNode支持HA 命名空间支持分区(Federation) 支持ViewFS 支持目录快照 支持权限ACL 支持缓存指定的文件 QJM实现名字节点HA (图片来源互联网) 命名空间分区 ...