当前位置:网站首页>Alert pop-up processing in Web Automation
Alert pop-up processing in Web Automation
2022-06-28 06:07:00 【FamilyYan】
One 、 Pop up classification
(1)JS bounced
Click to confirm :alert.accept()
Click Cancel :alert.dismiss()
Get text content :text = alert.text
Assign a value to the pop-up box : alert.send_keys(“Emily”)
(2) Modal frame : Operate by element positioning ,( Trigger the modal box first , Then navigate to the element in the modal box 、 Operational elements )
Two 、 Code implementation



from selenium.webdriver.common.alert import Alert
from selenium import webdriver
import logging
import time
logging.basicConfig(level=logging.DEBUG)
# Start the browser driver server
driver = webdriver.Chrome()
# driver.get("https://www.w3school.com.cn/tiy/t.asp?f=eg_js_alert")
# driver.get("https://www.w3school.com.cn/tiy/t.asp?f=eg_js_confirm")
driver.get("https://www.w3school.com.cn/tiy/t.asp?f=eg_js_prompt")
driver.maximize_window()
time.sleep(2)
# Switch iframe
driver.switch_to.frame("iframeResult")
time.sleep(2)
driver.find_element_by_xpath('//button[text()=" Have a try "]').click()
time.sleep(2)
alert = Alert(driver) # I am a warning box !
# Get text content
text = alert.text
print(text)
alert.send_keys("Emily")
time.sleep(5)
# Click to confirm
alert.accept()
# Click Cancel
# alert.dismiss()
边栏推荐
- Caused by: com.fasterxml.jackson.databind.exc.InvalidFormatException:异常解决
- Alibaba cloud SMS service (Complete Guide), SMS sending function implementation.
- The length of pytorch dataloader the difference between epoch and iteration
- JQ picture amplifier
- AutoCAD C # Polyline Small Sharp angle Detection
- 异常处理(一)——空指针和数组索引越界
- Pre training model parameter mismatch
- High quality domestic stereo codec cjc8988, pin to pin replaces wm8988
- Capacity scheduling absolute value configuration queue usage and pit avoidance
- Use of JDBC
猜你喜欢

【Paper Reading-3D Detection】Fully Convolutional One-Stage 3D Object Detection on LiDAR Range Images

Binder interview: memory management unit

ES9023音频解码芯片的工作原理

Apple MDM bypass jailfree bypass MDM configuration lock free

19 fonctions de perte d'apprentissage profond

mac下安装多个版本php并且进行管理

6. 毕业设计温湿度监控系统(ESP8266 + DHT11 +OLED 实时上传温湿度数据给公网服务器并在OLED显示屏上显示实时温湿度)

Working principle of es9023 audio decoding chip

YYGH-BUG-02

Capacity scheduling absolute value configuration queue usage and pit avoidance
随机推荐
Alibaba cloud SMS service (Complete Guide), SMS sending function implementation.
Use the SQL SELECT count distinct query statement to count the total number of unique values of a field in the database
阿里云短信服务(完整指南),短信发送功能实现。
death_ satan/hyperf-validate
EasyUI reset multi condition query
脚本语言和编程语言
MySQL(二)——基本操作
YYGH-BUG-02
ipvs 导致syn 重传问题
Common basic functions of Oracle
YYGH-BUG-03
Main functions of 5ggnb and ng ENB
Relevant implementation records of CSI and local disk
Using pytorch and tensorflow to calculate the confusion matrix of classification model
Mosaic data enhanced mosaic
High quality domestic stereo codec cjc8988, pin to pin replaces wm8988
AutoCAD C polyline self intersection detection
使用SQL select count distinct查询语句统计数据库中某个字段的唯一值总数量
Sklearn Feature Engineering (summary)
mysql常用函数