python+selenium下弹窗alter对象处理02
首先使用switch_to.alert()方法进行定位,然后可以使用下面的操作 text:返回alert、confirm、prompt中的文字信息; accept():接受现有警告框; dismiss():解散现有警告框; send_keys():在警告框中输入文本(如果可以输入的话); --------------------------------------------------------------------------------------- from selenium import webdriver
from selenium.webdriver.common.action_chains import ActionChains
from time import sleep driver = webdriver.Firefox() # 指定和打开浏览器
driver.get('http://www.baidu.com') link = driver.find_element_by_link_text("设置")
ActionChains(driver).move_to_element(link).perform() #鼠标悬停在上面
sleep(5)
driver.find_element_by_class_name("setpref").click() #点击高级搜索 sleep(5)
driver.find_element_by_class_name('prefpanelgo').click() #点击保存 sleep(5)
print(driver.switch_to.alert.text) #获取打印警告框里面的内容 sleep(5)
driver.switch_to.alert.accept() #点击确定 sleep(5)
driver.close()
python+selenium下弹窗alter对象处理02的更多相关文章
- python+selenium下弹窗alter对象处理01
alt.accept() : 等同于单击“确认”或者“OK” alt.dismiss() : ...
- python selenium下拉框定位
一.前言 总结一下python+selenium select下拉选择框定位处理的两种方式,以备后续使用时查询: 二.直接定位(XPath) 使用Firebug找到需要定位到的元素,直接右键复制XPa ...
- Python+Selenium学习--定位一组对象
场景 从上一节的例子中可以看出,webdriver可以很方便的使用find_element方法来定位某个特定的对象,不过有时候我们却需要定位一组对象,这时候就需要使用find_elements方法. ...
- Python+selenium下拉菜单选项
案例:在我要自学网登录页面选择要保留的时间 具体页面如图所示: 使用前端工具查看部分页面代码: <select class="loinp" name="Cookie ...
- python selenium 多个页面对象类使用同一个webdriver(即只打开一个浏览器窗口)
1 class BasePage(): 2 """selenium基类""" 3 4 def __init__(self, driver=N ...
- python selenium 下拉框
下拉框的处理如下代码: 定位select有很多种方式,这里介绍两种定位方式 1.二次定位 先定位到下拉框:self.dr.find_element_by_css_selector('#business ...
- python+selenium元素定位之XPath学习02
XPath 语法 XPath 使用路径表达式来选取 XML 文档中的节点或节点集.节点是通过沿着路径 (path) 或者步 (steps) 来选取的. XML 实例文档 我们将在下面的例子中使用这个 ...
- python+selenium元素定位之CSS学习02
参考文档:https://www.runoob.com/cssref/css-selectors.html CSS选择器用于选择你想要的元素的样式的模式. "CSS"列表示在CSS ...
- Python+selenium之弹窗
随机推荐
- 清楚webView的缓存
+(void)clearCache{ NSHTTPCookie *cookie; NSHTTPCookieStorage *storage = [NSHTTPCookieStorage s ...
- java 死锁演示
java 死锁演示 java死锁 模拟死锁生成 死锁是由多个线程竞争同一个资源导致 package com.feshfans; /** * 1. 本代码为展示 java 中死锁的产生 * 2. 死锁的 ...
- 微信小程序-自制弹出框禁止页面上下滑动
弹出 fixed 弹窗后,在弹窗上滑动会导致下层的页面一起跟着滚动. 解决方法: 在弹出层加上 catchtouchmove 事件 两种方法:(在电脑上测试是没有用的,这是触摸事件.因此,需要在手机端 ...
- selenium操作下拉选和网页提示框
import time from selenium import webdriver from selenium.webdriver.support.select import Select#处理下拉 ...
- java 责任链接模式
- GitHub上传项目时——解决failed to push some refs to git
原文地址:https://jingyan.baidu.com/article/f3e34a12a25bc8f5ea65354a.html 遇到的问题: error: failed to push so ...
- ESP8266网络介绍
仔细分析上图,根据功能区分,可以分为: Arduino功能,把ESP8266 当做 Arduino来使用 SD —— SD卡库 Servo —— 伺服电机库 Wire —— I2C库 SPI —— s ...
- 【NOIP2016提高A组模拟8.17】(雅礼联考day1)总结
考的还ok,暴力分很多,但有点意外的错误. 第一题找规律的题目,推了好久.100分 第二题dp,没想到. 第三题树状数组.比赛上打了个分段,准备拿60分,因为时间不够,没有对拍,其中有分段的20分莫名 ...
- 模板_BIT
#include<bits/stdc++.h> #define maxn 500005 //#define int long long using namespace std; inlin ...
- You have 1 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): shopadmin. Run 'python manage.py migrate' to apply them.
数据库迁移时报错, You have 1 unapplied migration(s). Your project may not work properly until you apply the ...