使用 spectron 在 electron webview 上访问元素
Accessing Elements on electron webview using spectron
我正在尝试自动化将其内容加载到 webview 的电子应用程序。我正在为此使用 spectron 和 webdriverio。
这是我正在使用的代码。
it('should assess webview', function() {
var self = this;
return this.app.client.waitUntilWindowLoaded()
.windowHandles().then(function(session) {
self.app.client.switchTab(session.value[1])
.click("#my-id")
.then(console.log.bind(console))
.catch(console.log.bind(console));
});
});
这似乎不起作用。我不确定我哪里出错了。但是我用了
it('should assess webview', function() {
var self = this;
return this.app.client.waitUntilWindowLoaded()
.windowHandles().then(function(session) {
self.app.client.switchTab(session.value[1])
.getSource()
.then(console.log.bind(console))
.catch(console.log.bind(console));
});
});
以上代码确保webviewwindow句柄是否正确。它是。请帮忙。谢谢
我已经检查了代码,使用 spectron 和 运行 webview 模拟这种行为,你的代码工作正常。重写代码。希望这有帮助。
it('should assess webview', function() {
var self = this;
return this.app.client.waitUntilWindowLoaded()
.windowHandles().then(function(session) {
// Need to return the promise back, if promise is
// it would wait for the state or else app will exit.
return self.app.client.switchTab(session.value[1])
.click("#my-id") // check whether selector is present in DOM
.then(console.log.bind(console))
.catch(console.log.bind(console));
});
});
或
it('should assess webview', function() {
var self = this;
return this.app.client.waitUntilWindowLoaded()
.windowHandles()
.then(function(session) {
// switchTab & window will both focus
// window or tab which is active
return this.window(session.value[1])
})
.click("#my-id") // check whether selector is present in DOM
.then(console.log.bind(console))
.catch(console.log.bind(console));;
});
我正在尝试自动化将其内容加载到 webview 的电子应用程序。我正在为此使用 spectron 和 webdriverio。
这是我正在使用的代码。
it('should assess webview', function() {
var self = this;
return this.app.client.waitUntilWindowLoaded()
.windowHandles().then(function(session) {
self.app.client.switchTab(session.value[1])
.click("#my-id")
.then(console.log.bind(console))
.catch(console.log.bind(console));
});
});
这似乎不起作用。我不确定我哪里出错了。但是我用了
it('should assess webview', function() {
var self = this;
return this.app.client.waitUntilWindowLoaded()
.windowHandles().then(function(session) {
self.app.client.switchTab(session.value[1])
.getSource()
.then(console.log.bind(console))
.catch(console.log.bind(console));
});
});
以上代码确保webviewwindow句柄是否正确。它是。请帮忙。谢谢
我已经检查了代码,使用 spectron 和 运行 webview 模拟这种行为,你的代码工作正常。重写代码。希望这有帮助。
it('should assess webview', function() {
var self = this;
return this.app.client.waitUntilWindowLoaded()
.windowHandles().then(function(session) {
// Need to return the promise back, if promise is
// it would wait for the state or else app will exit.
return self.app.client.switchTab(session.value[1])
.click("#my-id") // check whether selector is present in DOM
.then(console.log.bind(console))
.catch(console.log.bind(console));
});
});
或
it('should assess webview', function() {
var self = this;
return this.app.client.waitUntilWindowLoaded()
.windowHandles()
.then(function(session) {
// switchTab & window will both focus
// window or tab which is active
return this.window(session.value[1])
})
.click("#my-id") // check whether selector is present in DOM
.then(console.log.bind(console))
.catch(console.log.bind(console));;
});