- 登錄qq郵箱、操作表單、進入主界面
使用句柄:



通過句柄,跳轉頁面后可操作該頁面
Get Window Handles:獲取視窗的句柄
Select Window By Handle:切換到新視窗


注意:跳轉視窗需要Select Window By Handle關鍵字,但是類別庫中沒有對應的關鍵字,需要我們進行如下操作
1:在D:\install\python\python\Lib\site-packages\SeleniumLibrary\locators\windowmanager.py中添加
ef select_by_handle(self, browser, toHandle):
browser.switch_to_window(toHandle)
def get_window_handles(self, browser):
return [ window_info[0] for window_info in
self._get_window_infos(browser) ]
def get_current_window_handle(self, browser):
return browser.get_current_window_handle()
2:在D:\install\python\python\Lib\sitepackages\SeleniumLibrary\keywords\browsermanagement.py中添加
@keyword
def select_window_by_handle(self, locator=None):
self._window_manager.select_by_handle(self.drivers.current, locator)
@keyword
def get_window_handles(self):
"""Returns and logs handles of all windows known to the browser."""
return
self._log_list(self._window_manager.get_window_handles(self.drivers.current))
@keyword
def get_current_window_handle(self):
"""Returns and logs handle of current window known to the browser."""
return
self._log_list(self._window_manager.get_current_window_handle(self.drivers.curre
nt))
3:從新啟動ride.py才能正常加載
可以參考:https://blog.csdn.net/youxitou/article/details/92656020

DOS下執行RF腳本
1:找到python中的Scripts目錄,新建一個pybot.bat檔案

2:在pybot.bat檔案中添加下面的命令
@Echo off
python -m robot.run %*

3:在dos視窗輸入命令執行
執行整個專案下的所有用例: pybot 專案路徑
比如:pybot D:\install\python\robotframeworkwork\mashang\RF測驗

轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/348636.html
標籤:其他
