selenium Edge IE模式在Qmetry中未按预期工作

kpbwa7wx  于 2023-01-13  发布在  其他
关注(0)|答案(1)|浏览(122)

我想运行边缘IE模式使用qmetry。我们得到有线空白白色IE页面被打开时,我们点击登录按钮在我们的应用程序。相同的网站工作正常时,我执行它没有qmetry。
独立代码:

System.setProperty("webdriver.ie.driver", Global.WINDOWS_USER_HOME + "\.cache\selenium\IEDriverServer\win64\" + IEversion + "\IEDriverServer.exe");
InternetExplorerOptions iExplorerOptions = new InternetExplorerOptions();
iExplorerOptions.setCapability(InternetExplorerDriver.FORCE_CREATE_PROCESS, true);
iExplorerOptions.setCapability(InternetExplorerDriver.IE_SWITCHES, "-private");
iExplorerOptions.attachToEdgeChrome();
iExplorerOptions.ignoreZoomSettings();
iExplorerOptions.setCapability("ignoreProtectedModeSettings", true);
iExplorerOptions.withEdgeExecutablePath("C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe");
return new InternetExplorerDriver(new BrowserFactory().setInternetExplorerOptions());`

Qmetry使用的代码

String IEversion = downloadWebDriver();
System.setProperty("webdriver.ie.driver", Global.WINDOWS_USER_HOME + "\.cache\selenium\IEDriverServer\win64\" + IEversion + "\IEDriverServer.exe");
ConfigurationManager.getBundle().setProperty("iexplorer.additional.capabilities", "{'initialBrowserUrl':'" + Global.IE_INITIAL_BROWSERURL + "','ignoreProtectedModeSettings': true,'ignoreZoomSetting': true,'ie.browserCommandLineSwitches':'-private','ie.edgechromium':true,'ie.edgepath':'C://Program Files (x86)//Microsoft//Edge//Application//msedge.exe','ie.forceCreateProcessApi':true}");
Global.driver.set(new QAFExtendedWebDriver());  
return new QAFExtendedWebDriver();

您能看一下并告诉我们QAF 3.1.0有什么问题吗?

bsxbgnwa

bsxbgnwa1#

问题是在return new QAFExtendedWebDriver();中,您需要将构造函数与功能对象return new QAFExtendedWebDriver(capabilities);一起使用。
假设您已经设置了驱动程序名称和驱动程序功能,正确的方法是通过以下方式之一使用测试库中的getDriver()方法:

new WebDriverTestBase().getDriver();
new WebDriverTestCase().getDriver();
(QAFExtendedWebDriver)TestBaseProvider.instance().get().getUiDriver();

创建json格式的能力最简单的方法是创建能力对象并打印,例如:

public static void main(String[] args) throws ScriptException {
        InternetExplorerOptions iExplorerOptions = new InternetExplorerOptions();
        iExplorerOptions.setCapability(InternetExplorerDriver.FORCE_CREATE_PROCESS, true);
        iExplorerOptions.setCapability(InternetExplorerDriver.IE_SWITCHES, "-private");
        iExplorerOptions.attachToEdgeChrome();
        iExplorerOptions.ignoreZoomSettings();
        iExplorerOptions.setCapability("ignoreProtectedModeSettings", true);
        iExplorerOptions.withEdgeExecutablePath("C:/Program Files (x86)/Microsoft/Edge/Application/msedge.exe");
        
        System.out.println(JSONUtil.toString(iExplorerOptions.asMap()));
}

这将打印
{“浏览器名称”:“internet explorer”,“即浏览器命令行开关”:“-私有”,“即边缘 chrome 元素”:真,“即边缘路径”:“C:/程序文件(x86)/Microsoft/Edge/应用程序/msedge.exe”,“即强制创建进程Api”:真,“忽略保护模式设置”:真,“忽略缩放设置”:真,“即浏览器选项”:{“即边缘 chrome 元素”:真,“即浏览器命令行开关”:“-私有”,“即强制创建进程Api”:真,“忽略缩放设置”:真,“即边缘路径”:“C:/程序文件(x86)/Microsoft/Edge/应用程序/msedge.exe”,“忽略保护模式设置”:真}
如果你已经使用驱动程序名称作为iexplorer,从上面的参考设置边缘驱动程序的能力。

driver.name=iexplorerDriver
iexplorer.additional.capabilities={"browserName":"internet explorer","ie.browserCommandLineSwitches":"-private","ie.edgechromium":true,"ie.edgepath":"C:/Program Files (x86)/Microsoft/Edge/Application/msedge.exe","ie.forceCreateProcessApi":true,"ignoreProtectedModeSettings":true,"ignoreZoomSetting":true,"se:ieOptions":{"ie.edgechromium":true,"ie.browserCommandLineSwitches":"-private","ie.forceCreateProcessApi":true,"ignoreZoomSetting":true,"ie.edgepath":"C:/Program Files (x86)/Microsoft/Edge/Application/msedge.exe","ignoreProtectedModeSettings":true}}

相关问题