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
Pop-ups
Selenium Webdriver - Pop-ups
一个新的人口窗口可打开点击连接点或 but子。 网上用户因违约而控制了主页,以便查阅新人群中的内容,网络用户控制必须从主页转移到新的人口窗口。
Methods
处理新人群的方法如下:
driver. Current_window_handle • 重点获取窗户的处理id。
driver.window_handles- 获取所有开端窗户的地址清单。
driver.swtich_to.window(<窗口处理id >- 将网络用户控制转向开放的窗口,其处理id作为参数通过。
在用 Apple果 but子标点击标语时,新浮标的标语是 Apple果国际发展的标语,让我们努力转向那里的新人群和进入元素。
Code Implementation
人口法的实施如下:
from selenium import webdriver driver = webdriver.Chrome(executable_path= ../drivers/chromedriver ) #imppcit wait time driver.imppcitly_wait(5) #url launch driver.get("https://the-internet.herokuapp.com/windows") #identify element s = driver.find_element_by_pnk_text("Cpck Here") s.cpck() #current main window handle m= driver.current_window_handle #iterate over all window handles for h in driver.window_handles: #check for main window handle if h != m: n = h #switch to new tab driver.switch_to.window(n) print( Page title of new tab: + driver.title) #switch to main window driver.switch_to.window(m) print( Page title of main window: + driver.title) #quit browser driver.quit()
Output
产出显示了这一信息——退出代码0的过程意味着上述雷达法成功执行。 首先,新版(从方法名称中查到)的页标题——用 Apple果 ID印的标语印在 con。 其次,在将网络用户控制转向主要窗口之后,其网页名称——《签字:In>account》确实在康索尔印刷。
Advertisements