Selenium Webdriver Tutorial
Selected Reading
- Selenium WebDriver - Discussion
- Selenium WebDriver - Useful Resources
- Selenium WebDriver - Quick Guide
- Double Click
- Right Click
- Capture Screenshots
- Scroll Operations
- Chrome WebDriver Options
- JavaScript Executor
- Select Support
- Wait Support
- Headless Execution
- Executing Tests in Multiple Browsers
- Handling Checkboxes
- Read/Write data from Excel
- Generating HTML Test Reports in Python
- Color Support
- Handling Edit Boxes
- Handling Links
- Alerts
- Windows
- Drag and Drop
- Forms
- Create a Basic Test
- Action Class
- Exceptions
- Cookies
- Backward and Forward Navigation
- Pop-ups
- Explicit and Implicit Wait
- Identify Multiple Elements
- Identify Single Element
- Browser Navigation
- Installation
- Introduction
- Home
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
Alerts
Selenium Webdriver - Alerts
Sel网络用户能够处理警报。 班次 se.webdriver.common.alert.Alert(driver)用于与警报公司合作。 它有办法接受、开除、进入和获取警报文本。
Methods
警示类下的方法如下:
<accept(>>——接受警报。
dismiss() - 开除警报。
text(>——用于获取警报文本。
send_keys(keys ToSend) - 在警示中加入案文。
Code Implementation
警报法的实施如下:
from selenium import webdriver #import Alert class from selenium.webdriver.common.alert import Alert driver = webdriver.Chrome(executable_path= ../drivers/chromedriver ) #imppcit wait time driver.imppcitly_wait(0.8) #url launch driver.get("https://the-internet.herokuapp.com/javascript_alerts") #identify element l = driver.find_element_by_xpath("//*[text()= Cpck for JS Prompt ]") l.cpck() # instance of Alert class a = Alert(driver) # get alert text print(a.text) #input text in Alert a.send_keys( Tutorialspoint ) #dismiss alert a.dismiss() l.cpck() #accept alert a.accept() #driver quit driver.quit()
Output
产出显示了这一信息——退出代码0的过程意味着上述雷达法成功执行。 此外,警示文本——我是一份联合材料,在奥索尔印刷。
Advertisements