【发布时间】:2020-07-05 02:01:33
【问题描述】:
我正在尝试对我的 .jade 文件中的按钮 onClick 使用函数。该函数位于 javascript 文件中。每当单击按钮时,我都想使用屏幕截图功能。我的问题是我是否正确导入了 .js 文件?另外,我是否正确调用了该函数?
当我运行时,这是我得到的错误:
Invalid or unexpected token on the line button(onClick = #
{screenshots(client)}) GO
索引.jade
extends layout
block content
h1= title
script (src='../scripts/screenshot.js')
p Welcome to #{title}
button(onClick = #{screenshots(client)}) GO
div.Windows
img(src="http://localhost:3000/images/myscreenshot2.png", class="image", width="20%", height="20%")
object(data="http://localhost:3000/test.txt",class = "texttest",width='50%', height='615px' display: block;)
screenshot.js
async function screenshots(client) {
await client.takeScreenshot().then(
client.saveScreenshot("./public/images/myscreenshot2.png")
);
}
async function connection () {
const wdio = require("webdriverio");
const assert = require("assert");
const opts = {
port: 4723,
capabilities: {
platformName: "Android",
platformVersion: '8.1',
deviceName: "emulator-5554",
app: "C:\\Users\\user1\\Downloads\\test.apk",
automationName: "UiAutomator2"
}
};
const fs = require('fs');
const client = await wdio.remote(opts);
【问题讨论】:
标签: javascript pug