当前位置:网站首页>Slenium tips: how to handle some dialog boxes that may appear on Web pages
Slenium tips: how to handle some dialog boxes that may appear on Web pages
2022-06-25 20:20:00 【A novice Test Engineer】




Insert it here import time
from selenium import webdriver
driver=webdriver.Chrome()
driver.implicitly_wait(10)
driver.get('file:///D:/autoUI_selenium/lesson06/al.html')
# Trigger alert Dialog box
driver.find_element_by_css_selector('#b1').click()
time.sleep(2)
# Switch to alert The above object
#driver.switch_to.window()# Switch windows
#driver.switch_to.frame()# Switch to frame
al=driver.switch_to.alert
al.accept()# Call the confirmation method to confirm
# Trigger comfirm Dialog box
driver.find_element_by_css_selector('#b2').click()
time.sleep(2)
al1=driver.switch_to.alert
#al1.accept()# Call the confirmation method to confirm
al1.dismiss()# Call the cancel method to cancel
# Trigger promt Dialog box
driver.find_element_by_css_selector('#b3').click()
time.sleep(2)
al2=driver.switch_to.alert
al2.send_keys('123')# The input character
al2.accept() Into the code slice
边栏推荐
- 2.14(Knight Moves)
- 2020-11-14-Alexnet
- <C>. String comparison
- Nnformer reading notes
- The error log of vscode connecting to the server shows the problem of "insufficient permission". Directly use root to connect
- Database data type design (the most detailed in the whole network)
- 在打新债开户证券安全吗
- Huawei HMS core launched a new member conversion & retention prediction model
- Is it safe to open a new bond? Is low commission reliable
- TypeError: __ init__ () takes 1 positional argument but 5 were given
猜你喜欢

II Traits (extractors)

Two types of attribute injection methods

Thymleaf template configuration analysis

E-commerce project environment construction

Wechat applet swiper simple local picture display appears large blank

JS asynchronism (I. asynchronous concept, basic use of web worker)

Leetcode daily question - 27 Remove element (simple)

Arduino ide + esp8266+mqtt subscribe to publish temperature and humidity information

Wechat applet connects to the server to display mqtt data information

SQL statement select summary
随机推荐
Database data type design (the most detailed in the whole network)
<C>. function
在打新债开户证券安全吗?低佣金靠谱吗
206. reverse linked list (insert, iteration and recursion)
PAT B1081
Impact of Huawei application transfer and application claim on user identification
PAT B1053
[harmonyos] [arkui] how can Hongmeng ETS call pa
Please do not call Page constructor in files
String since I can perform performance tuning, I can call an expert directly
Force wechat page font size to be 100%
My official account writing experience sharing
Leaflet modify popup style
Wechat applet connects to the server to display mqtt data information
JS canvas drawing an arrow with two hearts
Matlab_ two point zero five
201604-4 test title: Game (BFS search maze)
<C>. String comparison
Two types of attribute injection methods
III Implementation principle of vector