我们需要测试电子应用程序。我们使用的是光谱,它使用ChromeDriver和WebdriverIO (Selenium2.0bindingforNodeJS)。
问题:我们的应用程序从打开的开发工具窗口开始,而不是主应用程序窗口。Webdriver连接到dev tools窗口,而不是主窗口。我们无法切换到主窗口。
示例代码:
var app = new Application({
path: cfg.pathToElectron,
args: [cfg.pathToSA]
});
app.start().then(function(){
app.client // <- this is dev tools window instead of main window
// this closes the dev tools which is ok but we need to switch to main window
app.client.close();
// things like this doesn't help
app.client.execute('xxx.getCurrentWindow().closeDevTools()');
});有什么想法如何从开发工具切换到主窗口?
发布于 2017-01-06 12:16:40
你知道那种感觉,当你问一个问题,而不是立即找到答案?
解决方案是从谱API调用windowByindex()。为此,您需要从谱调用API函数,而不是从网络驱动程序调用函数。
因此,解决我们的问题的办法是:
app.start().then(function(){
app.client.windowByIndex(1);
});https://stackoverflow.com/questions/41505214
复制相似问题