场景:用于开发人员应用注册的Web表单,包含两部分工作流程.
第1页:填写开发者应用程序详细信息,然后单击按钮以在新选项卡中创建应用程序ID,该ID将打开...
第2页:App ID页面.我需要从此页面复制App ID,然后关闭选项卡并返回到第1页并填写App ID(从第2页保存),然后提交表单.
我了解基本用法 - 如何打开第1页并单击打开第2页的按钮 - 但如何在新选项卡中打开第2页时如何处理?
例:
const puppeteer = require('puppeteer');
(async() => {
const browser = await puppeteer.launch({headless: false, executablePath: '/Applications/Google Chrome.app'});
const page = await browser.newPage();
// go to the new bot registration page
await page.goto('https://register.example.com/new', {waitUntil: 'networkidle'});
// fill in the form info
const form = await page.$('new-app-form');
await page.focus('#input-appName');
await page.type('App name here');
await page.focus('#input-appDescription');
await page.type('short description of app here');
await page.click('.get-appId'); //opens new tab with Page 2
// handle …Run Code Online (Sandbox Code Playgroud) 使用puppeteer,你怎么能以编程方式提交表单?到目前为止,我已经能够使用page.click('.input[type="submit"]')如果表单实际包含提交输入.但是对于不包含提交输入的表单,关注表单文本输入元素和使用page.press('Enter')似乎并不会导致表单提交:
const puppeteer = require('puppeteer');
(async() => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto('https://stackoverflow.com/', {waitUntil: 'load'});
console.log(page.url());
// Type our query into the search bar
await page.focus('.js-search-field');
await page.type('puppeteer');
// Submit form
await page.press('Enter');
// Wait for search results page to load
await page.waitForNavigation({waitUntil: 'load'});
console.log('FOUND!', page.url());
// Extract the results from the page
const links = await page.evaluate(() => {
const anchors = Array.from(document.querySelectorAll('.result-link a'));
return anchors.map(anchor …Run Code Online (Sandbox Code Playgroud) 是否有计划在不久的将来支持.NET Core?我的意思是,没有重构我的机器人代码.仍有与之不兼容的组件.
我正在尝试构建skype bot.
我按照给出的文档skype-sdk但未能使用它创建它.无法从机器人获得回复.
const fs = require('fs');
const restify = require('restify');
const skype = require('skype-sdk');
const botService = new skype.BotService({
messaging: {
botId: 'xxxxxxxx-xxx-xxx-xxx-xxxxxxxxxxxx',
serverUrl : "https://example.net",
requestTimeout : 15000,
appId: 'xxxxxxxx-xxx-xxx-xxx-xxxxxxxxxxxx',
appSecret: 'xxxxxxxxxxxxxxxxxxxxxxxx'
}
});
botService.on('contactAdded', (bot, data) => {
console.log("bot replay");
bot.reply('Hello ${data.fromDisplayName}!', true);
});
botService.on('personalMessage', (bot, data) => {
console.log("person replay");
bot.reply('Hey ${data.from}. Thank you for your message: "${data.content}".', true);
});
const server = restify.createServer();
server.use(skype.ensureHttps(true));
server.use(skype.verifySkypeCert({}));
server.post('/skbot', skype.messagingHandler(botService));
const port = process.env.PORT || 8080; …Run Code Online (Sandbox Code Playgroud) 我正在尝试在NodeJS上使用AdaptiveCards npm包以编程方式生成卡,但我没有看到如何生成要传递给消息的JSON.到目前为止,我的代码非常简单:
session.send(new builder.Message(session).addAttachment({
contentType: "application/vnd.microsoft.card.adaptive",
content: createCard()
}));
function createCard() {
let card = new adaptiveCards.AdaptiveCard({ type: "AdaptiveCard" });
// add a text block
card.addItem(new adaptiveCards.TextBlock({
text: 'Issue #1',
weight: "bolder",
size: "medium"
}));
return card;
}
Run Code Online (Sandbox Code Playgroud)
我试图打电话给render方法,但它不起作用.我也试着打电话JSON.stringify(card)但是我得到了TypeError: Converting circular structure to JSON消息错误.任何的想法?如果我将JSON传递给内容附件,那么一切正常.
所以我想class多次截取特定的屏幕截图,但它总是会说Session Closed或Terminated,因此我努力实现打开多个实例的多个屏幕截图。
有人至少可以指导如何在同一个浏览器实例上使用多个实例吗?
my code:
const puppeteer = require("puppeteer");
const SELECTOR = ".octicon";
(async () => {
let screenshotNumber = 0;
async function screenshots() {
const browser = await puppeteer.launch({
headless: true
});
try {
let page = await browser.newPage();
page.setViewport({ width: 1000, height: 600, deviceScaleFactor: 2 });
await page.goto("https://github.com/");
await page.waitForNavigation({ waitUntil: "networkidle" });
const rect = await page.evaluate(selector => {
const element = document.querySelector(selector);
const { x, y, width, height } …Run Code Online (Sandbox Code Playgroud)node.js ×4
puppeteer ×3
botframework ×2
javascript ×2
.net-core ×1
bots ×1
chromium ×1
skype-bots ×1