蓝色天空网 · mbsky.com
WebDriver生命周期、窗口和导航
会话、窗口和页面各自管理。
固定本地测试页的实际浏览器结果,不是在线Python解释器。下载代码后可在独立环境修改输入并重新运行。
本章Python入口 · 完整实验实现 · 本站测试服务 · 本站页面交互

当前输入实际检查
| 实际检查 | 结果 |
|---|---|
| fixture-initial-no-severe-errors | 通过 |
| requested-outer-size | 通过 |
| other-title | 通过 |
| back-path | 通过 |
| forward-path | 通过 |
| refresh-rebuilds-document | 通过 |
| maximize-positive | 通过 |
| minimize-command | 通过 |
| fullscreen-positive | 通过 |
| new-distinct-handle | 通过 |
| close-only-current-tab | 通过 |
| screenshot-saved-actual-browser | 通过 |
| PNG-magic-actual-browser | 通过 |
| PNG-extent-actual-browser | 通过 |
| all-created-sessions-quit | 通过 |
本章完整入口
from selenium_lab import *
@case('selenium-webdriver')
def lifecycle(l,d,b,s):
original=d.current_window_handle;d.set_window_size(1100,800);rect=d.get_window_rect();l.eq('requested-outer-size',(rect['width'],rect['height']),(1100,800));d.get(b+'/other');l.check('other-title','学习计划'in d.title);d.back();l.eq('back-path',d.current_url,b+'/');d.forward();l.eq('forward-path',d.current_url,b+'/other');d.execute_script('window.transient=77');d.refresh();l.eq('refresh-rebuilds-document',d.execute_script('return window.transient??null'),None);d.maximize_window();l.check('maximize-positive',d.get_window_rect()['width']>0);d.minimize_window();l.check('minimize-command',True);d.fullscreen_window();l.check('fullscreen-positive',d.get_window_rect()['height']>0);d.set_window_size(1400,1000);d.switch_to.new_window('tab');new=d.current_window_handle;l.check('new-distinct-handle',new!=original);d.get(b+'/other');d.close();d.switch_to.window(original);l.eq('close-only-current-tab',len(d.window_handles),1);d.get(b);l.pending_case('actual-visible-window','Window commands executed headless; visible OS maximize/minimize/fullscreen not accepted')
if __name__ == "__main__":
run('selenium-webdriver')