我试图通过RobotFramework在InPrivate模式下打开IE,如下所示:
${dc} Evaluate sys.modules['selenium.webdriver'].DesiredCapabilities.INTERNETEXPLORER sys, selenium.webdriver
Log To Console ${dc}
Set To Dictionary ${dc} ie.forceCreateProcessApi=${True} ie.browserCommandLineSwitches=-private
Log To Console ${dc}
Open Browser www.google.com ie desired_capabilitie=${dc}
脚本停留在最后一步,直到按Ctrl + C.有人知道如何解决这个问题吗?
感谢您的帮助!
答案 0 :(得分:0)
以下代码适用于我:
*** Settings ***
Library Collections
Library Selenium2Library
*** Test Cases ***
Test IE InPrivate
${dc} Evaluate sys.modules['selenium.webdriver'].DesiredCapabilities.INTERNETEXPLORER sys, selenium.webdriver
Set To Dictionary ${dc} ignoreProtectedModeSettings ${True}
Set To Dictionary ${dc} ie.forceCreateProcessApi ${True}
Set To Dictionary ${dc} ie.browserCommandLineSwitches=-private
Open Browser www.google.com ie desired_capabilitie=${dc}
但是,请注意,为了使forceCreateProcessApi
设置正常工作,需要添加其他注册表项:HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\TabProcGrowth = '0'
。否则会出现以下错误:
WebDriverException: Message: Unexpected error launching Internet Explorer. Unable to use
CreateProcess() API. To use CreateProcess() with Internet Explorer 8 or higher, the value
of registry setting in
HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\TabProcGrowth must be '0'.